two-level SEM

302 views
Skip to first unread message

hansdew...@hotmail.com

unread,
Jun 26, 2017, 6:50:00 AM6/26/17
to lavaan

Dear all,


I am trying to model a ‘two-level’ SEM with observations nested within Sites (6 different forests, with in every forest 27 to 43 observations). I try to model the interaction between trees, leaf litter quality, soil quality and earthworm components. I hereby hypothesise a positive feedback loop between the different components of our model.

I am only interested in the relation between my different components and answering my feedback loop hypothesis. As a consequence I am not interested in the differences between sites, but just like to ‘control’ for the clustering. I choose for a saturated model in the ‘between’ part of the model. The syntax is the following:


model <- '

level: 1 # within level

pH0_10       ~  Clay_num + humusNMDS1

WormB_McCune ~  pH0_10 + Soilvolume + litterPCA1 + litterPCA2  + FDis

humusNMDS1   ~  WormB_McCune + LAI + HLI + litterPCA1 + litterPCA2  + FDis

level: 2 # between level

# saturated

pH0_10       ~~  Clay_num + humusNMDS1 + Soilvolume + litterPCA1 + litterPCA2  + FDis + WormB_McCune + LAI + HLI

Clay_num     ~~  humusNMDS1 + Soilvolume + litterPCA1 + litterPCA2  + FDis + WormB_McCune + LAI + HLI

humusNMDS1   ~~  Soilvolume + litterPCA1 + litterPCA2  + FDis + WormB_McCune + LAI + HLI

Soilvolume   ~~  litterPCA1 + litterPCA2  + FDis + WormB_McCune + LAI + HLI

litterPCA1   ~~  litterPCA2  + FDis + WormB_McCune + LAI + HLI

litterPCA2   ~~  FDis + WormB_McCune + LAI + HLI

FDis         ~~  WormB_McCune + LAI + HLI

WormB_McCune ~~  LAI + HLI

LAI          ~~  HLI

'

fit_model <- sem(model, data = datahans, cluster = "Site_num", verbose = FALSE)

 

When this runs I get the following error:

Error in validObject(.Object) :

  invalid class “Fit” object: invalid object for slot "fx.group" in class "Fit": got class "NULL", should be or extend class "numeric"

 

Any advice to solve this would be helpful. Many Thanks!

 

Terrence Jorgensen

unread,
Jun 28, 2017, 6:42:11 AM6/28/17
to lavaan
Yves is still updating the experimental multilevel features before submitting it to CRAN.  Do you have the latest development version installed?  


If it still returns an error, perhaps share your sessionInfo() output and some data if possible, to help track down the problem.

Terrence D. Jorgensen
Postdoctoral Researcher, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

hansdew...@hotmail.com

unread,
Jun 29, 2017, 4:23:03 AM6/29/17
to lavaan
Dear Sir Jorgensen,

Thank you for your reply. 
Yes, we have the latest version installed, but it still returns an error.
We are now in contact with Yves Rosseel. As soon as we found a solution for our problem we will share it on this forum.


 


hansdew...@hotmail.com

unread,
Aug 4, 2017, 9:26:33 AM8/4/17
to lavaan

Dear all,


Thanks to Yves Rosseel, we found the main reason for the above mentioned warning.

We have too few clusters (only 6 sites) for an analysis whereby the clusters are considered as random component. For the same reason we were not able to properly model our data with the lavaan.survey package.


A possible solution would be to either model a multigroup SEM. Another option could be to model a fixed effect SEM with forest site as a compound variable (i.e. made up of five binary variable, 5 = n-1) or try to include latitude and longitude as continuous variables. Afterwards one need to check for spatial autocorrelation in the residuals to see if this was sufficient to remove the non-independence.

frev...@gmail.com

unread,
May 1, 2018, 10:44:57 PM5/1/18
to lavaan
Hello all,

Sorry to resurface this topic, but I am having similar complications with my analysis and would appreciate any input. 

I have 17 sites that have multiple observations at each (less than 6 observations though), when I use the growth() function I get the error as mentioned above. However, when I try to model a multigroup SEM using the group() command in sem(), I get the following error: 

Error in lav_samplestats_icov(COV = cov[[g]], ridge = ridge, x.idx = x.idx[[g]],  :  lavaan ERROR: sample covariance matrix is not positive-definite

I did not have this error before including the group() command in the code. Any thoughts for why this might be? Or any suggestions for how to control for repeated measurements at a site?

Thanks in advance for any help!

Code without group() that ran without warnings or errors:
avg.forb.fit<-sem(avg.forb.model,data=forb)

Code with group() that ran with error:
avg.forb.fit<-sem(avg.forb.model,group="site",data=forb)

Terrence Jorgensen

unread,
May 4, 2018, 7:00:36 AM5/4/18
to lavaan
I have 17 sites that have multiple observations at each (less than 6 observations though)

Yikes!

I did not have this error before including the group() command in the code. Any thoughts for why this might be?

Small Ns.  Possible, one of your variables is a constant within one of these groups.  Have you checked whether all of your variables vary within group?  (obviously, Level-2 variables would not vary within any Level-2 units, making them constants with 0 variance, hence the error)

aggregate(cbind(myFirstVariable, mySecondVariable, ...) ~ myGroupingVariable, data = forb, sd)


Or any suggestions for how to control for repeated measurements at a site?

You haven't much information about your model, but you seem to want to estimate a growth model, so you have T repeated occasions nested within approximately 6*17 cases nested within 17 sites?  Have you considered estimating the growth curve as s 3-level model using lme() or lmer()?  An N = T*6*17 would not be so bad of a Level-1 sample size, although the higher-level Ns would still be small enough to be wary of the variance-component estimates.
Reply all
Reply to author
Forward
0 new messages