library(lavaan)
rating_data <- HEXACO_example_data
cfa_model <- paste0("H =~ ", paste0("SS", seq(6,60,6), collapse = " + "), "\n",
"E =~ ", paste0("SS", seq(5,60,6), collapse = " + "), "\n",
"X =~ ", paste0("SS", seq(4,60,6), collapse = " + "), "\n",
"A =~ ", paste0("SS", seq(3,60,6), collapse = " + "), "\n",
"C =~ ", paste0("SS", seq(2,60,6), collapse = " + "), "\n",
"O =~ ", paste0("SS", seq(1,60,6), collapse = " + "), "\n")
cfa_estimates <- get_CFA_estimates(response_data = rating_data,
fit_model = cfa_model,
item_names = paste0("SS",c(1:60)))
cfa_matrices <- get_simulation_matrices(loadings = cfa_estimates$loadings,
intercepts = cfa_estimates$intercepts,
residuals = cfa_estimates$residuals,
covariances = cfa_estimates$covariances,
N = 100, N_items = 60, N_dims = 6,
dim_names = c("H", "E", "X", "A", "C", "O"),
empirical = TRUE)
### Re-order the Utility columns!
cfa_matrices$Utility <- cfa_matrices$Utility[,c(t(matrix(1:60, ncol = 6)[,6:1]))]
### N_response need to be consistent with those specified in get_simulated_matrices()
FC_resp <- convert_to_TIRT_response(Utility = cfa_matrices$Utility,
block_design = make_random_block(60, 60, 3),
N_response = 100, format = "pairwise",
block_size = 3, N_blocks = 20)
FC_rank_resp <- convert_to_TIRT_response(Utility = cfa_matrices$Utility,
block_design = make_random_block(60, 60, 5),
N_response = 100, format = "ranks",
block_size = 5, N_blocks = 12)
FC_rank_partial_resp <- convert_to_TIRT_response(Utility = cfa_matrices$Utility,
block_design = make_random_block(60, 60, 5),
N_response = 100, format = "ranks", partial = TRUE,
block_size = 5, N_blocks = 12)
FC_resp
FC_rank_resp
FC_rank_partial_resp
Run the code above in your browser using DataLab