Skip to contents

A logistic regression for the probability of being on the drug in each person-interval, given the confounders that drive treatment: the current heart rate, the baseline heart rate, and the previous interval's dose. This is the engine behind both propensity-score adjustment (M5) and IPTW (M7).

Usage

fit_propensity(data, formula = on_drug ~ baseline_hr + heart_rate + prev_drug)

Arguments

data

A long cohort from simulate_hr_agent().

formula

The treatment model. Defaults to on_drug ~ baseline_hr + heart_rate + prev_drug.

Value

A fitted stats::glm() object. Inspect it with broom::tidy().

Examples

dat <- simulate_hr_agent(n = 2000)
ps_fit <- fit_propensity(dat)
broom::tidy(ps_fit, exponentiate = TRUE)
#> # A tibble: 4 × 5
#>   term        estimate std.error statistic   p.value
#>   <chr>          <dbl>     <dbl>     <dbl>     <dbl>
#> 1 (Intercept)  0.00106   0.291      -23.5  3.10e-122
#> 2 baseline_hr  1.02      0.00430      4.27 1.92e-  5
#> 3 heart_rate   1.07      0.00430     15.1  2.31e- 51
#> 4 prev_drug    1.94      0.109        6.10 1.05e-  9