Skip to contents

marginal_structural_model fits E(Y(abar)) = b0 + b1 sum_t a_t by weighted least squares with stabilised inverse-probability-of-treatment weights prod_t f(A_t | past A) / f(A_t | past A, L_1..L_t), both densities by Newton-Raphson logistic regression (Robins, Hernan and Brumback 2000). spatial_dbscan returns DBSCAN clusters of point locations (DbscanClusters; Ester et al. 1996).

Usage

marginal_structural_model(y, treatment_history, covariate_history)

spatial_dbscan(coords, eps = 1, min_pts = 5, border_points = TRUE)

Arguments

y

Outcome.

treatment_history

Binary n x T treatment matrix.

covariate_history

n x T time-varying confounders.

coords

Point coordinates.

eps

Neighbourhood radius.

min_pts

Minimum points of a core point (itself included).

border_points

Assign border points to clusters.

Value

marginal_structural_model a list with estimate, intercept, weights, ess, n, n_periods; spatial_dbscan a list with statistic (number of clusters), cluster, n_noise, sizes.

References

Robins, J. M., Hernan, M. A. and Brumback, B. (2000). Marginal structural models and causal inference in epidemiology. Epidemiology 11, 550-560. Ester, M., Kriegel, H.-P., Sander, J. and Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise. KDD-96, 226-231.

Examples

spatial_dbscan(rbind(c(0, 0), c(0, 1), c(1, 0), c(9, 9), c(9, 8), c(8, 9), c(5, 5)),
               eps = 1.5, min_pts = 3)$cluster
#> [1] 1 1 1 2 2 2 0