[R] create data frame with coefficients from many regressions

iza.ch1 iza.ch1 at op.pl
Mon Jul 22 21:11:02 CEST 2013


> 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
> 
> 


More information about the R-help mailing list