1
$\begingroup$

Here's a model I'm currently analysing with the package piecewiseSEM:

marsh_reduced_SEM2 = list(
# Plant variables
canopy_mfinal <- lme(log(Canopy) ~ Xomatter + Bulk_Density + fGrazing, random = ~ 1|Site, data = marsh.ok,
                     method = "REML", control = my_control),
# Soil variables
Xomatter_mfinal <- lme(log(Xomatter) ~ Percent_sand,  
                       random = ~ 1|Site/Creek, data = marsh.ok, method = "REML", control = my_control),
shear_mfinal <- lm(log(Shear_B) ~ Xomatter + Bulk_Density + fGrazing, data = marsh.ok),
bulk_mfinal <- lm(Bulk_Density ~ Xomatter + Percent_sand + fGrazing, data = marsh.ok),
# Erosion
erosiontot_final <- lme(log(X.Total_loss_min) ~ Xomatter + Shear_B, random = ~ 1|Site, data = marsh.ok, 
                        method = "REML", control = my_control)

)

"fGrazing" is a categorical variable with 2 levels. The rest of predictors and response variables are continuous.

I have managed to get the unstandardised coefficients doing:

sem.coefs(marsh_reduced_SEM2, data = marsh.ok, standardize = "none")

But I can't get the standardised coefficients:

sem.coefs(marsh_reduced_SEM2, data = marsh.ok, standardize = "scale")

Because it gives the following error:

Error in [.data.frame(newdata, , transform.vars2[i]) : undefined columns selected

Any ideas about what might be happening here?

Many thanks!

$\endgroup$

1 Answer 1

2
$\begingroup$

I had the same problem. It seems that the function "sem.coefs" can't deal with variables that are transformed directly in the model list. Try to transform them first. For example:

marsh.ok$Canopy.log=log(marsh.ok$Canopy)

If you do this for all the variables that need transformation it should work.

I hope this helps. Vesna

$\endgroup$
1
  • $\begingroup$ It worked! Thanks a lot! Yes, I ran the code for the function sem.coefs() line by line, and the problem is clearly that at some point, the code needs the column names and if the variable is transformed directly in the model list, the function cannot find that column name and it produces the error. Thanks again. $\endgroup$ Apr 24, 2017 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.