My mixed model is as follows:
model <- lme(Cost~1+Units, random=~1+Units|Factory, method="ML", data=A)
I was told to apply the code below to plot residuals versus fitted values and it worked:
plot(fitted(model), resid(model))
However, it showed me an error message when I tried to plot residuals versus Units, the predictor variable.
> plot(Units(model), resid(model))
Error: could not find function "Units"
Error in plot(Units(model), resid(model)) :
error in evaluating the argument 'x' in selecting a method for function 'plot'
What should I do to fix this problem? Thanks.