Estimating equations for weighted sensitivity analysis of the mean
Source:R/ee-causal.R
ee_mean_sensitivity_analysis.RdEstimates the mean of an outcome with missing data using a weighted
sensitivity analysis approach. Handles MCAR, MAR, and MNAR
mechanisms by specifying a user-defined sensitivity function q_eval
and a monotone increasing distribution function H_function.
Arguments
- theta
Numeric vector of length
1 + b, wherebis the number of columns inX. The first element is the corrected mean; the remainder are regression coefficients.- y
Numeric vector of n outcome values. Missing values should be indicated via the
deltaparameter.- delta
Numeric vector of n indicators: 1 if
yis observed, 0 if missing. Must not containNA.- X
Numeric n-by-b design matrix for the missingness model. Should include an intercept column. Must not contain
NA.- q_eval
Numeric vector of n evaluated sensitivity function values, i.e.
q(Y, alpha).- H_function
A function mapping real values to
[0, 1]that is monotone increasing (e.g.,inverse_logit()).
Value
A (1+b)-by-n matrix of estimating equation contributions, with the
first row named corrected_mean and the missingness model rows named X_1
through X_b for the columns of X.
Examples
# An outcome observed for only part of the sample, with missingness driven by
# the measured covariate W.
set.seed(42)
n <- 500
W <- rbinom(n, 1, 0.5)
Y_full <- 200 - 35 * W + rnorm(n, sd = 5)
delta <- rbinom(n, 1, inverse_logit(2 + W))
# Missing outcomes never enter the estimating equation, so any placeholder
# value works; a zero keeps the arithmetic finite.
Y <- ifelse(delta == 1, Y_full, 0)
X <- cbind(1, W) # Missingness model design matrix
# A sensitivity function of zero everywhere assumes the outcome is missing at
# random given W. Nonzero values encode departures from that assumption.
psi <- function(theta) {
ee_mean_sensitivity_analysis(
theta,
y = Y,
delta = delta,
X = X,
q_eval = rep(0, n),
H_function = inverse_logit
)
}
# theta holds the corrected mean, started near the observed outcomes,
# followed by the two missingness model coefficients.
m <- m_estimate(stacked_equations = psi, init = c(180, 0, 0))
coef(m)
#> corrected_mean X_1 X_2
#> 183.174625 1.698074 1.061031