Specification in, run out: builds the estimator inputs with
build_setup(), fits, runs inference, and – given a store – saves the
whole run so it can be reloaded and re-plotted without refitting.
Usage
fit_spec(
spec,
panel,
store = NULL,
keep = c("all", "est", "none"),
seed = NULL
)Arguments
- spec
An
sdid_spec().- panel
An
sdid_panel().- store
Directory of a run store to save into, or
NULL.- keep
How much of the fit to retain:
"all"(default) keeps the fitted object and every placebo draw, which every plot needs;"est"keeps only the fitted object;"none"keeps the summary alone.- seed
NULLto inherit the caller's RNG stream, or an integer seed applied to this fit only.
Reproducibility of the standard error
Placebo standard errors are simulated, so they depend on the state of the
RNG stream when the fit begins. seed = NULL inherits the caller's
stream: reproducible for a whole sweep run after one set.seed(), but a
spec refitted on its own gets a different SE. Passing
seed = seed_for(spec) makes a spec reproducible in isolation. The
caller's own stream is left untouched either way.
Examples
# \donttest{
spec <- sdid_spec(label = "Prop 99", inference = list(replications = 50))
run <- fit_spec(spec, prop99_panel(), seed = 1)
run
#>
#> ── sdid_run Prop 99
#> • ATT -15.6 95% CI [-37.4, 6.18]
#> • SE 11.1 (t = -1.40)
#> • fit sdid, N0 = 38, T0 = 19, pre-period RMSE 1.73
#> • placebos 47/50 kept at trim_k 5
#> • treated California from 1989
#> • spec bf7b1f5e74c4 run 20260929T053936906476-bf7b1f5e
# }