I am looking for help with the use of categorical binary predictor variables in the piecewiseSEM package in R.
I am inspecting the effect of two categorical variables on one continuous response variable with piecewiseSEM and I am running into some problems.
My model explains the effect of vegetation height and grazer presence on bird chick weight, with clutch ID as a random factor. The response variable, chick weight, is a continuous variable, and the predictor variables vegetation height and grazer presence are both coded as binary factors (0 and 1 for absence and presence of high vegetation/grazers respectively). Clutch ID is a factor variable with 37 levels.
The interaction is modeled as shown below:
data <- read.delim("question_data.txt")
data$grazers <- factor(data$grazers, levels=c(0,1), labels=c("0","1"))
data$FLH <- factor(data$FLH, levels=c(0,1), labels=c("0","1"))
# weight = chick weights
# grazers = grazers present/absent
# FLH = high vegetation present/absent
# clutch = clutch that chicks originate from
library(nlme)
M <- lme(weight ~ grazers + FLH, random=~1|clutch, data=data)
To obtain standardized coefficients I use the piecewiseSEM package, shown below with output included.
library(piecewiseSEM)
coefs(M, standardize="scale")
#Output:
# Response Predictor Estimate Std.Error DF Crit.Value P.Value Std.Estimate
#1 weight grazers1 0.7318 1.5211 44 0.4811 0.6328 0.1152
#2 weight FLH1 -0.0710 1.5612 44 -0.0455 0.9639 -0.0108
#Warning messages:
#1: In var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :
#Calling var(x) on a factor x is deprecated and will become an error.
#Use something like 'all(duplicated(x)[-1L])' to test for a constant vector.
#2: In var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :
#Calling var(x) on a factor x is deprecated and will become an error.
#Use something like 'all(duplicated(x)[-1L])' to test for a constant vector.
Running the code gives coefficients to interpret, but the error messages seem to indicate that the output is not reliable or that the two binary predictor variables are not suitable for the model. I'd like to ask for clarification on two questions:
1) Is it possible to use categorical binary predictor variables usable in piecewise SEM?
2) If the answer to 1) is yes, how should I interpret the standardized coefficients when in the output they correspond to only one level of the factor?
Thank you in advance!