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 gams coef(ozonea) # extract the coefficient of GAMs (Intercept) pressure maxtemp s(avetemp).1 s(avetemp).2 s(avetemp).3 s(avetemp).4 s(avetemp).5 s(avetemp).6 s(avetemp).7 s(avetemp).8 s(avetemp).9 s(ratio).1 2.848204561 -0.024662520 -0.095528572 -0.052613005 -0.135309283 0.066243642 0.030937179 0.176267227 0.243405931 0.357027920 0.600628869 0.758581430 0.004653696 s(ratio).2 s(ratio).3 s(ratio).4 s(ratio).5 s(ratio).6 s(ratio).7 s(ratio).8 s(ratio).9 0.156547789 -0.132527837 -0.179947367 -0.208918785 -0.468014803 -0.195498523 -0.813667830 -1.505844690 then, I want to calculate newozone - s(ratio,bs="cr") we define this term (newozone - s(ratio,bs="cr")) is X can i use the coefficient to calculate? -- View this message in context: http://r.789695.n4.nabble.com/Question-about-GAMs-tp3900848p3900848.html Sent from the R help mailing list archive at Nabble.com.
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 predicted by hand. HTH, Daniel pigpigmeow wrote:> > 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 gams > > coef(ozonea) # extract the coefficient of GAMs > (Intercept) pressure maxtemp s(avetemp).1 s(avetemp).2 > s(avetemp).3 s(avetemp).4 s(avetemp).5 s(avetemp).6 s(avetemp).7 > s(avetemp).8 s(avetemp).9 s(ratio).1 > 2.848204561 -0.024662520 -0.095528572 -0.052613005 -0.135309283 > 0.066243642 0.030937179 0.176267227 0.243405931 0.357027920 > 0.600628869 0.758581430 0.004653696 > s(ratio).2 s(ratio).3 s(ratio).4 s(ratio).5 s(ratio).6 > s(ratio).7 s(ratio).8 s(ratio).9 > 0.156547789 -0.132527837 -0.179947367 -0.208918785 -0.468014803 > -0.195498523 -0.813667830 -1.505844690 > > then, I want to calculate > newozone - s(ratio,bs="cr") > we define this term (newozone - s(ratio,bs="cr")) is X > can i use the coefficient to calculate? >-- View this message in context: http://r.789695.n4.nabble.com/Question-about-GAMs-tp3900848p3901383.html Sent from the R help mailing list archive at Nabble.com.
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 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 gams > > coef(ozonea) # extract the coefficient of GAMs > (Intercept) pressure maxtemp s(avetemp).1 s(avetemp).2 > s(avetemp).3 s(avetemp).4 s(avetemp).5 s(avetemp).6 s(avetemp).7 > s(avetemp).8 s(avetemp).9 s(ratio).1 > 2.848204561 -0.024662520 -0.095528572 -0.052613005 -0.135309283 > 0.066243642 0.030937179 0.176267227 0.243405931 0.357027920 0.600628869 > 0.758581430 0.004653696 > s(ratio).2 s(ratio).3 s(ratio).4 s(ratio).5 s(ratio).6 > s(ratio).7 s(ratio).8 s(ratio).9 > 0.156547789 -0.132527837 -0.179947367 -0.208918785 -0.468014803 > -0.195498523 -0.813667830 -1.505844690 > > then, I want to calculate > newozone - s(ratio,bs="cr") > we define this term (newozone - s(ratio,bs="cr")) is X > can i use the coefficient to calculate? > > > -- > View this message in context: http://r.789695.n4.nabble.com/Question-about-GAMs-tp3900848p3900848.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
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 mailing list archive at Nabble.com.