Extreme Value Bounds with Double Sampling
estimator_ds(Y, Z, R1, Attempt, R2, minY, maxY, strata = NULL, alpha = 0.05, data)
Y | The (unquoted) outcome variable. Must be numeric. |
---|---|
Z | The (unquoted) assignment indicator variable. Must be numeric and take values 0 or 1. |
R1 | The (unquoted) initial sample respose indicator variable. Must be numeric and take values 0 or 1. |
Attempt | The (unquoted) follow-up sample attempt indicator variable. Must be numeric and take values 0 or 1. |
R2 | The (unquoted) follow-up sample respose indicator variable. Must be numeric and take values 0 or 1. |
minY | The minimum possible value of the outcome (Y) variable. |
maxY | The maximum possible value of the outcome (Y) variable. |
strata | A single (unquoted) variable that indicates which strata units are in. |
alpha | The desired significance level. 0.05 by default. |
data | A dataframe |
A results matrix
set.seed(343) # For reproducibility N <- 1000 # Potential Outcomes Y_0 <- sample(1:5, N, replace=TRUE, prob = c(0.1, 0.3, 0.3, 0.2, 0.1)) Y_1 <- sample(1:5, N, replace=TRUE, prob = c(0.1, 0.1, 0.4, 0.3, 0.1)) R1_0 <- rbinom(N, 1, prob = 0.7) R1_1 <- rbinom(N, 1, prob = 0.8) R2_0 <- rbinom(N, 1, prob = 0.9) R2_1 <- rbinom(N, 1, prob = 0.95) # Covariate strata <- as.numeric(Y_0 > 2) # Random Assignment Z <- rbinom(N, 1, .5) # Reveal Initial Sample Outcomes R1 <- Z*R1_1 + (1-Z)*R1_0 # Initial sample response Y_star <- Z*Y_1 + (1-Z)*Y_0 # True outcomes Y <- Y_star Y[R1==0] <- NA # Mask outcome of non-responders # Conduct Double Sampling Attempt <- rep(0, N) Attempt[is.na(Y)] <- rbinom(sum(is.na(Y)), 1, .5) R2 <- rep(0, N) R2[Attempt==1] <- (Z*R2_1 + (1-Z)*R2_0)[Attempt==1] Y[R2==1 & Attempt==1] <- Y_star[R2==1 & Attempt==1] df <- data.frame(Y, Z, R1, Attempt, R2, strata) # Without post-stratification estimator_ds(Y, Z, R1, Attempt, R2, minY=1, maxY=5, data=df)#> ci_lower ci_upper low_est upp_est low_var upp_var #> 0.048650401 0.437209790 0.181568350 0.304099481 0.006471977 0.006490723# With post-stratification estimator_ds(Y, Z, R1, Attempt, R2, minY=1, maxY=5, strata=strata, data=df)#> ci_lower ci_upper low_est upp_est low_var upp_var #> 0.134213533 0.482968974 0.246987534 0.375801359 0.004689110 0.004234475