autoConverge {GPP}R Documentation

Checks Stan model for convergence, then runs model on actual data.

Description

Return a converged Stan model fit and the recommended noise level.

Usage

autoConverge(
  df,
  controlVars,
  nUntreated,
  obvColName,
  obvName,
  outcomeName,
  starttime,
  timeColName,
  filepath = NULL,
  ncores = NULL,
  iter = 25000,
  epsilon = 0.02,
  noise = 0.1,
  printMod = FALSE,
  shift = 0.05
)

Arguments

df

The dataframe used for the model.

controlVars

String of column names for control variables.

nUntreated

The number of untreated units in the model.

obvColName

The column name that includes the observation subject to the counterfactual.

obvName

The name of the observation subject to the counterfactual.

outcomeName

The outcome variable of interest.

starttime

The start time of the counterfactual estimation.

timeColName

The name of the column that includes the time variable.

filepath

Your preferred place to save the fit data. See Details.

ncores

The number of cores to be used to run the model. Default of NULL will utilize all cores.

iter

Preferred number of iterations. See details.

epsilon

The desired level of convergence, i.e. how close to the 0.95 coverage is acceptable.

noise

The baseline level of noise to be added to the model to prevent overfit. Updates as the model runs.

printMod

Boolean. Defaults FALSE. If TRUE, prints the model block for the run to the console. See details.

shift

The magnitude of adjustment for the noise level per iteration. Defaults to 0.05.

Details

We recommend creating a new folder for the file path since the Stan fit creates a large number of files at runtime.

For iterations, check that your model converged (we recommend all r-hats close to 1 and examining traceplots).

We recommend keeping printMod as FALSE, otherwise, the function will write the model to the console for every model run on the convergence.

We also recommend using all cores on your machine to speed up model run time. If you are unsure about the number of cores in your machine, see doParallel::detectCores().

Value

The recommended noise level after convergence.

Author(s)

Devin P. Brown devinpbrown96@gmail.com and David Carlson carlson.david@wustl.edu

See Also

plotGPPfit runMod GPP writeMod


[Package GPP version 0.1 Index]