Stanford University
x, x + z where z is all covariatesx on y weighted by the propensity scorelm(x ~ z) for the propensity score model.wt_ate() with .fitted and .sigma; transforms using dnorm() to get on probability-like scale.exposure ~ confounderswt_ate()smkintensity82_71) affect weight gain among lighter smokers?exposure ~ confoundersnhefs_model <- lm( smkintensity82_71 ~ sex + race + age + I(age^2) + education + smokeintensity + I(smokeintensity^2) + smokeyrs + I(smokeyrs^2) + exercise + active + wt71 + I(wt71^2), data = nhefs_light_smokers )nhefs_model <- lm( smkintensity82_71 ~ sex + race + age + I(age^2) + education + smokeintensity + I(smokeintensity^2) + smokeyrs + I(smokeyrs^2) + exercise + active + wt71 + I(wt71^2), data = nhefs_light_smokers )nhefs_model <- lm( smkintensity82_71 ~ sex + race + age + I(age^2) + education + smokeintensity + I(smokeintensity^2) + smokeyrs + I(smokeyrs^2) + exercise + active + wt71 + I(wt71^2), data = nhefs_light_smokers )
wt_ate()wt_ate()# A tibble: 1,162 × 74
seqn qsmk death yrdth modth dadth sbp dbp sex
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <fct>
1 235 0 0 NA NA NA 123 80 0
2 244 0 0 NA NA NA 115 75 1
3 245 0 1 85 2 14 148 78 0
4 252 0 0 NA NA NA 118 77 0
5 257 0 0 NA NA NA 141 83 1
6 262 0 0 NA NA NA 132 69 1
7 266 0 0 NA NA NA 100 53 1
8 419 0 1 84 10 13 163 79 0
9 420 0 1 86 10 17 184 106 0
10 434 0 0 NA NA NA 127 80 1
# ℹ 1,152 more rows
# ℹ 65 more variables: age <dbl>, race <fct>, income <dbl>,
# marital <dbl>, school <dbl>, education <fct>, …
lm() with wait_minutes_posted_avg as the outcome and the confounders identified in the DAG.augment() to add model predictions to the data framewt_ate(), calculate the weights using wait_minutes_posted_avg, .fitted, and .sigma05:00 lm(x ~ 1)) or use mean and SD of xwt_ate(.., stabilize = TRUE) does this all!nhefs_swts <- nhefs_model |> augment(data = nhefs_light_smokers) |> mutate(swts = wt_ate( smkintensity82_71, .fitted, .sigma = .sigma, stabilize = TRUE ))nhefs_swts <- nhefs_model |> augment(data = nhefs_light_smokers) |> mutate(swts = wt_ate( smkintensity82_71, .fitted, .sigma = .sigma, stabilize = TRUE ))
03:00 lm( wt82_71 ~ smkintensity82_71, weights = swts, data = nhefs_swts ) |> tidy() |> filter(term == "smkintensity82_71") |> mutate(estimate = estimate * -10)lm( wt82_71 ~ smkintensity82_71, weights = swts, data = nhefs_swts ) |> tidy() |> filter(term == "smkintensity82_71") |> mutate(estimate = estimate * -10)
# A tibble: 1 × 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 smkintensity82_71 2.04 0.0335 -6.08 1.62e-9
03:00 lm(
wait_minutes_actual_avg ~ wait_minutes_posted_avg,
weights = swts,
data = wait_times_swts
) |>
tidy() |>
filter(term == "wait_minutes_posted_avg") |>
mutate(estimate = estimate * 10)# A tibble: 1 × 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 wait_minutes_posted_… 2.40 0.0655 3.66 4.48e-4