Dear R experts,
I built a linear mixed effect model with two independent regressors (x1,x2) and one repeated regressor (z) and tried to use step function to select a better model. Here is my code:
data=data.frame(x1=c(1,2,6,8,1,6,1,2,3),x2=c(3,2,8,1,1,1,1,7,8),y=c(1,0,0,1,1,0,1,0,1),z=c(1,1,1,2,2,3,3,3,4))
full.model=glmer(data=data,y~x1+x2+(1|z),family = binomial(link='logit'))
null.model=glmer(data=data,y~1+(1|z),family = binomial(link='logit'))
step(null.model , scope = list(lower=null.model,upper=full.model), direction='both', data = data, trace=0, test="Chisq", steps=10)
I encountered the following error
Error in $<-
(*tmp*
, formula, value = Terms) :
no method for assigning subsets of this S4 class
Cannot find any helpful information on the internet so far. Could you please help me out? Thanks.
Best,
Veda