[R] Extract components of gam object

arun smartpink111 at yahoo.com
Sat Sep 7 17:54:54 CEST 2013



Hi,

summary(pres.gam)

Family: gaussian 
Link function: identity 

Formula:
prestige ~ s(income) + s(education)

Parametric coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  47.3276     0.6914   68.45   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Approximate significance of smooth terms:
               edf Ref.df     F  p-value    
s(income)    3.079  3.813 12.18 8.03e-08 ***
s(education) 3.005  3.746 42.68  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-sq.(adj) =   0.84   Deviance explained =   85%
GCV score = 50.493  Scale est. = 46.843    n = 98




Assuming that you want to extract `3.079`.
summary(pres.gam)$edf[1]
#[1] 3.07938
A.K.





I want to extract the components of a gam object. Sample code and data follows: 

library(MASS) 
library(mgcv)#package for GAM 
library(car)#to get the data 

data(Prestige) 
Prestige2<-na.omit(Prestige) 
pres.gam<-gam(prestige~s(income)+s(education),data =Prestige2) 

As an example I wish to extract the edf for income. In addition I
 want to learn how to systematically understand the components of 
structure pres.gam. I have tried str(pres.gam) which produce large 
output which is difficult to understand. Please explain using the edf 
component. 
Thank you



More information about the R-help mailing list