r - Variable Selection with mgcv -
is there way of automating variable selection of gam in r, similar step? i've read documentation of step.gam
, selection.gam
, i've yet see answer code works. additionally, i've tried method= "reml"
, select = true
, neither remove insignificant variables model.
i've theorized create step model , use variables create gam, not seem computationally efficient.
example:
library(mgcv) set.seed(0) dat <- data.frame(rsp = rnorm(100, 0, 1), pred1 = rnorm(100, 10, 1), pred2 = rnorm(100, 0, 1), pred3 = rnorm(100, 0, 1), pred4 = rnorm(100, 0, 1)) model <- gam(rsp ~ s(pred1) + s(pred2) + s(pred3) + s(pred4), data = dat, method = "reml", select = true) summary(model) #family: gaussian #link function: identity #formula: #rsp ~ s(pred1) + s(pred2) + s(pred3) + s(pred4) #parametric coefficients: # estimate std. error t value pr(>|t|) #(intercept) 0.02267 0.08426 0.269 0.788 #approximate significance of smooth terms: # edf ref.df f p-value #s(pred1) 0.8770 9 0.212 0.1174 #s(pred2) 1.8613 9 0.638 0.0374 * #s(pred3) 0.5439 9 0.133 0.1406 #s(pred4) 0.4504 9 0.091 0.1775 --- #signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #r-sq.(adj) = 0.0887 deviance explained = 12.3% #-reml = 129.06 scale est. = 0.70996 n = 100
marra , wood (2011, computational statistics , data analysis 55; 2372-2387) compare various approaches feature selection in gams. concluded additional penalty term in smoothness selection procedure gave best results. can activated in mgcv::gam() using select = true
argument/setting, or of following variations:
model <- gam(rsp ~ s(pred1,bs="ts") + s(pred2,bs="ts") + s(pred3,bs="ts") + s(pred4,bs="ts"), data = dat, method = "reml") model <- gam(rsp ~ s(pred1,bs="cr") + s(pred2,bs="cr") + s(pred3,bs="cr") + s(pred4,bs="cr"), data = dat, method = "reml",select=t) model <- gam(rsp ~ s(pred1,bs="cc") + s(pred2,bs="cc") + s(pred3,bs="cc") + s(pred4,bs="cc"), data = dat, method = "reml") model <- gam(rsp ~ s(pred1,bs="tp") + s(pred2,bs="tp") + s(pred3,bs="tp") + s(pred4,bs="tp"), data = dat, method = "reml")
Comments
Post a Comment