View source: R/get_simulation_matrices.R
| get_simulation_matrices | R Documentation |
Takes the factor analysis results extracted by get_CFA_estimates()
and generates simulated person traits, item parameters, and latent utility values
for a Thurstonian IRT model.
get_simulation_matrices(
cfa_estimates,
N,
empirical = FALSE,
theta_mean = 0,
theta_cov = NULL
)
cfa_estimates |
A list object returned by |
N |
Integer. Number of simulated responses (participants) to generate. |
empirical |
Logical. As in |
theta_mean |
Specifies the original mean of the simulated traits |
theta_cov |
Specifies the original covariance of the simulated traits - if you don't want to use the estimates from the cfa() function. |
A list containing matrices for Lambda (Loadings), Mu (Intercepts),
Epsilon (Residuals), Theta (Latent Traits), and Utility.
cfa_model <- paste0("H =~ ", paste0("SS", seq(6, 18, by = 6), collapse = " + "), "\n",
"E =~ ", paste0("SS", seq(5, 18, by = 6), collapse = " + "), "\n",
"X =~ ", paste0("SS", seq(4, 18, by = 6), collapse = " + "), "\n")
cfa_fit <- lavaan::cfa(cfa_model, data = HEXACO_example_data[1:500,], ordered = TRUE,
estimator = "WLSMV", verbose = TRUE, test = "none", se = "none")
cfa_estimates <- get_CFA_estimates(cfa_fit)
simu_estimates <- get_simulation_matrices(cfa_estimates, N = 500)
### Because utilities orders are exactly the order each item appears in the cfa model,
### you may need to re-order the columns back in your own case.
num_order <- order(as.numeric(gsub("[^0-9]", "", colnames(simu_estimates$Utility))))
new_Utility <- simu_estimates$Utility[, num_order]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.