[R] GAMs in R : How to put the new data into the model?

Daniel Malter daniel at umd.edu
Wed Sep 28 07:31:08 CEST 2011


Your questions is pretty opaque. Please adhere to the posting guide. Provide
a self-contained (!) example (i.e., code) that reproduces your problem.
Generally, you would predict like this:

x<-rnorm(100)
e<-rnorm(100)
y<-x+x^2+e
reg<-gam(y~s(x))
plot(reg)

predict(reg,newdata=data.frame(x=2))

where you can substitute any vector of values for x

HTH,
Daniel



pigpigmeow wrote:
> 
> I have 5  GAMs ( model1, model2, model3, model4 and model5)
> Before I use some data X(predictor -January to June data) to form a
> equation and calculate the expected value of Y (predictand -January to
> June). After variable selection, GAMs (Model 1)were bulit up! R-square
> :0.40
> 
> NOW, I want to use new X'( predictor -July - December data) and put into
> Model 1, then get the expected value of Y' (predictand-July -December)
> 
> I used mcgv package, what should I do now?
> 

--
View this message in context: http://r.789695.n4.nabble.com/GAMs-in-R-How-to-put-the-new-data-into-the-model-tp3849851p3850063.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list