tamaanify: Function for Parsing 'TAM' Input

View source: R/tamaanify.R

tamaanifyR Documentation

Function for Parsing TAM Input

Description

This function parses a so called tammodel which is a string used for model estimation in TAM. The function is based on the lavaan syntax and operates at the extension lavaanify.IRT.

Usage

tamaanify(tammodel, resp, tam.method=NULL, doparse=TRUE )

Arguments

tammodel

String for model definition following the rules described in Details and in Examples.

resp

Item response dataset

tam.method

One of the TAM methods tam.mml, tam.mml.2pl or tam.mml.3pl.

doparse

Optional logical indicating whether lavmodel should be parsed for DO statements.

Details

The model syntax tammodel consists of several sections. Some of them are optional.

ANALYSIS:
Possible model types are unidimensional and multidimensional item response models (TYPE="TRAIT"), latent class models ("LCA"), located latent class models ("LOCLCA"; e.g. Formann, 1989; Bartolucci, 2007), ordered latent class models ("OLCA"; only works for dichotomous item responses; e.g. Hoijtink, 1997; Shojima, 2007) and mixture distribution models ("MIXTURE"; e.g. von Davier, 2007).

LAVAAN MODEL:
For specification of the syntax, see lavaanify.IRT.

MODEL CONSTRAINT:
Linear constraints can be specified by using conventional specification in R syntax. All terms must be combined with the + operator. Equality constraints are set by using the == operator as in lavaan.

ITEM TYPE:
The following item types can be defined: Rasch model (Rasch), the 2PL model (2PL), partial credit model (PCM) and the generalized partial credit model (GPCM).

The item intercepts can also be smoothed for the PCM and the GPCM by using a Fourier basis proposed by Thissen, Cai and Bock (2010). For an item with a maximum of score of K, a smoothed partial credit model is requested by PCM(kk) where kk is an integer between 1 and K. With kk=1, only a linear function is used. The subsequent integers correspond to Fourier functions with decreasing periods. See Example 2, Model 7 of the tamaan function.

PRIOR:
Possible prior distributions: Normal distribution N(mu,sd), truncated normal distribution TN(mu,sd,low,upp) and Beta distribution Beta(a,b). Parameter labels and prior specification must be separated by ~.

Value

A list with following (optional) entries which are used as input in one of the TAM functions tam.mml, tam.mml.2pl or tam.mml.3pl:

tammodel

Model input for TAM

tammodel.dfr

Processed tammodel input

ANALYSIS

Syntax specified in ANALYSIS

ANALYSIS.list

Parsed specifications in ANALYSIS

LAVAANMODEL

Syntax specified in LAVAAN MODEL

lavpartable

Parameter table processed by the syntax in LAVAAN MODEL

items

Informations about items: Number of categories, specified item response function

maxcat

Maximum number of categories

ITEMTYPE

Syntax specified in ITEM TYPE

MODELCONSTRAINT

Syntax specified in MODEL CONSTRAINT

MODELCONSTRAINT.dfr

Processed syntax in MODEL CONSTRAINT

modelconstraint.thresh

Processed data frame for model constraint of thresholds

modelconstraint.loading

Processed data frame for loadings

resp

Data set for usage

method

Used TAM function

A

Design matrix A

Q

Design matrix for loadings

Q.fixed

Fixed values in Q matrix

B.fixed

Matrix with fixed item loadings (used for tam.mml.2pl)

L

Processed design matrix for loadings when there are model constraints for loadings

variance.fixed

Matrix for specification of fixed values in covariance matrix

est.variance

Logical indicating whether variance should be estimated (tam.mml.2pl)

theta.k

Theta design matrix

E

Design matrix E

notA

Logical indicating whether A matrix is defined

gammaslope.fixed

Fixed gammaslope parameters

gammaslope.prior

Prior distributions for gammaslope parameters

xsi.fixed

Fixed \xi parameter

xsi.prior

Prior distributions for \xi parameters

References

Bartolucci, F. (2007). A class of multidimensional IRT models for testing unidimensionality and clustering items. Psychometrika, 72, 141-157. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s11336-005-1376-9")}

Formann, A. K. (1989). Constrained latent class models: Some further applications. British Journal of Mathematical and Statistical Psychology, 42, 37-54. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/j.2044-8317.1989.tb01113.x")}

Hojtink, H., & Molenaar, I. W. (1997). A multidimensional item response model: Constrained latent class analysis using the Gibbs sampler and posterior predictive checks. Psychometrika, 62(2), 171-189. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/BF02295273")}

Thissen, D., Cai, L., & Bock, R. D. (2010). The nominal categories item response model. In M. L. Nering & Ostini, R. (Eds.). Handbook of Polytomous Item Response Models (pp. 43-75). New York: Routledge.

Shojima, K. (2007). Latent rank theory: Estimation of item reference profile by marginal maximum likelihood method with EM algorithm. DNC Research Note 07-12.

von Davier, M. (2007). Mixture distribution diagnostic models. ETS Research Report ETS RR-07-32. Princeton, ETS. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/j.2333-8504.2007.tb02074.x")}

See Also

See tamaan for more examples. Other examples are included in tam.mml and tam.mml.3pl.

lavaanify.IRT

Examples

## Not run: 

#############################################################################
# EXAMPLE 1: Examples dichotomous data data.read
#############################################################################

library(sirt)
data(data.read,package="sirt")
dat <- data.read

#*********************************************************************
#*** Model 1: 2PL estimation with some fixed parameters and
#             equality constraints
tammodel <- "
LAVAAN MODEL:
  F2=~ C1__C2 + 1.3*C3 + C4
  F1=~ A1__B1
  # fixed loading of 1.4 for item B2
  F1=~ 1.4*B2
  F1=~ B3
  F1 ~~ F1
  F2 ~~ F2
  F1 ~~ F2
  B1 | 1.23*t1 ; A3 | 0.679*t1
  A2 | a*t1 ; C2 | a*t1 ; C4 | a*t1
  C3 | x1*t1 ; C1 | x1*t1
ITEM TYPE:
  A1__A3 (Rasch) ;
  A4 (2PL) ;
  B1__C4 (Rasch) ;
    "
# process model
out <- TAM::tamaanify( tammodel, resp=dat)
# inspect some output
out$method          # used TAM function
out$lavpartable     # lavaan parameter table

#*********************************************************************
#*** Model 2: Latent class analysis with three classes
tammodel <- "
ANALYSIS:
  TYPE=LCA;
  NCLASSES(3);   # 3 classes
  NSTARTS(5,20); # 5 random starts with 20 iterations
LAVAAN MODEL:
  F=~ A1__C4
    "
# process syntax
out <- TAM::tamaanify( tammodel, resp=dat)
str(out$E)     # E design matrix for estimation with tam.mml.3pl function

#*********************************************************************
#*** Model 3: Linear constraints for item intercepts and item loadings
tammodel <- "
LAVAAN MODEL:
  F=~ lam1__lam10*A1__C2
  F ~~ F
  A1 | a1*t1
  A2 | a2*t1
  A3 | a3*t1
  A4 | a4*t1
  B1 | b1*t1
  B2 | b2*t1
  B3 | b3*t1
  C1 | t1
MODEL CONSTRAINT:
  # defined parameters
  # only linear combinations are permitted
  b2==1.3*b1 + (-0.6)*b3
  a1==q1
  a2==q2 + t
  a3==q1 + 2*t
  a4==q2 + 3*t
  # linear constraints for loadings
  lam2==1.1*lam1
  lam3==0.9*lam1 + (-.1)*lam0
  lam8==lam0
  lam9==lam0
    "
# parse syntax
mod1 <- TAM::tamaanify( tammodel, resp=dat)
mod1$A          # design matrix A for intercepts
mod1$L[,1,]     # design matrix L for loadings

## End(Not run)

#############################################################################
# EXAMPLE 2: Examples polytomous data data.Students
#############################################################################

library(CDM)
data( data.Students, package="CDM")
dat <- data.Students[,3:13]

#*********************************************************************
#*** Model 1: Two-dimensional generalized partial credit model
tammodel <- "
LAVAAN MODEL:
  FA=~ act1__act5
  FS=~ sc1__sc4
  FA ~~ 1*FA
  FS ~~ 1*FS
  FA ~~ FS
  act1__act3 | t1
  sc2 | t2
    "
out <- TAM::tamaanify( tammodel, resp=dat)
out$A    # design matrix for item intercepts
out$Q    # loading matrix for items

#*********************************************************************
#*** Model 2: Linear constraints

# In the following syntax, linear equations for multiple constraints
# are arranged over multiple lines.
tammodel <- "
  LAVAAN MODEL:
    F=~ a1__a5*act1__act5
    F ~~ F
  MODEL CONSTRAINT:
      a1==delta +
                tau1
      a2==delta
      a3==delta + z1
      a4==1.1*delta +
              2*tau1
                + (-0.2)*z1
  "
# tamaanify model
res <- TAM::tamaanify( tammodel, dat )
res$MODELCONSTRAINT.dfr
res$modelconstraint.loading

TAM documentation built on May 29, 2024, 2:20 a.m.