Learn R Programming

TAM (version 1.6-0)

tamaanify: 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.

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:
  • tammodelModel input for TAM
  • tammodel.dfrProcessed tammodel input
  • ANALYSISSyntax specified in ANALYSIS
  • ANALYSIS.listParsed specifications in ANALYSIS
  • LAVAANMODELSyntax specified in LAVAAN MODEL
  • lavpartableParameter table processed by the syntax in LAVAAN MODEL
  • itemsInformations about items: Number of categories, specified item response function
  • maxcatMaximum number of categories
  • ITEMTYPESyntax specified in ITEM TYPE
  • MODELCONSTRAINTSyntax specified in MODEL CONSTRAINT
  • MODELCONSTRAINT.dfrProcessed syntax in MODEL CONSTRAINT
  • modelconstraint.threshProcessed data frame for model constraint of thresholds
  • modelconstraint.loadingProcessed data frame for loadings
  • respData set for usage
  • methodUsed TAM function
  • ADesign matrix A
  • QDesign matrix for loadings
  • B.fixedMatrix with fixed item loadings (used for tam.mml.2pl)
  • LProcessed design matrix for loadings when there are model constraints for loadings
  • variance.fixedMatrix for specification of fixed values in covariance matrix
  • est.varianceLogical indicating whether variance should be estimated (tam.mml.2pl)
  • theta.kTheta design matrix
  • EDesign matrix E
  • notALogical indicating whether $A$ matrix is defined
  • gammaslope.fixedFixed gammaslope parameters
  • gammaslope.priorPrior distributions for gammaslope parameters
  • xsi.fixedFixed $\xi$ parameter
  • xsi.priorPrior distributions for $\xi$ parameters

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). TO BE IMPLEMENTED: (ordered) latent class models for multiple dimensions, cognitive diagnostic models LAVAAN MODEL: For specification of the syntax, see lavaanify.IRT. MODEL CONSTRAINTS: Linear constraints can be specified by using conventional specification in Rsyntax. 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. TO BE IMPLEMENTED: beta item response model, nominal item response model, smoothed nominal item response model, nonparametric B-spline item response functions, cognitive diagnostic models, latent class approximation of factor models 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 ~.

References

Bartolucci, F. (2007). A class of multidimensional IRT models for testing unidimensionality and clustering items. Psychometrika, 72, 141-157. Formann, A. K. (1989). Constrained latent class models: Some further applications. British Journal of Mathematical and Statistical Psychology, 42, 37-54. 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. 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 Reponse 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. http://www.rd.dnc.ac.jp/~shojima/ntt/paper.htm. von Davier, M. (2007). Mixture distribution diagnostic models. ETS Research Report ETS RR-07-32. Princeton, ETS.

See Also

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

Examples

Run this code
#############################################################################
# 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 <- 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 <- 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 <- tamaanify( tammodel , resp=dat)
mod1$A          # design matrix A for intercepts
mod1$L[,1,]     # design matrix L for loadings

#############################################################################
# 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 <- 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
# go 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 <- tamaanify( tammodel , dat )
res$MODELCONSTRAINT.dfr 
res$modelconstraint.loading

Run the code above in your browser using DataLab