In most of the
heemod vignettes models are defined through
R code. But models with large numbers of states and transition probabilities might be unwieldy to input at the keyboard, and could be conveniently specified by file inputs.
This vignette demonstrates how to make and use files to input models to
heemod. The files can then be used to run a suite of analyses (including deterministic and probabilistic sensitivity analyses, acceptability curve calculation, etc.) and optionally save results to a folder.
The inputs for state definition, transition matrices, model options, etc. (referenced as tabular inputs) must be provided via
xlsx files.1 Columns starting by
.comment are ignored, as well as blank rows.
These inputs must be provided in separate files. The path to these files is specified in a reference file, that acts as an ‘umbrella’ file atop of the other inputs. The reference file default name is
Warning for users of the
xls files are read with the
readxl package. As of version 0.1.1 if a column contains strings and numeric values the numeric values are rounded to 6 decimal places. We therefore recommend to use solely the
This file contains two mandatory columns
file, as well as optional columns with comments, which will be ignored. The
data column must contain the following keywords:
state: file containing model states.
tm: file containing transition probabilities.
parameters: file containing model parameters.
Optionally, the following rows can be provided:
options: file specifying model options.
demographics: file describing of the population to run the models on.
data: a directory containing additional tables to be loaded; these can be
output: a directory to save the output graphics.
source: a directory in which
Rsource files used in the analysis can be placed, and will be sourced when the model is run. The global environment is not modified.
All the files and directories must be in the reference file directory. Files or directories located elsewhere must be given by absolute path and marked by a
TRUE value in an optional
A state file contains 2 mandatory columns:
.state, corresponding to strategy and state names respectively. The other columns correspond to the state values.
Discounting rates can be specified in
.discount.* columns, where
* stands for the name of the value to discount. Values are always discounted at the same rate in all states.2
Values specified for only one strategy will be carried over to others. Only values that differ from one strategy to another must be specified separately for each strategy.
State values that do not change between models need only be specified once (such as all states except
PrimaryTHR in the
new model) and will automatically be repeated between models.
A transition probabilities file contains 4 columns:
.model: strategy name.
from: initial state.
to: end state.
prob: transition probability from initial state to end state.
A probability can be defined by any expression: a number,
C, a different parameter name (specified in the parameter file), or a function call.
As with the state file above probabilities specified for only one strategy will be carried over to others. Only probabilities that differ from one strategy to another must be specified separately for each strategy. Unspecified transition probabilities are assumed to be 0.
A parameter file contains 2 mandatory columns: the parameter names
parameter and the values
Optional columns can be added to perform determinist or probabilist sensitivity analysis (DSA and PSA).
high columns specify the lower and upper bounds of parameter values for DSA, while
psa contains the parameter distribution for PSA.
A parameter can be specified as any expression: as a number, through a previously defined parameter, with a mathematical formula or a function call.
look_up() function can be used to look up parameter values in external reference tables (see section User-defined data), if a
data argument is given in the reference file (as for the
mr parameter in the above example).
Sometimes external data is required for an analysis (e.g. age-specific mortality rates). A
data row in the reference file specifies a subdirectory containing data frames to be loaded (saved as
xlsx files). Multiple files can be placed here, and each filename (without the extension) is used as the dataframe name.3
Models specified by tabular input will run with defaults options. The following options can be specified in a non-mandatory
effect: values to be used as cost and effect.
initcomma separated starting values.
method: counting method.
base: name of base model.
cycles: run the model for how many cycles?
n: number of resample for PSA.
num_core: number of cluster cores.
The entire set of analysis specified in the tabular files can be run by the function
<- run_model_tabular( result location = system.file("tabular/thr", package = "heemod") )
The results can then be interpreted as usual.
$model_runs resultplot(result$psa, type = "ce") plot(result$dsa, result = "cost", strategy = "new") $demographicsresult
; separator) are not supported.↩︎
A single discount rate can be duplicated across states, or specified in one state and left blank elsewhere. Specifying two different discount rates for a single variable in different states will cause an error.↩︎
Having multiple files with the same base name but different extensions in the directory will cause an error.↩︎