[R] Question about GAMs

Simon Wood s.wood at bath.ac.uk
Fri Oct 14 08:42:06 CEST 2011


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)/30)
pred <- predict.gam(b,newd,type="terms")

pred[,3] ## extracts s(x2)
pred[,"s(x2)"] ## same


On 14/10/11 04:54, pigpigmeow wrote:
> 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.
>
> ______________________________________________
> 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.
>


-- 
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603               http://people.bath.ac.uk/sw283



More information about the R-help mailing list