
Time-varying causal effect beta(t) over a sliding window
Source:R/causal_4d_bridge.R
causal_effect_time_varying.RdCloses the Pilar 1 x Pilar 3 loop: the v1.4.0 backdoor-adjusted estimator is applied within non-overlapping (or overlapping) windows of the temporal frame, producing a beta_hat(t) trajectory with bootstrap CIs. Mann-Kendall tests for a significant trend.
Usage
causal_effect_time_varying(
frame,
dag,
exposure,
outcome,
window = 24L,
step = 6L,
adjustment = NULL,
B = 200L,
min_n = 30L,
seed = NULL
)Arguments
- frame
A data frame with columns
t,lon,lat, theexposure,outcomeand anyadjustmentcolumns.- dag
A
dagittyDAG. Used only to derive the adjustment set whenadjustment = NULL.- exposure, outcome
Character column names.
- window
Integer; number of distinct
tvalues per window.- step
Integer; how many
tvalues to advance the window.- adjustment
Optional character vector of adjustment columns.
- B
Integer bootstrap replicates per window.
0disables CI estimation (just a point estimate per window).- min_n
Minimum in-window sample size to fit a window. Windows smaller than this yield
NAestimates.- seed
Optional RNG seed for bootstrap reproducibility.