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) }