Learn R Programming

dcmstan (version 0.1.0)

stan_code: Generate 'Stan' code for a diagnostic classification models

Description

Given a specification for a diagnostic classification model or a generated quantities definition, automatically generate the 'Stan' code necessary to estimate the model. For details on how the code blocks relate to diagnostic models, see da Silva et al. (2017), Jiang and Carter (2019), and Thompson (2019).

Usage

stan_code(x, ...)

Value

A glue object containing the 'Stan' code for the specified model.

Arguments

x

A model specification or generated quantities object.

...

Additional arguments passed to methods.

References

da Silva, M. A., de Oliveira, E. S. B., von Davier, A. A., and Bazán, J. L. (2017). Estimating the DINA model parameters using the No-U-Turn sampler. Biometrical Journal, 60(2), 352-368. tools:::Rd_expr_doi("10.1002/bimj.201600225")

Jiang, Z., & Carter, R. (2019). Using Hamiltonian Monte Carlo to estimate the log-linear cognitive diagnosis model via Stan. Behavior Research Methods, 51, 651-662. tools:::Rd_expr_doi("10.3758/s13428-018-1069-9")

Thompson, W. J. (2019). Bayesian psychometrics for diagnostic assessments: A proof of concept (Research Report No. 19-01). University of Kansas; Accessible Teaching, Learning, and Assessment Systems. tools:::Rd_expr_doi("10.35542/osf.io/jzqs8")

Examples

Run this code
qmatrix <- data.frame(
  att1 = sample(0:1, size = 5, replace = TRUE),
  att2 = sample(0:1, size = 5, replace = TRUE)
)

model_spec <- dcm_specify(qmatrix = qmatrix,
                          measurement_model = lcdm(),
                          structural_model = unconstrained())

stan_code(model_spec)

Run the code above in your browser using DataLab