# Simulating Ordinal Data

50 views

### Ilker Soyturk

Jan 29, 2020, 4:29:10 PM1/29/20
to lavaan
Can anyone provide syntax for data simulation for ordinal (likert-scale) data? I have standardized path coefficient for a model and I want to generate a simulated data for educational purposes. I do not know if it has been answered anywhere but any help will be appreciated
Thanks!.

### Nickname

Jan 30, 2020, 10:10:09 AM1/30/20
to lavaan
Ilker,
Here is a simple CFA example.

`# Simulate ordinal datarequire(lavaan)# see ?model.syntax for detailssimModel <- '  factor =~ .8*item1 + .8*item2 + .8*item3 + .8*item4 # factor loadings  item1 | -1*t1 + -.5*t2 + 0*t3 + .5*t4 + 1*t5 # thresholds  item2 | -1*t1 + -.5*t2 + 0*t3 + .5*t4 + 1*t5  item3 | -1*t1 + -.5*t2 + 0*t3 + .5*t4 + 1*t5  item4 | -1*t1 + -.5*t2 + 0*t3 + .5*t4 + 1*t5  factor ~ 0*1 # zero intercepts (not required)  item1 ~ 0*1  item2 ~ 0*1  item3 ~ 0*1  item4 ~ 0*1  factor ~~ 1*factor # variances  item1 ~~ 1*item1  item2 ~~ 1*item2  item3 ~~ 1*item3  item4 ~~ 1*item4' # end simModellavaanify(simModel)ordinalData <- simulateData(simModel, sample.nobs=1000)head(ordinalData, 10)summary(ordinalData)fitModel <- '  factor =~ item1 + item2 + item3 + item4  item1 | t1 + t2 + t3 + t4 + t5  item2 | t1 + t2 + t3 + t4 + t5  item3 | t1 + t2 + t3 + t4 + t5  item4 | t1 + t2 + t3 + t4 + t5  factor ~~ 1*factor  item1 ~~ item1  item2 ~~ item2  item3 ~~ item3  item4 ~~ item4' # end fitModel  lavaanify(fitModel)ordinalFit <- lavaan(model=fitModel, data=ordinalData)summary(ordinalFit) # note unique variances rescaled`

Keith
------------------------
Keith A. Markus
John Jay College of Criminal Justice, CUNY
http://jjcweb.jjay.cuny.edu/kmarkus
Frontiers of Test Validity Theory: Measurement, Causation and Meaning.
http://www.routledge.com/books/details/9781841692203/