Created
May 29, 2011 05:14
-
-
Save tony91782/997494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ivboot <- function(sec,fir,data,boots=500){ | |
dat <- data | |
sec <- as.formula(sec) | |
fir <- as.formula(fir) | |
thisiv <- iv(sec, fir,data) | |
booter <- function(dat,i){ | |
coef(iv(sec,fir,data=dat[i,])) | |
} | |
boot_coef <-coef(thisiv) | |
myboot <- boot(dat, booter, R=boots,stype="i") | |
thisiv$second$coefficients[,2] <- sd(myboot$t) | |
thisiv$second$coefficients[,3] <- thisiv$second$coefficients[,1]/thisiv$second$coefficients[,2] | |
thisiv$second$coefficients[,4] <- 2*pnorm(-abs(thisiv$second$coefficients[,3])) | |
colnames(thisiv$second$coefficients) = c("Estimate", "Std. Error", "z value", "Pr( >|z|)") | |
return(thisiv) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment