[R] problem with predict.gam in package gam
Drew Tyre
atyre2 at unl.edu
Thu Sep 15 01:06:57 CEST 2011
I am trying to reproduce plots in Chapter 3 of Zuur et al Mixed
Effects models and extensions in Ecology. For pedagogical reasons,
they make a series of plots with gam(...) in package gam. I encounter
errors that trace back to the predict.gam method. Below is a
repeatable example using one of the example datasets:
library(gam)
data(kyphosis)
test = gam(Kyphosis ~ s(Age,4) + Number, family = binomial, data=kyphosis)
predict(test) # works
predict(test,se.fit=TRUE) # fails
#Error in dim(data) <- dim : attempt to set an attribute on NULL
# after debugging, it wants a model frame ...
test = gam(Kyphosis ~ s(Age,4) + Number, family = binomial,
data=kyphosis, model=TRUE)
predict(test,se.fit=TRUE) # fails, but with a different error
# Error in terms.default(object, data = data) :
# no terms component nor attribute
I am using R 2.13.1 on a PC inside RStudio.
I realize I can do this in package mgcv, but just curious as to
whether this is something known and fixable?
Thanks
--
Drew Tyre
School of Natural Resources
University of Nebraska-Lincoln
416 Hardin Hall, East Campus
3310 Holdrege Street
Lincoln, NE 68583-0974
phone: +1 402 472 4054
fax: +1 402 472 2946
email: atyre2 at unl.edu
http://snr.unl.edu/tyre
http://aminpractice.blogspot.com
http://www.flickr.com/photos/atiretoo
More information about the R-help
mailing list