Note: forwarded message attached.
__________________________________________________
--- Begin Message ---Subject: Re: [R] Prediction using GAM To: Prof Brian Ripley <[EMAIL PROTECTED]> In-Reply-To: 6667 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Length: 1068 The example I used is exactly in the R help file of predict.gam in the package 'gam'. You may reproduce this example by using the following code: library(gam) data(gam.data) data(gam.newdata) gam.object <- gam(y ~ s(x,6) + z, data=gam.data) predict(gam.object)[1] 1 0.8017407 predict(gam.object,data.frame(x=gam.data$x[1],z=gam.data$z[1])) 1 0.1668452 --- Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > R has *two* gam() functions in contributed packages > 'mgcv' and 'gam'. > Which is this? > > Please see the posting guide and provide a > reproducible example. > > If this is package 'gam', prediction difficulties of > this sort for the S > version are discussed in the White Book, MASS and > elsewhere (but I recall > reading that they did not apply to the R version). > > > On Wed, 23 Mar 2005, Kerry Bush wrote: > > > Recently I was using GAM and couldn't help > noticing > > the following incoherence in prediction: > > > >> data(gam.data) > >> data(gam.newdata) > > It is unusual to use data() on your own objects, but > we cannot reproduce > what you did without data. > > >> gam.object <- gam(y ~ s(x,6) + z, data=gam.data) > >> predict(gam.object)[1] > > 1 > > 0.8017407 > >> > > > predict(gam.object,data.frame(x=gam.data$x[1],z=gam.data$z[1])) > > 1 > > 0.1668452 > > > > I would expect that using two types of predict > > arguments should give me the same results. > > When I used this to predict a new data set then it > > seems OK: > > > >> > > > predict(gam.object,data.frame(x=gam.newdata$x[1],z=gam.newdata$z[1])) > > 1 > > 0.4832136 > >> predict(gam.object,gam.newdata)[1] > > 1 > > 0.4832136 > > > > Could anybody explain the strange behavior of > > predict.gam function? > > > -- > Brian D. Ripley, > [EMAIL PROTECTED] > Professor of Applied Statistics, > http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 > 272861 (self) > 1 South Parks Road, +44 1865 > 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 > 272595 > __________________________________________________
--- End Message ---
______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
