-
Notifications
You must be signed in to change notification settings - Fork 1
/
edm-model.R
91 lines (85 loc) · 2.48 KB
/
edm-model.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#' Construct a property list for the model.
#'
#' Holds detail information about the model.
#'
#' @param n Number of Observations
#' @param j Number of Items
#' @param k Number of Attributes
#' @param runtime Duration of C++ Estimation
#' @param ... Additional properties
#' @param class Designate the model-specific class.
#'
#' @export
new_edm_default_property_list = function(n, j, k, runtime, ..., class = character()) {
structure(
list(
n = n,
k = k,
runtime = runtime,
...,
call = match.call()
),
class = c(class, "edm_property_list", "list")
)
}
#' Display Exploratory Diagnostic Model Properties
#'
#' Custom print method for viewing Exploratory Diagnostic Model properties.
#' @inherit base::print
#' @export
print.edm_property_list = function(x, ...) {
# Display call
cat("Call:\n")
print(x$call)
# Supress call
public_features = x
public_features$call = NULL
# Show the model level information
cat("Model details:\n")
cat(paste0("* ", names(x), ": ", x, collapse = "\n"))
invisible(x)
}
#' Construct an EDM model class object with pre-defined names.
#'
#' Base class that provides slots for growth within the modeling objects.
#'
#' @param chain Values from the MCMC chains across iterations.
#' @param property_list Information on the data and algorithm configuration.
#' @param estimate Any estimate done within C++ and raised into R during
#' the modeling procedure.
#' @param ... Additional model-specific data
#' @param class Designate the model-specific class.
#'
#' @return
#' An EDM model object with subclasses of `class`, `edm`, and `list` that
#' contains:
#'
#' - `chains`: Chain values
#' - `property_list`: Estimation details including:
#' - `n`: Number of Observations
#' - `k`: Number of Attributes
#' - `order`: Highest degree from 1 to P = 2^K or less.
#' - `estimate`:
#' - **Note:** May be `NA` or a sub-list.
#'
#' @export
new_edm_model = function(chain, property_list, estimate = NA, ..., class = character()) {
structure(
list(
"chain" = chain,
"property_list" = property_list,
"estimate" = estimate,
...
),
class = c(class, "edm_model", "list")
)
}
#' Print Exploratory Diagnostic Model Components
#'
#' Custom print method for viewing Exploratory Diagnostic Model components.
#' @inherit base::print
#' @export
print.edm_model = function(x, ...) {
print(x$property_list)
print(x$estimate)
}