31 lines
1.8 KiB
R
31 lines
1.8 KiB
R
# Own estimands of the non-interventional designs (plan 5.5). The landmark and naive
|
|
# contrasts have no intervention that defines them; their own estimand is what the same
|
|
# estimator gives with every confounder measured (oracle): exact severity, true frailty
|
|
# and smoking, and the latent physician traits. A large-n limit is too noisy (the
|
|
# landmark estimator has few treated patients), so the oracle estimator is run on every
|
|
# replicate's own data: estimation bias = mean(estimate - oracle estimate), paired, and
|
|
# the oracle mean estimates the own estimand.
|
|
|
|
#' The replicate's records with the hidden truth in place of the claims proxies.
|
|
oracle_records <- function(rec) {
|
|
o <- rec
|
|
o$pm <- merge(rec$pm[, .(id, t)], rec$hidden_pm, by = c("id", "t"))[, .(id, t, sev_obs = z)]
|
|
h <- rec$hidden
|
|
o$patients <- merge(copy(rec$patients)[, c("frailty_index", "smoking") := NULL],
|
|
h[, .(id, frailty_index = frailty, smoking = smoking_true, skill, style)], by = "id")
|
|
o$extra_covs <- c("skill", "style")
|
|
o
|
|
}
|
|
|
|
#' Oracle versions of the landmark (both versions) and naive designs (V1, patient-level SE).
|
|
run_oracle <- function(rec, outcomes = c(male = "t_male", disease = "t_disease", nco1 = "t_nco1", nco2 = "t_nco2")) {
|
|
o <- oracle_records(rec)
|
|
rbindlist(lapply(names(outcomes), function(nm) {
|
|
lm <- est_landmark(o, outcomes[[nm]], "V1_ignore", extra_covs = o$extra_covs)
|
|
l5 <- est_landmark(o, outcomes[[nm]], "V1_ignore", extra_covs = o$extra_covs, at_landmark = TRUE)
|
|
nv <- est_naive(o, outcomes[[nm]], "V1_ignore", extra_covs = o$extra_covs)
|
|
rbind(cbind(design = "landmark", lm), cbind(design = "landmark_m5", l5), cbind(design = "naive", nv))[
|
|
, `:=`(outcome = nm, contrast = "early_none", variant = "oracle", se = se_patient)]
|
|
}))
|
|
}
|