Description Usage Arguments Value Examples
Obtains a latent trait estimate and variance of the estimate.
1 2 3 4 | estimate_latent_trait(estimate, answers, prior_form, prior_parameters, model,
administered, number_dimensions, estimator, alpha, beta, guessing,
number_itemsteps_per_item, safe_eap = FALSE,
eap_estimation_procedure = "riemannsum")
|
estimate |
Vector containing current theta estimate, with covariance matrix as an attribute. |
answers |
Vector with answers to administered items. |
prior_form |
String indicating the form of the prior; one of |
prior_parameters |
List containing mu and Sigma of the normal prior: |
model |
One of |
administered |
Vector with indices of administered items. |
number_dimensions |
Number of dimensions. |
estimator |
Type of estimator to be used, one of |
alpha |
Matrix of alpha parameters, one column per dimension, one row per item. Row names should contain the item keys. Note that so called within-dimensional models still use an alpha matrix, they simply have only one non-zero loading per item. |
beta |
Matrix of beta parameters, one column per item step, one row per item. Row names should contain the item keys.
Note that |
guessing |
Matrix with one column of guessing parameters per item. Row names should contain the item keys. Optionally used in 3PLM model, ignored for all others. |
number_itemsteps_per_item |
Vector containing the number of non missing cells per row of the beta matrix. |
safe_eap |
Only relevant if estimator is expected aposteriori.
Set to |
eap_estimation_procedure |
String indicating the estimation procedure if estimator is expected aposteriori and prior form is normal. One of |
Vector containing the updated estimate with the covariance matrix as attribute.
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 | number_dimensions <- 1
estimate <- rep(.3, number_dimensions)
model <- "3PLM"
number_items <- 50
answers <- rep(c(1, 0), 17)
administered <- c(6:20, 31:49)
alpha <- matrix(runif(number_items * number_dimensions, .3, 1.5),
nrow = number_items, ncol = number_dimensions)
beta <- matrix(rnorm(number_items), nrow = number_items, ncol = 1)
guessing <- c(rep(.1, number_items / 2), rep(.2, number_items / 2))
number_itemsteps_per_item <- ShadowCAT:::number_non_missing_cells_per_row(beta)
prior_form <- "normal"
prior_parameters <- list(mu = 0, Sigma = diag(1))
# Obtain estimates
# Note that maximum a posteriori combined with uniform prior
# is equivalent to maximum likelihood with bounds
estimator <- "maximum_aposteriori"
ML <- ShadowCAT:::estimate_latent_trait(estimate, answers,
prior_form = "uniform",
prior_parameters = list(lower_bound = -4, upper_bound = 4),
model, administered, number_dimensions, estimator,
alpha, beta, guessing, number_itemsteps_per_item)
estimator <- "maximum_aposteriori"
MAP <- ShadowCAT:::estimate_latent_trait(estimate, answers,
prior_form, prior_parameters,
model, administered, number_dimensions, estimator,
alpha, beta, guessing, number_itemsteps_per_item)
estimator <- "expected_aposteriori"
EAP <- ShadowCAT:::estimate_latent_trait(estimate, answers,
prior_form, prior_parameters,
model, administered, number_dimensions, estimator,
alpha, beta, guessing, number_itemsteps_per_item)
ML; MAP; EAP
# access variance
attr(ML, "variance")
# Note that expected_aposteriori takes considerably more time when dimensionality is higher:
number_dimensions <- 5
estimate <- rep(.3, number_dimensions)
alpha <- matrix(runif(number_items * number_dimensions, .3, 1.5),
nrow = number_items, ncol = number_dimensions)
prior_form <- "normal"
prior_parameters <- list(mu = rep(0, number_dimensions), Sigma = diag(number_dimensions))
estimator <- "maximum_aposteriori"
system.time(ShadowCAT:::estimate_latent_trait(estimate, answers,
prior_form, prior_parameters,
model, administered, number_dimensions, estimator,
alpha, beta, guessing, number_itemsteps_per_item))
estimator <- "expected_aposteriori"
system.time(ShadowCAT:::estimate_latent_trait(estimate, answers,
prior_form, prior_parameters,
model, administered, number_dimensions, estimator,
alpha, beta, guessing, number_itemsteps_per_item))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.