2

I'm trying to solve an exercise from Pinheiro and Bates book (Mixed-Effects Models in S and S-PLUS) using R. It uses data Pixel from nlme package.

The exercise says: Use lmList to fit a separate quadratic model in day for each Dog. Plot the individual confidence intervals for the coefficients in the lmList fit. Verify that only the intercept and the linear coefficient seem to vary significantly with Dog.

I fitted the model like this:

fm2Pixel.lis<-lmList(pixel~day+I(day^2)|Dog, Pixel)

But when I try to plot confidence intervals using this function:

plot(intervals(fm2Pixel.lis))

R gives mi this error:

Error in `[<-`(`*tmp*`, use, use, ii, value = lst[[ii]]) : 
  subscript out of bounds

Does enyone know how to fix whatever is wrong?

Marija T.
  • 53
  • 7
  • 1
    I actually consider this a bug in `nlme::lmList` (I think it should be able to handle this edge case). I've [written to r-devel@r-project.org](https://stat.ethz.ch/pipermail/r-devel/2015-September/071779.html) raising the issue ... – Ben Bolker Sep 20 '15 at 18:57
  • FWIW this gives a different set of warning/error messages: `summary(fm2Pixel.lis2 – Ben Bolker Sep 20 '15 at 18:58

1 Answers1

1

There are only two observations with Dog == 9. This results in an NA for the estimate of the quadratic parameter and intervals can't handle that. If you exclude this subset it works:

fm2Pixel.lis <- lmList(pixel ~ poly(day, 2, raw = TRUE) | Dog,
                       Pixel[Pixel$Dog != 9,])
plot(intervals(fm2Pixel.lis))
Roland
  • 117,893
  • 9
  • 163
  • 255
  • Thank you for your answer @Ronald. Are those missing values also the reason why R doesn't let me use `summary` function on the model or is my model wrong? – Marija T. Sep 20 '15 at 16:28
  • @vozpre: yes (and they are missing correctly: the parameter is not estimable) – Martin Mächler Oct 05 '15 at 07:06