Re: [R] Question about GAMs

2011-10-13 Thread Simon Wood
predict.gam is returning a matrix with a named column for each term. Select the appropriate column. Example below library(mgcv) n<-200;sig <- 2 dat <- gamSim(1,n=n,scale=sig) b <- gam(y~s(x0)+s(I(x1^2))+s(x2)+offset(x3),data=dat) newd <- data.frame(x0=(0:30)/30,x1=(0:30)/30,x2=(0:30)/30,x3=(0:30

Re: [R] Question about GAMs

2011-10-13 Thread pigpigmeow
pre<-predict(ozonea,groupA,type="terms",terms=NULL,newdata.guaranteed=FALSE,na.action=na.pass) yeah! but I don't know how to only show the value of s(ratio,bs="cr") -- View this message in context: http://r.789695.n4.nabble.com/Question-about-GAMs-tp3900848p3903753.html Sent from the R help mail

Re: [R] Question about GAMs

2011-10-13 Thread David Winsemius
On Oct 13, 2011, at 11:20 AM, pigpigmeow wrote: I'm confused... I type .. predict.gam(ozonea,type=s(ratio,bs="cr")) pressure maxtemp s(avetemp) s(ratio) 1 -0.0459102290 -0.185178463 0.263358446 -0.164558673 2 -0.0286464652 -0.194731320 0.199315027 0.727823293 30.04780734

Re: [R] Question about GAMs

2011-10-13 Thread Gavin Simpson
On Thu, 2011-10-13 at 08:20 -0700, pigpigmeow wrote: > I'm confused... > I type .. > predict.gam(ozonea,type=s(ratio,bs="cr")) That is not a valid 'type'; normally you'd use `type = "terms"` or `type = "iterms"`, depending on whether you want (any) standard errors to include the uncertainty about

Re: [R] Question about GAMs

2011-10-13 Thread pigpigmeow
I'm confused... I type .. predict.gam(ozonea,type=s(ratio,bs="cr")) pressure maxtemp s(avetemp) s(ratio) 1 -0.0459102290 -0.185178463 0.263358446 -0.164558673 2 -0.0286464652 -0.194731320 0.199315027 0.727823293 30.0478073459 -0.013227033 0.002228896 0.342373202 4 -0.00

Re: [R] Question about GAMs

2011-10-13 Thread Simon Wood
I'd be inclined to use predict(ozonea,type="terms") to extract the estimates of s(ratio,bs = "cr") that you need. But do you really want newozone - s(ratio,bs="cr") when you've used a log link? best, Simon On 10/13/2011 09:05 AM, pigpigmeow wrote: hi! I hope all of you can help me this ques

Re: [R] Question about GAMs

2011-10-13 Thread Daniel Malter
I am not an expert on this, but there is a way to check this. You can predict from a gam using predict(ozonea, newdata=...). In the "newdata" argument you can specify the X-values of interest to you. Thus, you can compare if your predictions are the same when predicted directly from the gam or when

[R] Question about GAMs

2011-10-13 Thread pigpigmeow
hi! I hope all of you can help me this question for example GAMs: ozonea<-gam(newozone~ pressure+maxtemp+s(avetemp,bs="cr")+s(ratio,bs="cr"),family=gaussian (link=log),groupA,methods=REML) formula(ozonea) newozone ~ pressure + maxtemp + s(avetemp, bs = "cr") + s(ratio,bs = "cr") #formula of gam