[R] Loop for running several models and retrieving outputs
jim holtman
jholtman at gmail.com
Tue Sep 16 04:19:26 CEST 2008
It is hard to tell since you have not told us what 'xxxxxxxxxxxxx' is,
but one way is to create a list of the objects you want to send to
'lm' and then save them in a list as output:
fit.mod <- list()
for (i in seq_along(myModels)){
fit.mod[[i]] <- lm(myModels[[i]]
}
On Mon, Sep 15, 2008 at 4:49 PM, FD <fhduan at gmail.com> wrote:
> Hi All:
>
> I need to run a bunch of models one-by-one and retrieve the outputs (like
> estimates, p values) accordingly. Some of models may not have outputs due to
> singularity or even no observations. If this happens, assign NA to the
> outputs.
>
> For example,
>
> #running models
> fit.mod <- lm(xxxxxxxxxx) #model 1
> fit.mod <- lm(xxxxxxxxxx) #model 2
> .........
> fit.mod <- lm(xxxxxxxxxx) #model 10
>
> #outputting estimates and p values to a data frame
> ....
>
>
> Any suggestions? Thank you very much in advance.
>
> FD
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list