make_many_predictions: Generate a collection of raw counterfactual trajectories

Description Usage Arguments Value Functions References Examples

View source: R/ITSModelingCode.R

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

1
2
3
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

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

1
2
3
4
5
6
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 )

simITS documentation built on July 2, 2020, 4:10 a.m.