View source: R/simulate_data.R
simulate_confounded_data | R Documentation |
Simulates confounded data with continuous treatment based on Vegetabile et al's simulation
simulate_confounded_data( seed = 1, nobs = 1000, MX1 = -0.5, MX2 = 1, MX3 = 0.3, A_effect = TRUE )
seed |
random seed for reproducibility |
nobs |
number of observations |
MX1 |
the mean of the first covariate. Defaults to -0.5, the value used in the simulations of Vegetabile, et al (2021). |
MX2 |
the mean of the second and fourth covariates. Defaults to 1, the value used in the simulations of Vegetabile, et al (2021). |
MX3 |
the probability that the fifth covariate (a binary covariate) is equal to 1. Defaults to 0.3, the value used in the simulations of Vegetabile, et al (2021). |
A_effect |
whether ( |
An list with elements:
data |
A simulated dataset with |
true_adrf |
A function that inputs values of the treatment |
A list with the following elements
data |
a |
true_adrf |
a function; true average dose response function |
original_covariates |
original, untransformed covariates in the simulation setup. Do not use, as it makes the simulation setup significantly easier. |
Vegetabile, B. G., Griffin, B. A., Coffman, D. L., Cefalu, M., Robbins, M. W., and McCaffrey, D. F. (2021). Nonparametric estimation of population average dose-response curves using entropy balancing weights for continuous exposures. Health Services and Outcomes Research Methodology, 21(1), 69-110.
simdat <- simulate_confounded_data(seed = 999, nobs = 500) str(simdat$data) A <- simdat$data$A y <- simdat$data$Y trt_vec <- seq(min(simdat$data$A), max(simdat$data$A), length.out=500) ylims <- range(c(simdat$data$Y, simdat$true_adrf(trt_vec))) plot(x = simdat$data$A, y = simdat$data$Y, ylim = ylims) lines(x = trt_vec, y = simdat$true_adrf(trt_vec), col = "blue", lwd=2) ## naive estimate of ADRF without weights adrf_hat_unwtd <- weighted_kernel_est(A, y, rep(1, length(y)), trt_vec)$est lines(x = trt_vec, y = adrf_hat_unwtd, col = "green", lwd=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.