Displaying 1 result from an estimated 1 matches for "mall80".
Did you mean:
mall20
2008 Aug 25
1
How to run a model 1000 times, while saving coefficients each time?
...ave a looping structure (also below) but we do not know how to save
the coefficients and R2 values. We are missing some code (indicated)
Any assistance would be greatly appreciated.
Thanks,
library(sampling)
mall<-read.csv("mall.csv")
for (j in 1:1000) {
s<-srswor(2840,3550)
mall80<-mall[s==1,]
mall20<-mall[s==0,]
model1<-lm(count~habitat,data=mall80)
summary(model1)
mall20$predicted<-predict(model1,newdata=mall20)
model2<-lm(count~predicted,data=mall20)
MISSING CODE: SAVE MODEL COEFFICIENTS AND R2 VALUE TO A DATAFRAME CALLED
RESULTS
}