Displaying 1 result from an estimated 1 matches for "newyi".
Did you mean:
newy
2007 May 21
1
Boostrap p-value in regression [indirectly related to R]
...### fit simple regression model
mod <- lm(yi ~ xi)
summary(mod)
b1 <- coef(mod)[2]
t1 <- coef(mod)[2] / coef(summary(mod))[2,2]
### 1000 bootstrap replications using (X,Y)-pair resampling
t1.star <- rep(NA,1000)
for (i in 1:1000) {
ids <- sample(1:n, replace=TRUE)
newyi <- yi[ids]
newxi <- xi[ids]
mod <- lm(newyi ~ newxi)
t1.star[i] <- ( coef(mod)[2] - b1) / coef(summary(mod))[2,2]
}
### get bootstrap p-value
hist(t1.star, nclass=40)
abline(v=t1, lwd=3)
abline(v=-1*t1, lwd=3)
2 * mean( t1.star > abs(t1) )
###############...