[R] How to make array of regression objects

Ista Zahn izahn at psych.rochester.edu
Wed May 18 14:25:22 CEST 2011


Hi Dmitrij,
I think the usual way is to store the results in a list:

o <- list()
o[[1]] <- lrm(...)
o[[2]] <- lrm(...)
o[[...]] <-lrm(...)

then you can access the results like 0[[1]], 0[[2]] ...

Best,
Ista

On Tue, May 17, 2011 at 11:53 PM, Dmitrij Kudriavcev
<dimitrij.kudriavcev at ntsg.lt> wrote:
> Dear all,
>
> I have made couple logistic regressions, what making a distribution of some
> event.
>
> Currently, i store it like this:
>
> o1 <- lrm(...)
> o2 <- lrm(...)
> o3 <- lrm(...)
> ...
>
> Then, i have made a function to peak required regression object from this
> variables by it number:
>
> get_object <- function(obj_name, nModel) {
>    eval (parse(text=paste("o <- ", obj_name, nModel, sep="")))
>    o
> }
>
> Is there a better way to do it? I have try to store it in the matrix using
> data.frame(), but object become destroyed after that and predict() function
> do not recognize it.
>
> Regards,
> Dmitrij Kudriavcev
>
>        [[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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list