estimate_thirt_params_mcmc | R Documentation |
Estimate parameters with MCMC
estimate_thirt_params_mcmc(
resp,
items,
control = list(),
initial_params = list(),
fixed_params = list(),
op_params = list()
)
resp |
a data.frame of length |
items |
a data.frame of length |
control |
a list of three parameters to control the MCMC algorithm:
|
initial_params |
a list of initial parameters to start the algorithm, each parameter needs to be a matrix named theta, gamma, lambda, or psisq. |
fixed_params |
a list of fixed parameters to be excluded from estimation, each parameter needs to be a matrix named theta, gamma, lambda, or psisq. |
op_params |
a list of fixed parameters for operational items, each parameter needs to be a matrix named gamma, lambda, or psisq. |
a list of three objects if no operational items are provided:
all_iters
is a list of length [n_iter]
for parameter estimates for all iterations,
mean_mcmc
is a list of length 4 for mean of four parameters after burn-ins,
sd_mcmc
is a list of length 4 for SD of four parameters after burn-ins.
three additional objects are included if operational items are provided:
all_iters_test
includes all iterations for test items calibration,
mean_mcmc_test
includes parameter estimates for test items calibration,
sd_mcmc_test
includes parameter SD across iterations for test items calibration.
## Not run:
set.seed(202108)
# designs
n_person <- 100
n_item <- 3
n_neg <- 1
n_block <- 2
n_dim <- 4
n_iter <- 1000
n_burnin <- 20
step_size_sd <- 0.1
# simulate parameters
params <- simulate_thirt_params(n_person = n_person,
n_item = n_item,
n_neg = n_neg,
n_block = n_block,
n_dim = n_dim)
resp <- do.call(simulate_thirt_resp, params)
gamma <- params$gamma$gamma
lambda <- params$items$lambda
psisq <- params$items$psisq
theta <- params$persons[, -1]
# operational parameters
op_gamma <- matrix(
# first pair 1-2 is fixed for each of 2 blocks
c(0.4, NA, NA,
-0.9, NA, NA)
)
op_lambda <- matrix(
# first 2 items are fixed for each of 2 blocks
c(-0.65, 0.55, NA,
0.57, -0.40, NA)
)
op_psisq <- matrix(
# first 2 items are fixed for each of 2 blocks
c(0.89, 0.72, NA,
0.02, 0.41, NA)
)
# estimation output
start_mcmc <- Sys.time()
output <- estimate_thirt_params_mcmc(resp = resp$resp,
items = resp$items,
control = list(n_iter = n_iter,
n_burnin = n_burnin,
step_size_sd = step_size_sd),
op_params = list(gamma = op_gamma,
lambda = op_lambda,
psisq = op_psisq)
)
end_mcmc <- Sys.time()
# correlate estimated and true parameters
diag(cor(theta, output$mean_mcmc$theta))
cor(gamma, output$mean_mcmc_test$gamma)
cor(lambda, output$mean_mcmc_test$lambda)
cor(psisq, output$mean_mcmc_test$psisq)
(time_mcmc <- end_mcmc - start_mcmc)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.