s-news
[Top] [All Lists]

Re: Save several regression outputs in One Object

To: s-news@lists.biostat.wustl.edu
Subject: Re: Save several regression outputs in One Object
From: Daniel_J_Celta@fpl.com
Date: Sun, 6 Aug 2006 13:02:55 -0400
Cc: "Chen,Sichong" <sichong.chen@postgrad.manchester.ac.uk>
Chen
You would need to use an "lapply" where you pass to the function the inputs
for the regression.
The "lapply" will return a list where each object of the list is a fitted
regression model.

For example:

RgList _
  lapply(list("DepVar1", "DepVar2"),
      function(DepVar, Data, ...)  {
            assign("DepVar", DepVar, where = 0)
            lm(DepVar ~ ExpVar1 + ExpVar2, Data, ...)
      }, Data = Data)

RgList is now a list were each object is an lm model.
Hope this helps


Daniel J Celta
Project Valuation - Special Valuations
561 691 7653


                                                                                
                                                                  
                      "Chen,Sichong"                                            
                                                                  
                      <sichong.chen@postgrad.manche        To:       
s-news@lists.biostat.wustl.edu                                               
                      ster.ac.uk>                          cc:                  
                                                                  
                      Sent by:                             Subject:  [S] Save 
several regression outputs in One Object                            
                      s-news-owner@lists.biostat.wu                             
                                                                  
                      stl.edu                                                   
                                                                  
                                                                                
                                                                  
                                                                                
                                                                  
                      08/05/2006 06:42 PM                                       
                                                                  
                                                                                
                                                                  
                                                                                
                                                                  




Dear Users

I have a question regarding on how to save several regression outputs in
one
object.

I have a loop, which will do regression for 50 times and so it will have 50
outputs for the regression results. I want to create an object. Every time,
the output is save in this object. So at the end, I don't have to have 50
objects for the results, only this object will give me what I need.
Previously, what I did is very simple. I only need a residual or
coefficient
for the regressions. I just create a matrix and use cbind function to
combine the results together as long as the result is a vector and have the
same length. But this time it is a little different, I want to save,
coefficients, t-stats, p-value and R-square all. So the job is quite
difficult for me.

I am thinking to create a list object. But I really don't know how to put
this function into a loop and get the answer quickly.

I am also thinking about to use object array, if the result to save each
time has the same dimension. But again, I don't know how to use it in loop
either. Any suggestion is appreciated.

Best regards,
Sichong Chen
PhD of Finance
Manchester Business School
University of Manchester
Oxford Road
Manchester
United Kingdom
M13 9PL


--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news






<Prev in Thread] Current Thread [Next in Thread>