| irt_simulate | R Documentation |
Execute a Monte Carlo simulation study based on an irt_study specification. For each iteration and sample size, data are generated, missing values applied, the IRT model is fitted, and parameter estimates are extracted and stored.
irt_simulate(
study,
iterations,
seed,
progress = TRUE,
parallel = FALSE,
se = TRUE,
compute_theta = TRUE
)
study |
An irt_study object specifying the design and study conditions. |
iterations |
Positive integer. Number of Monte Carlo replications. |
seed |
Integer. Base random seed for reproducibility. Each iteration
uses |
progress |
Logical. Print progress messages? Default |
parallel |
Logical. Run iterations in parallel using
|
se |
Logical. Compute standard errors and confidence intervals for item
parameter estimates? Default |
compute_theta |
Logical. Compute EAP theta estimates and recovery metrics
(correlation, RMSE)? Default |
The returned irt_results object stores raw per-iteration estimates.
Use summary.irt_results() to compute performance criteria (bias, MSE,
RMSE, coverage, etc.) and plot.irt_results() to visualize results.
When parallel = TRUE, the Monte Carlo loop over iterations is
parallelized via future.apply::future_lapply(). Each parallel task
processes one iteration across all sample sizes sequentially.
Important: This function does NOT configure a future plan. Users must
set their own plan before calling with parallel = TRUE:
library(future) plan(multisession, workers = 4) # or your preferred backend results <- irt_simulate(study, iterations = 100, seed = 42, parallel = TRUE)
Without an explicit plan, future defaults to sequential execution (no parallelism).
Reproducibility is guaranteed within a given dispatch mode, not across modes:
Serial mode (parallel = FALSE) uses deterministic per-cell seeds
under the session's default RNG kind (Mersenne-Twister). Re-running with
the same base seed reproduces identical results bit-for-bit.
Parallel mode (parallel = TRUE) delegates RNG management to
future.apply::future_lapply(..., future.seed = TRUE), which assigns
each iteration a formally independent L'Ecuyer-CMRG substream. Re-running
with the same base seed reproduces identical results bit-for-bit across
parallel runs, including across different worker counts.
Across modes, numerical results will differ because the two paths use different RNG algorithms and different seeding strategies. Both are statistically valid; the parallel path has the stronger formal guarantee of independent substreams, which is the standard for Monte Carlo work.
Progress messages are suppressed in parallel mode (workers cannot stream to
stdout safely). Set progress = FALSE in serial mode to suppress messages
(they appear every 10% of iterations).
An S3 object of class irt_results containing:
Data frame with per-iteration item parameter estimates (columns: iteration, sample_size, item, param, true_value, estimate, se, ci_lower, ci_upper, converged).
Data frame with per-iteration theta recovery summaries (columns: iteration, sample_size, theta_cor, theta_rmse, converged).
The original irt_study object.
Number of replications run.
Base seed used.
Elapsed wall-clock time in seconds.
Logical flag indicating whether SEs and CIs were computed.
Logical flag indicating whether theta recovery metrics were computed.
irt_study() for specifying study conditions,
summary.irt_results() and plot.irt_results() for analyzing output,
irt_iterations() for determining the number of replications.
# Minimal example (iterations and sample sizes reduced for speed;
# use iterations >= 100 and 3+ sample sizes in practice)
design <- irt_design(
model = "1PL", n_items = 5,
item_params = list(b = seq(-2, 2, length.out = 5))
)
study <- irt_study(design, sample_sizes = c(200, 500))
results <- irt_simulate(study, iterations = 10, seed = 42)
summary(results)
plot(results)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.