Hello,
I would like to write a loop to 1) run 100 linear regressions, and 2)
compile the slopes of all regression into one vector. Sample input data
are:
y1<-rnorm(100, mean=0.01, sd=0.001)
y2<-rnorm(100, mean=0.1, sd=0.01)
x<-(c(10,400))
#I have gotten this far with the loop
for (i in 1:100) {
#create the linear model for each data set
model1<-lm(c(y1[i],y2[i])~x)
slope1<-model1$coefficients[2]
}
How can I compile the slopes from all 100 regressions into one vector?
Thanks,
Jake
[[alternative HTML version deleted]]