causal-inference-in-R icon indicating copy to clipboard operation
causal-inference-in-R copied to clipboard

Expanding on continuous exposures

Open malcolmbarrett opened this issue 3 years ago • 5 comments

Balance assessment: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6484705/ Binning: https://journals.lww.com/epidem/Fulltext/2014/03000/Constructing_Inverse_Probability_Weights_for.21.aspx

malcolmbarrett avatar Jul 18 '22 15:07 malcolmbarrett

also looking for information on estimating different estimands for continuous exposures (cc @LucyMcGowan if you find anything)

malcolmbarrett avatar Jul 18 '22 15:07 malcolmbarrett

Getting the weighted correlations for covariate balance assessment is a bit of a pain and might be benefited by a function in a package. Using the packages and models in the book:

wait_times_wts |> 
  # prep data for `cov.wt()`
  drop_na(avg_spostmin, close, extra_magic_morning, weather_wdwhigh, wdw_ticket_season) |> 
  select(avg_spostmin, close, extra_magic_morning, weather_wdwhigh, wdw_ticket_season) |> 
  mutate(close = as.numeric(close), wdw_ticket_season = as.numeric(factor(wdw_ticket_season))) |> 
  # get weighted correlations
  cov.wt(wt = wait_times_wts$swts, cor = TRUE) |> 
  pluck("cor") |> 
  # tidy results
  as.data.frame(rownames = TRUE) |> 
  rownames_to_column("variable") |> 
  filter(variable != "avg_spostmin") |> 
  select(variable, correlation = avg_spostmin)

#              variable  correlation
# 1               close  0.57380383
# 2 extra_magic_morning  0.03553053
# 3     weather_wdwhigh  0.30051169
# 4   wdw_ticket_season -0.13616836

malcolmbarrett avatar Jul 18 '22 15:07 malcolmbarrett

I thought we had this linked somewhere but couldn't find it in the issues. @malcolmbarrett this is a nice paper for generalized propensity scores with different targets: https://arxiv.org/pdf/1808.05339.pdf

image

LucyMcGowan avatar Nov 13 '22 01:11 LucyMcGowan

oh excellent!!

malcolmbarrett avatar Nov 13 '22 15:11 malcolmbarrett

Code to do weighted correlation by hand if helpful:

causal_collider_wts |>
  summarise(
    exposure_w = sum(swts * exposure) / sum(swts),
    covariate_w = sum(swts * covariate) / sum(swts),
    numerator = sum(swts * (exposure - exposure_w) * (covariate - covariate_w)),
    denom = sqrt(sum(swts * (exposure - exposure_w)^2) * sum(swts * (covariate - covariate_w)^2)),
    weighted_cor = numerator/denom
  ) |>
  select(weighted_cor)

LucyMcGowan avatar Jul 21 '23 14:07 LucyMcGowan