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
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!
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.
I have 17 sites that have multiple observations at each (less than 6 observations though)
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?