extrapolate_model {simITS} | R Documentation |
Extrapolate pre-policy data to post-policy era
Description
This function takes a fitted model and uses it to make the post-policy predictions by simulating data.
Usage
extrapolate_model(
M0,
outcomename,
dat,
t0,
R = 400,
summarize = FALSE,
smooth = FALSE,
smoother = smooth_series,
full_output = FALSE,
fix_parameters = FALSE,
...
)
Arguments
M0 |
The fit model |
outcomename |
Outcome of interest (name of column) |
dat |
Dataframe with data being analyzed. |
t0 |
Last pre-policy timepoint |
R |
Number of replications |
summarize |
Boolean, TRUE means collapse all simulated trajectories into single aggregate. FALSE means return all paths. |
smooth |
Boolean. TRUE means fit a smoother to the trajectories and look at distribution of smoothed trajectories. FALSE means look at raw data treajectories. |
smoother |
Function to do smoothing, if smoothing set to TRUE. Default is smooth_series() |
full_output |
TRUE means smoother returns residuals as well as smoothed series. |
fix_parameters |
Keep the parameters in the model M0 as fixed; do not add parameter uncertainty. |
... |
Extra arguments to be passed to smoother (e.g, bandwidth). |
Value
Dataframe with columns corresponding to the simulations. If summarize=TRUE, one row per month in original data. If FALSE, all the details of all the runs are returned.
See Also
process_outcome_model
for wrapper function for this
method that is easier to use.
Examples
data("mecklenberg" )
mecklenberg = add_lagged_covariates( mecklenberg, "pbail" )
mecklenberg.pre = dplyr::filter( mecklenberg, month <= 0 )
M0 = fit_model_default( mecklenberg.pre, "pbail" )
res = extrapolate_model( M0, "pbail", mecklenberg, 0, 1,
smooth=TRUE)
tail( res )