[R] How to automate this model selection algorithm?

Andrew Crane-Droesch andrewcd at gmail.com
Tue Mar 19 01:28:25 CET 2013


Just to add, I've been playing around with "select=TRUE" in mgcv, and it 
does seem that it could work if I were to specify all of the nested 
two-way interactions in my three-way interactions (see the toy example 
below).  But the problem is that I don't have enough degrees of freedom 
to feed such a model into GAM using my main dataset.

N=200
a = rnorm(N)
b = rnorm(N)
c = rnorm(N)

y = rnorm(N)+a+b+c+a*b

m = gam(y~s(a)+s(b)+s(c)+te(a,b)+te(a,b,c))
msel = gam(y~s(a)+s(b)+s(c)+te(a,b)+te(a,b,c),select=TRUE)
mdrop = gam(y~s(a)+s(b)+s(c)+te(a,b))
summary(m)
summary(msel)
summary(mdrop)
plot(density(m$fitted.values))
lines(density(msel$fitted.values),col="red")
lines(density(mdrop$fitted.values),col="blue")



More information about the R-help mailing list