I try to do 1104 linear regressions with the same model. My independent variable does not change. However, my dependant variable does. Indeed, I have 1104 dependent variables. I can only extract all the coefficients (intercepts included), t-stats and R-square stats. I would also like to extract all the p-values lists of each coefficients within the 1104 linear regressions. How to do that with an easy way ?
Here are my codes:
run 1104 regressions for M1
bigtest<-as.data.frame(bigtest)
test <- lapply(135:1238, function(i) lm(bigtest[,i]~bigtest[,"rm"]))
reg_sq <- sapply(1:length(test),function(i) summary(test[[i]])$r.squared)
#reg_sq
coefrm <- sapply(1:length(test),function(i)summary(test[[i]])$coefficients[2,1])
intercept <- sapply(1:length(test),function(i)summary(test[[i]])$coefficients[1,1])
#betas
tstatrm <- sapply(1:length(test),function(i) summary(test[[i]])$coefficients[2,3])
tstatint <- sapply(1:length(test),function(i) summary(test[[i]])$coefficients[1,3])
#tstat
m1 <- cbind(reg_sq,coefrm,intercept,tstatrm,tstatint)
resultsM1 <- as.data.frame(m1)