make_many_predictions {simITS} | R Documentation |
Generate a collection of raw counterfactual trajectories
Description
Given a fit linear model 'fit0', generate R prediction series starting at t0. This takes model uncertainty into account by pulling from the pseudo-posterior of the model parameters (from Gelman and Hill arm package).
Usage
make_many_predictions(fit0, dat, R, outcomename, t0)
make_many_predictions_plug(fit0, dat, R, outcomename, t0)
Arguments
fit0 |
The fit linear model to simulate from. |
dat |
A dataframe with the covariates needed by the model fit0 for both pre and post-policy months. |
R |
Number of series to generate. |
outcomename |
The name of the column in dat which is our outcome. |
t0 |
Last month of pre-policy. Will start predicting at t0+1. |
Value
A data.frame with the collection of predicted series, one row per month per replicate (so will have R*nrow(dat) rows).
Functions
-
make_many_predictions_plug
: This version makes multiple predictions using estimated parameters without additional uncertainty. This takes point estimates from the fit model as fixed parameters. WARNING: This method will not capture true uncertainty as it is not taking parameter uncertainty into account.
References
The 'arm' package, see https://cran.r-project.org/package=arm
Also see Gelman, A., & Hill, J. (2007). Data analysis using regression and multilevelhierarchical models (Vol. 1). New York, NY, USA: Cambridge University Press.
Examples
data("mecklenberg" )
mecklenberg = add_lagged_covariates( mecklenberg, "pbail" )
mecklenberg.pre = dplyr::filter( mecklenberg, month <= 0 )
M0 = fit_model_default( mecklenberg.pre, "pbail" )
res = make_many_predictions( M0, dat=mecklenberg, outcome="pbail", t0=0, R=2 )
tail( res )