predict_aarr | R Documentation |
predict_aarr()
is a specific function designed to use annual average rate of
reduction (AARR) of prevalence data to forecast future prevalence. This is
particularly useful for forecasting future prevalence when there is not a full time
series available, but only a few data points for each series.
predict_aarr(
df,
response,
sort_col_min = NULL,
interpolate = FALSE,
ret = c("df", "all", "error", "model"),
scale = NULL,
probit = FALSE,
test_col = NULL,
test_period = NULL,
test_period_flex = NULL,
group_col = "iso3",
group_models = TRUE,
obs_filter = NULL,
sort_col = "year",
sort_descending = FALSE,
pred_col = "pred",
type_col = NULL,
types = c("imputed", "projected"),
source_col = NULL,
source = NULL,
scenario_detail_col = NULL,
scenario_detail = NULL,
replace_obs = c("missing", "all", "none")
)
df |
Data frame of model data. |
response |
Column name of prevalence variable to be used to calculate AARR. |
sort_col_min |
If provided, a numeric value that sets a minimum value needed
to be met in the |
interpolate |
Logical value, whether or not to interpolate values based on
estimated AARR between observations. Defaults to |
ret |
Character vector specifying what values the function returns. Defaults to returning a data frame, but can return a vector of model error, the model itself or a list with all 3 as components. |
scale |
Either |
probit |
Logical value on whether or not to probit transform the response
prior to model fitting. Probit transformation is performed after any scaling
determined by |
test_col |
Name of logical column specifying which response values to remove
for testing the model's predictive accuracy. If |
test_period |
Length of period to test for RMChE. If |
test_period_flex |
Logical value indicating if |
group_col |
Column name(s) of group(s) to use in |
group_models |
Logical, if |
obs_filter |
String value of the form " If `group_models = FALSE`, then `obs_filter` is only used to determine when predicted values replace observed values but **is not** used to restrict values from being used in model fitting. If `group_models = TRUE`, then a model is only fit for a group if they meet the `obs_filter` requirements. This provides speed benefits, particularly when running INLA time series using `predict_inla()`. |
sort_col |
Column name of column to arrange data by in |
sort_descending |
Logical value on whether the sorted values from |
pred_col |
Column name to store predicted value. |
type_col |
Column name specifying data type. |
types |
Types to add to missing values. The first value is for imputed values and the second is for extrapolated values. |
source_col |
Column name containing source information for the data frame.
If provided, the argument in |
source |
Source to add to missing values. |
scenario_detail_col |
Column name containing scenario_detail information
for the data frame. If provided, the argument in |
scenario_detail |
Scenario details to add to missing values (usually the name of the model being used to generate the projection, optionally with relevant parameters). |
replace_obs |
Character value specifying how, if at all, observations should be replaced by fitted values. Defaults to replacing only missing values, but can be used to replace all values or none. |
This function, in its current form, only forecast data from its last observed
data point, as AARR is not ideal for interpolation. In this case, the model
being returned by the function is a dataset of AARR values for each group (or
a single value if no grouped variables). No confidence bounds are generated
by predict_aarr()
.
Depending on the value passed to ret
, either a data frame with
predicted data, a vector of errors from model_error()
, a fitted model, or a list with all 3.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.