clcm: Fit CLCM

View source: R/Estimate_clcm.R

clcmR Documentation

Fit CLCM

Description

Estimate confirmatory latent class model

Usage

clcm(
  dat,
  item.type = NULL,
  item.names = NULL,
  Q = NULL,
  lc.con = NULL,
  lat.reg = NULL,
  sv = NULL,
  post.true = NULL,
  initial.lprior = NULL,
  initial.post = NULL,
  max.diff = 1e-04,
  max.it = 1000,
  verbose = T
)

Arguments

dat

data frame containing item responses. If the data contains more than one timepoint, it must be specified by a variable named Time, a factor of two levels. Data should be in long format, that is, similar format to that used by the nlme/lme4/glmmTMB R packages

item.type

character vector specifying the type of item to be modeled. The item type options are as follows:

  • Ordinal - Ordinal model, 1 slope parameter, C-1 intercept parameters, where C is the number of categories. The slope parameter distinguishes the latent classes.

  • Nominal - Nominal or Multinomial model, 2*(C-1) parameters. The slope parameters distinguish the latent classes.

  • Poisson - Poisson model, 2 parameters. The model is paramterized using lambda. See ?rpois for details. The lambda parameter is stratified on the latent classes. The slope parameter distinguishes the latent classes.

  • Neg_Binom - Negative Binomial model, 3 parameters. The model is parameterized using mu and size. See ?rnbinom for details on parameters. The mu parameter is stratified on the latent classes; the size parameter is common to all latent classes. The slope parameter distinguishes the latent classes.

  • ZINB - Zero-Inflated Negative Binomial model, 4 parameters. The model is parameterized as mu, size, and zi (zero inflation parameter). The mu parameter is stratified on the latent classes; the size and zi parameters are common to all latent classes. The slope parameter distinguishes the latent classes.

  • ZIP- Zero-Inflated Poisson model, 3 parameters. The model is parameterized using lambda and zi (zero inflation parameter). The lambda parameter is stratified on latent classes. The zi parameter is common to all latent classes. The slope parameter distinguishes the latent classes.

  • Normal - Normal distribution model, 2 parameters. The model is parameterized using a mean and variance The mean is stratified on latent classes. The variance is common to all latent classes (pooled across latent classes) The slope parameter distinguishes the latent classes.

  • Beta - Beta distribution model, 3 parameters. Support ranges from 0 to 1. The model is parameterized using shape1 and shape2 paramters. See ?rbeta for details The shape1 parameter is stratified on latent classes The shape 2 parameter is common to all latent classes The slope parameter distinguishes the latent classes.

item.names

specify the item names; the dataframe column names containing item responses

Q

optional pass the Q-matrix, default is K=1, two latent classes. This is a confirmatory latent class model, hence the need for the specifcation. Note that only dichotomous attributes (factors) are supported. Only the conjunctive condensation rule is supported. All condensation rules are equivalent for items that evaluate a single attriute (factor).

lc.con

optional list of constraints on each latent class at each timepoint, where NA constrains that latent class to zero at that timepoint. For example, constraint latent class one (out of two) to be zero at timepoint 1: lc.con = list('Time_1' = c(NA, 1), 'Time_2' = c(1, 1)). Note that the dat dataframe passed must contain the variable Time.

lat.reg

optional pass variables to regress latent class on For example, regress the latent classes at timepoint 2 onto the Group variable: lat.reg = list('Time_1' = NULL, 'Time_2' = 'Group' ), where Time_1 and Time_2 are the discrete timepoints. Note that the dat dataframe passed must contain the variable Time.

sv

optional list of the starting values for item parameter estimation

initial.lprior

optional matrix of the initial log-prior distribution. This is important for the 2-stage estimation routine.

initial.post

optional matrix of the initial posterior distribution

max.diff

convergence tolerance of item param estimation; default is 1e-04

max.it

maximum number of iterations in EM estimation procedure; default is 1e3

verbose

logical; should the function print the estimation progress? Default is TRUE, recommend set to FALSE for simulations.

Value

Returns the estimated confirmatory latent class model

Examples

## Not run: 
set.seed(3112021)
sim.dat <- simulate_clcm(N=200,
                          number.timepoints = 1,
                          item.type = rep('Ordinal', 5),
                          categories.j = rep(4, 5),
                          lc.prop = list('Time_1' = c(0.5, 0.5)) )

mod <- clcm(dat = sim.dat$dat,
            item.type = sim.dat$item.type,
            item.names = sim.dat$item.names,
            Q = sim.dat$Q)

 
## End(Not run)

CJangelo/CLCM documentation built on May 22, 2022, 9:27 a.m.