yrosseel / lavaan

an R package for structural equation modeling and more
http://lavaan.org
412 stars 99 forks source link

second-order latent factor with sam() #281

Closed albertostefanelli closed 11 months ago

albertostefanelli commented 1 year ago

Second-order latent factors cannot be estimated with sam(). This should be added to the documentation or implemented if possibile.

model <- ' 
  # latent variable definitions
     ind60 =~ x1 + x2 + x3
     dem60 =~ y1 + a*y2 + b*y3 + c*y4
     dem65 =~ y5 + a*y6 + b*y7 + c*y8
     dem2o =~ dem60 + dem65

'

fit.sam <- sam(model, data = PoliticalDemocracy)
Error in sam(model, data = PoliticalDemocracy) : 
  lavaan ERROR: model contains indicators that are also latent variables:
    dem60 dem65
yrosseel commented 11 months ago

I now added this explicitly in the 'details' section of the man page of sam(). Implementation is not trivial, but is on my TODO list.