# Finds the largest/smallest SE when the covariance
# is unknown.
ivse_optim <- function(itty,ittw,ittyse,ittwse, min=1){
low <- (-1)*(ittyse*ittwse)
hig <- (ittyse*ittwse)
start <- 0
res <- optim(start,function(x){
ivse(itty,ittw,ittyse,ittwse,x)},
lower=low, upper=hig, method="L-BFGS-B",
control=list(fnscale=min))
return(res$value)
}
#' Calculates the variance of the Wald Estimator
#' see Imbens/Rubin, p. 531 (eq. 23.5)
ivvar <- function(itty,ittw,ittyse,ittwse,ittcov){
ittyvar <- (ittyse)^2
ittwvar <- (ittwse)^2
r1 <- (1/ittw^2)*ittyvar
r2 <- (itty^2/ittw^4) * ittwvar
r3 <- (-2 * (itty/ittw^3)*ittcov)
return(r1+r2+r3)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.