get_simulation_matrices: Generate Simulated Person and Item Parameter Matrices for the...

View source: R/get_simulation_matrices.R

get_simulation_matricesR Documentation

Generate Simulated Person and Item Parameter Matrices for the TIRT Model

Description

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.

Usage

get_simulation_matrices(
  cfa_estimates,
  N,
  empirical = FALSE,
  theta_mean = 0,
  theta_cov = NULL
)

Arguments

cfa_estimates

A list object returned by get_CFA_estimates().

N

Integer. Number of simulated responses (participants) to generate.

empirical

Logical. As in MASS::mvrnorm(): Should mu and sigma specify the empirical, rather than population, mean and covariance? Defaults to FALSE.

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.

Value

A list containing matrices for Lambda (Loadings), Mu (Intercepts), Epsilon (Residuals), Theta (Latent Traits), and Utility.

Examples

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]

autoFC documentation built on July 14, 2026, 5:07 p.m.