Learn R Programming

sirt (version 1.0-3)

lavaanify.sirt: Slight Extension of the lavaan Syntax

Description

This functions slightly extends the lavaan syntax implemented in the lavaan package (see lavaanify). Guessing and slipping parameters can be specified by using the operators ?=g1 and ?=s1, respectively. The operator __ can be used for a convenient specification for groups of items. For example, I1__I5 refers to items I1,...,I5.

Usage

lavaanify.sirt(lavmodel, items=NULL, data=NULL)

Arguments

lavmodel
A model in lavaan syntax plus the additional operators ?=g1 and ?=s1.
items
Optional vector of item names
data
Optional data frame with item responses

Value

  • A list with following entries
  • lavpartableA lavaan parameter table
  • lavaan.syntaxProcessed syntax for lavaan package

See Also

lavaanify (lavaan) See lavaan2mirt for estimating models in the mirt package using lavaan syntax.

Examples

Run this code
#############################################################################
# EXAMPLE 1: lavaan syntax with guessing and slipping parameters
#############################################################################

# define model in lavaan
lavmodel <- "F =~ A1+c*A2+A3+A4
    # define slipping parameters for A1 and A2
    A1 + A2 ?= s1
    # joint guessing parameter for A1 and A2
    A1+A2 ?= c1*g1
    A3 | 0.75*t1
    # fix guessing parameter to .25 and 
    # slipping parameter to .01 for item A3
    A3 ?= .25*g1+.01*s1
    A4 ?= c2*g1
    A1 | a*t1
    A2 | b*t1
      "

# process lavaan syntax
lavpartable <- lavaanify.sirt(lavmodel)$lavpartable
  ##     id lhs op rhs user group free ustart exo label eq.id unco
  ##  1   1   F =~  A1    1     1    1     NA   0           0    1
  ##  2   2   F =~  A2    1     1    2     NA   0     c     0    2
  ##  3   3   F =~  A3    1     1    3     NA   0           0    3
  ##  4   4   F =~  A4    1     1    4     NA   0           0    4
  ##  5   5  A3  |  t1    1     1    0   0.75   0           0    0
  ##  6   6  A1  |  t1    1     1    5     NA   0     a     0    5
  ##  7   7  A2  |  t1    1     1    6     NA   0     b     0    6
  ##  8   8  A1 ?=  s1    1     1    7     NA   0           0    7
  ##  9   9  A2 ?=  s1    1     1    8     NA   0           0    8
  ##  10 10  A1 ?=  g1    1     1    9     NA   0    c1     1    9
  ##  11 11  A2 ?=  g1    1     1    9     NA   0    c1     1   10
  ##  12 12  A3 ?=  g1    1     1    0   0.25   0           0    0
  ##  13 13  A3 ?=  s1    1     1    0   0.01   0           0    0
  ##  14 14  A4 ?=  g1    1     1   10     NA   0    c2     0   11
    
#############################################################################
# EXAMPLE 2: Usage of "__" and "?=" operators
#############################################################################  

data(data.read)
dat <- data.read
items <- colnames(dat)

lavmodel <- "F1 =~ A1+A2+ A3+lam4*A4
   # item loadings for items B1 to B4
   F2 =~ B1__B4
   # equal loadings of items C1 to C4
   F3 =~ lam9*C1__C4
   # item intercepts
   B1__B2 | -0.5*t1
   B3__C1 | int6*t1
   # guessing parameters
   C1__C3 ?= g1
   C4 + B1__B3 ?= 0.2*g1
   # slipping parameters
   A1__B1 + B3__C2 ?= slip1*s1
   # residual variances
   B1__B3 ~~ errB*B1__B3 
    " 
lav2 <- lavaanify.sirt( lavmodel , data=dat)

Run the code above in your browser using DataLab