Skip to content
Prev 327243 / 398502 Next

create data frame with coefficients from many regressions

set.seed(28)
dat1<- as.data.frame(matrix(sample(1:20,100,replace=TRUE),ncol=10))

set.seed(49)
dat2<- as.data.frame(matrix(sample(40:80,100,replace=TRUE),ncol=10))

?sapply(seq_len(ncol(dat1)),function(i) {x1<- summary(lm(dat2[,i]~dat1[,i]));x1$coef[,1]})
#????????????????? [,1]?????? [,2]?????? [,3]?????? [,4]?????? [,5]????? [,6]
#(Intercept) 50.3768788 53.5300207 65.2972973 55.6530015 58.5158172 79.368165
#dat1[, i]??? 0.4770829? 0.2767426 -0.4554849? 0.3089312? 0.7785589 -1.193601
#????????????????? [,7]????? [,8]????? [,9]?????? [,10]
#(Intercept) 59.8130393 67.089662 74.593072 66.39938809
#dat1[, i]?? -0.4659636 -1.498945 -1.221709? 0.05624853
?
as.data.frame(sapply(seq_len(ncol(dat1)),function(i) {x1<- summary(lm(dat2[,i]~dat1[,i]));x1$coef[,1]}))


A.K.




----- Original Message -----
From: iza.ch1 <iza.ch1 at op.pl>
To: r-help at r-project.org
Cc: 
Sent: Monday, July 22, 2013 3:11 PM
Subject: [R] create data frame with coefficients from many regressions
______________________________________________
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.