# NOT RUN {
expit <- function(x) exp(x) / (1 + exp(x))
ws <- matrix(rnorm(3000), ncol = 3)
probs <- expit(ws %*% c(-1, 0, 2))
y <- rbinom(n = nrow(probs), size = 1, prob = probs[, 1])
wts <- abs(rnorm(length(y))) + 1
wts <- length(wts) * wts / sum(wts)
cats <- rep(1:10, 100)
obs_dat <- cbind(y, "cat" = cats, "wt" = wts, ws)
est_ic <- ic.data.examp(obs_dat, what = "both")
my_est <- est_ic$est
my_ic <- est_ic$ic / nrow(ws)
var_mat <- t(my_ic) %*% my_ic
sqrt(diag(var_mat))
for(cov_idx in 1:ncol(ws)){
print(summary(stats::glm(y ~ ws[, cov_idx], weights = obs_dat[, "wt"],
family = binomial))$coefficients[2, 1:2])
}
# }
Run the code above in your browser using DataLab