blatentSimulate {blatent}R Documentation

Simulates data using blatent syntax and simulated parameters input

Description

Simulates data from a model specified by blatent syntax and using a set of default parameter specifications.

Usage

blatentSimulate(
  modelText,
  nObs,
  defaultSimulatedParameters = setDefaultSimulatedParameters(),
  paramVals = NULL,
  seed = NULL,
  calculateInfo = FALSE
)

Arguments

modelText

A character string that contains the specifications for the model to be run. See blatentSyntax or more information about syntax formatting.

nObs

The number of observations to be simulated.

defaultSimulatedParameters

The specifications for the generation of the types of parameters in the simulation. Currently comprised of a list of unevaluated expressions (encapsulated in quotation marks; not calls for ease of user input) that will be evaluated by simulation function to generate parameters. Defaults to values generated by setDefaultSimulatedParameters. The list of unevaluated expressions must include:

  • observedIntercepts The data generating function for all intercepts for observed variables.

  • observedMainEffects The data generating function for the main effects for observed variables.

  • observedInteractions The data generating function for all interactions for observed variables.

  • latentIntercepts The data generating function for all intercepts for latent variables.

  • latentMainEffects The data generating function for the main effects for latent variables.

  • latentInteractions The data generating function for all interactions for latent variables.

paramVals

A named vector of parameter values which will be set rather than generated. A named vector of the length parameters of an analysis can be obtained by using createParameterVector. The NA values of this vector can be overwritten by values to be used in the simulation.

seed

The random number seed value used for setting the data. Defaults to NULL.

calculateInfo

A logical variable where TRUE indicates information statistics will be calculated (only when a single latent multivariate Bernoulli variable is in the model) and FALSE disables calculation.

References

Rupp, A. A., Templin, J., & Henson, R. A. (2010). Diagnostic Measurement: Theory, Methods, and Applications. New York: Guilford.

Examples


# Generating data using Q-matrix structure from data example in Chapter 9 of
#  Rupp, Templin, & Henson (2010).

RTHCh9ModelSyntax = "
   item1 ~ A1
   item2 ~ A2
   item3 ~ A3
   item4 ~ A1 + A2 + A1:A2
   item5 ~ A1 + A3 + A1:A3
   item6 ~ A2 + A3 + A2:A3
   item7 ~ A1 + A2 + A3 + A1:A2 + A1:A3 + A2:A3 + A1:A2:A3

   # Latent Variable Specifications:
 A1 A2 A3 <- latent(unit='rows',distribution='bernoulli',structure='univariate',type='ordinal')

   # Observed Variable Specifications:
   item1-item7 <- observed(distribution = 'bernoulli', link = 'probit')
"

simSpecs = setDefaultSimulatedParameters(
   observedIntercepts = "runif(n = 1, min = -1, max = -1)",
   observedMainEffects = "runif(n = 1, min = 2, max = 2)",
   observedInteractions = "runif(n = 1, min = 0, max = 0)",
   latentIntercepts = "runif(n = 1, min = 0, max = 0)",
   latentMainEffects  = "runif(n = 1, min = 0, max = 0)",
   latentInteractions = "runif(n = 1, min = 0, max = 0)"
 )

simulatedData = blatentSimulate(modelText = RTHCh9ModelSyntax, nObs = 1000,
                                defaultSimulatedParameters = simSpecs)

# setting values for specific parameters:
paramVals = createParameterVector(modelText = RTHCh9ModelSyntax)
paramVals["item1.(Intercept)"] = -2

# creating data
simulatedData2 = blatentSimulate(modelText = RTHCh9ModelSyntax, nObs = 1000,
                                 defaultSimulatedParameters = simSpecs, paramVals = paramVals)


[Package blatent version 0.1.2 Index]