Hello,
I am trying to set up a hierarchical SEM using multiple factors that are dependent variables and also include a random effect. I think my current issue comes down to needing to use categorical variables that can't be ordered, and how to also incorporate a random effect. Does anyone have any tips or guidance for how to proceed?
Below is a description of my model and my code:
Description: I am interested in looking at how anthropocentric land use surrounding a site may influence the site's nutrient patterns, which in return may influence plant traits. I measured individual plant traits at several sites, but also measured site-level characteristics (see below). Because several plants were measured at a single site, site is repeated and should be used as a random effect.
My variables are:
- natural (factor for either low or high natural land use surrounding the site)
- impervious (factor for either low or high amounts of impervious surface surrounding the site)
- cv.precipitation (numeric variable for variation in precipitation at the site level)
- n_i (factor for whether the surveyed species was native or invasive)
- Multiple numeric nutrient measurements
- Multiple numeric trait measures
Model:
forb.model<-'
landuse=~natural+impervious+cv.precipitation
nutrients=~avg.po4+avg.n+po4.weekly.max+n.weekly.max+n_i
traits=~avg.height+avg.culms+avg.chloro+avg.sla
landuse~nutrients
nutrients~traits
'
forb.fit<-growth(cv.forb.model,data=forb, ordered=c("natural","impervious"))
summary(forb.fit, fit.measures=TRUE, standardized = TRUE)
When running the above code, I get the following error:
Warning messages:
1: In muthen1984(Data = X[[g]], ov.names = ov.names[[g]], ov.types = ov.types, :
lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix
2: In lav_samplestats_from_data(lavdata = lavdata, missing = lavoptions$missing, :
lavaan WARNING: 1 bivariate tables have empty cells; to see them, use:
lavInspect(fit, "zero.cell.tables")
3: In lavaan(cv.forb.model, data = forb, model.type = "growth", ordered = c("nat", :
lavaan WARNING: model has NOT converged!
Any tips and help would be extremely appreciated! I am new to R and really struggling my way through this code. I'd also be happy to provide any addition details and clarify anything.
Thanks