Try this:
apply(subset.models[,-1], 1,
function(x)lm(as.formula(paste('y ~',
paste(names(freeny[,-1])[x],
collapse = "+"), sep = "")), data = freeny))
On Sun, Sep 13, 2009 at 10:57 AM, Axel Urbiz <axel.urbiz@gmail.com> wrote:
> Hi,
>
> I’d like to fit one GLM model for each possible combination of inputs (i.e.
> exhaustive search). The package leaps can help me to generate all possible
> variable subsets, but I’ll appreciate your guidance as of how to generate
> one model for each of those possible subsets. I’m new in R! Thanks in
> advance for your help.
>
> library(leaps)
>
> subsets <- regsubsets( y ~ . , data=freeny, nbest=100, nvmax=5,
>
> method="exhaustive", really.big=T)
>
> subset.models <- summary(subsets)$which
>
> now fit one lm for each possible combination of variables.
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@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.
>
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]