ic.data.examp: Function for calculating the influence function used for the...

Description Usage Arguments Examples

View source: R/IC-RDE.R

Description

Function for calculating the influence function used for the real data example.

Usage

1
ic.data.examp(obs_data, what = "both", control = NULL)

Arguments

obs_data

the observed data. The first column should be the outcome.

what

the desired return value. Should be one of '"ic"' (infludence curve), '"est"' (estimate), or '"both"'.

control

any other control parameters to be passed to the estimator.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
expit <- function(x) exp(x) / (1 + exp(x))
ws <- matrix(rnorm(30000), 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)
obs_dat <- cbind(y, "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])
}

adam-s-elder/amar documentation built on Feb. 5, 2022, 7:10 a.m.