murphymv / semEff

Automatic Calculation of Effects for Piecewise Structural Equation Models
https://murphymv.github.io/semEff/
GNU General Public License v3.0
10 stars 0 forks source link

BootEff in psem with interaction terms #54

Open AlexCarrascosa opened 4 months ago

AlexCarrascosa commented 4 months ago

Hello¡ I'm trying to use the BootEff() function in a psem model composed of lmer models with some interaction terms (code attached at the end). I always get this error:

Warning message: In (function (m, w) : 1001 model fit(s) or parameter estimation(s) failed. NAs reported/generated.

It seems that BootEff is not able to estimate these models. But, if I remove the interaction terms from the lmer models within the psem, it works perfectly. The problem is not related to random effects, because even with lm() models I get the same error when there are interaction terms.

_Prod_psem <- psem( lmer( Production ~ grass_proportion+ Treatment+Soil_fertility+Annual_Prep+ Treatment:Annual_Prep+ (1| Farm/Plot), data= Out_canopyprod),

_lmer( grass_proportion ~ Soil_fertility+Treatment+Mean_annual_Temp+ Annual_Prep+Treatment:Annual_Prep+ (1| Farm/Plot),data= Out_canopyprod) ,

_lmer(Soil_fertility ~ Treatment+ Mean_annual_Temp+(1| Farm), data= Out_canopy_prod), data = Out_canopyprod)

_Prod.sem.boot <- bootEff(Prodpsem, R = 1000, seed = 13, parallel = "snow", ran.eff = "Farm"))

Warning message: In (function (m, w) : 1001 model fit(s) or parameter estimation(s) failed. NAs reported/generated.

I've also run the bootEff() including catch.err = FALSE and this is the error reported:

Error in contr.sum(levels(i)) : not enough degrees of freedom to define contrasts

What goes wrong?

Thank you very much

murphymv commented 2 months ago

Hi Alex,

Without the data it's difficult to be certain what's going on. Is it possible to give the output of str(Out_canopy_prod)?

Regards, Mark