
Marginal structural models
morie_marginal_structural_models.RdCausal models fitted in the pseudo-population created by stabilized inverse-probability-of-treatment weights (Robins, Hernan and Brumback, 2000), so their coefficients are causal rather than confounder-adjusted associations.
Usage
morie_msm_linear(y, treatment_history, weights = NULL)
morie_msm_logistic(y, treatment_history, weights = NULL)
morie_msm_poisson(y, treatment_history, offset = NULL, weights = NULL)
morie_msm_negative_binomial(y, treatment_history, alpha = 1, offset = NULL,
weights = NULL)
morie_msm_cox_marginal(time, event, treatment_history, weights = NULL)
morie_msm_accelerated_failure(time, event, treatment_history, weights = NULL)
morie_msm_gmm_estimator(y, treatment_history, instruments = NULL, weights = NULL)
morie_msm_time_varying_exposure(y, exposure_history, weights = NULL)Arguments
- y
outcome vector
- treatment_history
matrix of treatments, one row per subject
- exposure_history
matrix of exposures, one row per subject
- time
observed follow-up times
- event
event indicator, 1 for an event and 0 for censored
- weights
stabilized inverse-probability-of-treatment weights
- offset
optional log-exposure offset
- alpha
negative-binomial overdispersion parameter
- instruments
optional instrument matrix for the GMM estimator
Value
A list holding the fitted quantities for the method called: point estimates, fitted values and any diagnostics it produces. See the individual method descriptions above for the components each returns.
Details
These functions mirror, in R, the implementations in the Python package
morie; the two are checked against each other by the parity
tests in tests/testthat/.
Examples
set.seed(1)
A <- matrix(rbinom(60, 1, 0.5), 30, 2)
y <- 1 + 0.8 * rowMeans(A) + rnorm(30, 0, 0.3)
morie_msm_linear(y, A)
#> $estimate
#> [1] 0.3538458
#>
#> $beta
#> [1] 1.0859866 0.3538458
#>
#> $beta_a
#> [1] 0.3538458
#>
#> $a_bar
#> [1] 0 1 1 1 1 2 2 1 2 0 1 1 2 1 2 1 1 1 1 2 1 1 1 0 0 0 0 1 2 0
#>
#> $fitted
#> [1] 1.085987 1.439832 1.439832 1.439832 1.439832 1.793678 1.793678 1.439832
#> [9] 1.793678 1.085987 1.439832 1.439832 1.793678 1.439832 1.793678 1.439832
#> [17] 1.439832 1.439832 1.439832 1.793678 1.439832 1.439832 1.439832 1.085987
#> [25] 1.085987 1.085987 1.085987 1.439832 1.793678 1.085987
#>