I am getting an error message when using predict.gls when the package "MuMIn" is installed.
The following (Ex. 1) works:
### EX. 1
library(nlme)
# example code from https://stat.ethz.ch/R-manual/R-devel/library/nlme/html/predict.gls.html
fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
correlation = corAR1(form = ~ 1 | Mare))
newOvary <- data.frame(Time = c(-0.75, -0.5, 0, 0.5, 0.75))
predict(fm1, newOvary)
# [1] 9.441686 13.116003 11.316793 13.116003 14.991110
# attr(,"label")
# [1] "Predicted values"
However, the following (Ex. 2) yields an error message, even though the library(MuMIn) line is the only difference from Ex. 1:
### EX. 2
library(nlme)
library(MuMIn) # (This is the only thing different from Ex. 1)
# example code from https://stat.ethz.ch/R-manual/R-devel/library/nlme/html/predict.gls.html
fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
correlation = corAR1(form = ~ 1 | Mare))
newOvary <- data.frame(Time = c(-0.75, -0.5, 0, 0.5, 0.75))
predict(fm1, newOvary)
# Error in eval(predvars, data, env) : object 'follicles' not found
Does anyone know why this is the case? There seems to be an incompatibility when using 'predict' when MuMIn is installed
Interestingly, the following (Ex. 3), which calls predict.gls directly, restores it to working:
### EX. 3
library(nlme)
library(MuMIn)
# example code from https://stat.ethz.ch/R-manual/R-devel/library/nlme/html/predict.gls.html
fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
correlation = corAR1(form = ~ 1 | Mare))
newOvary <- data.frame(Time = c(-0.75, -0.5, 0, 0.5, 0.75))
nlme:::predict.gls(fm1, newOvary) # (This is the only thing different from Ex. 2)
# [1] 9.441686 13.116003 11.316793 13.116003 14.991110
# attr(,"label")
# [1] "Predicted values"
However, I have read that it is inadvisable to use 'nlme:::predict.gls' as the ':::' can be 'risky' because it accesses internal functions that aren't meant to be directly available.
Here is my current R.version output:
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 4.0
year 2017
month 04
day 21
svn rev 72570
language R
version.string R version 3.4.0 (2017-04-21)
nickname You Stupid Darkness
Incidentally, I didn't have this problem on my old computer, which used an older version of R. I had a friend try Ex. 2 on his computer, and it produced an error message too.
Any insight into the reason for the error message in Ex. 2, and how I can fix it without resorting to the workaround in Ex. 3, would be much appreciated!