[R-SIG-Finance] create data frame with coefficients from many regressions

Jeff Ryan jeff.a.ryan at gmail.com
Mon Jul 22 21:04:09 CEST 2013


The results of an lapply call can be joined together easily with do.call(cbind or do.call(rbind or do.call(c. Though what you need is probably requiring one additional step to use a custom function to get the result you want in some sensible structure for the above. 

This isn't at all a finance question though. Should be redirected to r-help. 

Thanks
Jeff

Jeffrey Ryan    |    Founder    |    jeffrey.ryan at lemnica.com

www.lemnica.com

On Jul 22, 2013, at 12:54 PM, "iza.ch1" <iza.ch1 at op.pl> wrote:

> Hi !
> 
> I want to ask if somebody knows the way to create data frame with coefficients from many regressions 
> I regress the first column from ret against the first columns from median, then the second with the second and so on.
> This is the code used for regression
> 
> i<-1:6
> lapply(seq_len(ncol(ret)),function(i) {lm(ret[,i]~median[,i])}
> 
> I get 6 results for each regression 
> 
> [[1]]
> 
> Call:
> lm(formula = ret[, i] ~ median[, i])
> 
> Coefficients:
> (Intercept)  median[, i]  
>          0            1  
> 
> 
> [[2]]
> 
> Call:
> lm(formula = ret[, i] ~ median[, i])
> 
> Coefficients:
> (Intercept)  median[, i]  
> -1.411e-17    1.000e+00 
> 
> now I would like to create a data frame with intercepts which looks like it
> 
>                        [[1]]          [[2]]
> Intercept
> median
> 
> I tried to use ddply command but it does not work. I will be very grateful for the hint :)
> 
> Thank you in advance
> 
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list