Skip to contents

Create the specifications for a Bayesian diagnostic classification model. Choose the measurement and structural models that match your assumptions of your data. Then choose your prior distributions, or use the defaults. The model specification can then be used to generate the 'Stan' code needed to estimate the model.

Usage

dcm_specify(
  qmatrix,
  identifier = NULL,
  measurement_model = lcdm(),
  structural_model = unconstrained(),
  priors = NULL
)

Arguments

qmatrix

The Q-matrix. A data frame with 1 row per item and 1 column per attribute. May optionally include an additional column of item identifiers. If an identifier column is included, this should be specified with identifier. All cells for the remaining attribute columns should be either 0 (item does not measure the attribute) or 1 (item does measure the attribute).

identifier

Optional. If present, the quoted name of the column in the qmatrix that contains item identifiers.

measurement_model

A measurement model object.

structural_model

A structural model object.

priors

A prior object created by prior(). If NULL (the default), default prior distributions defined by default_dcm_priors() are used.

Value

A dcm_specification object.

Examples

qmatrix <- data.frame(
  att1 = sample(0:1, size = 15, replace = TRUE),
  att2 = sample(0:1, size = 15, replace = TRUE),
  att3 = sample(0:1, size = 15, replace = TRUE),
  att4 = sample(0:1, size = 15, replace = TRUE)
)

dcm_specify(qmatrix = qmatrix,
            measurement_model = lcdm(),
            structural_model = unconstrained())
#> A loglinear cognitive diagnostic model (LCDM) measuring 4 attributes with
#> 15 items.
#> 
#>  Attributes:
#>  "att1" (8 items)
#>  "att2" (8 items)
#>  "att3" (10 items)
#>  "att4" (5 items)
#> 
#>  Attribute structure:
#>   Unconstrained
#> 
#>  Prior distributions:
#>   intercept ~ normal(0, 2)
#>   maineffect ~ lognormal(0, 1)
#>   interaction ~ normal(0, 2)
#>   `Vc` ~ dirichlet(1, 1, 1, 1)