irtree_sim1: Generate data from and fit an ItemResponseTrees model

Description Usage Arguments Value See Also

View source: R/simulation.R

Description

This function generates data from gen_model, subsequently fits all the models in fit_model, and returns the results and/or saves them to an external RData file.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
irtree_sim1(
  R = 1,
  gen_model = NULL,
  fit_model = gen_model,
  N = NULL,
  sigma = NULL,
  itempar = NULL,
  link = c("logit", "probit"),
  na_okay = TRUE,
  engine = c("mirt", "mplus", "tam"),
  verbose = TRUE,
  control = NULL,
  improper_okay = FALSE,
  par_type = "difficulty",
  file = NULL,
  dir = tempdir(),
  save_rdata = FALSE,
  reduce_output = FALSE
)

Arguments

R

Integer used to number the saved output if save_rdata = TRUE. Really only useful when used from irtree_sim().

gen_model

Object of class irtree_model describing the data-generating model. See irtree_model for more information.

fit_model

Object of class irtree_model describing the model that should be fit to the data. May be a list of multiple objects of class irtree_model if different models should be fit to the same data set. See irtree_model for more information.

N

Integer, the number of persons.

sigma

Either a matrix or a function that returns a matrix. This matrix is the variance-covariance matrix of the person parameters that is passed to MASS::mvrnorm(). Note that the order of the person parameters is taken from the section Processes in the model object (see irtree_model).

itempar

Either a list or a function that returns a list. The list has an element beta and an element alpha. Each of these is a matrix of item parameters. Note that the order of items (rows) is taken from the section Items and the order of processes (columns) is taken from the section Processes in the model (see irtree_model).

link

Character. Link function to use.

na_okay

Logical indicating whether variables with unobserved response categories are permitted. If FALSE, rejection sampling is used to ensure that all categories are observed.

engine

String specifying whether to use mirt, Mplus, or TAM for estimation.

verbose

Logical indicating whether output should be printed to the console.

control

List. The allowed elements of this list depend on the engine. Use control_mirt(), control_mplus(), or control_tam() for convenience. Note that the fit() function does not use ..., but that you can use the control_*() functions to pass additional arguments.

improper_okay

Logical indicating whether the model should also be fit if it is not a proper IR-tree model. Set this only to TRUE if you really know what you are doing.

par_type

Only used if the fit engine was mirt. Item parameters (or thresholds) can be either of type easiness (the mirt default) or difficulty (as in Mplus and TAM).

file

String giving the file path used to save the output if save_rdata = TRUE. Note that the file ending is automatically set to .rda. This argument is also passed to irtree_fit_mplus() if applicable.

dir

Path name that is used to save the results of every run if save_rdata = TRUE.

save_rdata

Logical indicating whether to save the results to an RData file.

reduce_output

Logical indicating whether the returned object should be reduced (i.e., the output of fit() is removed and only summary information is retained).

Value

List with two elements. The second element spec contains various arguments (such as the data). The first element fits is a list with one element for each fit_model that contains the output of fit() as well as the elements glanced, tidied, and augmented (see glance(), tidy(), and augment()).

See Also

irtree_sim(), and the wrapped functions fit() and irtree_gen_data().


hplieninger/ItemResponseTrees documentation built on Nov. 13, 2020, 12:17 p.m.