Fit a linear or GAM model to RoC scores and return the fitted values.
Usage
make_trend(data_source, sel_method = c("linear", "non_linear"), silent = FALSE)Arguments
- data_source
data.framewith columnsROCandAge.- sel_method
character. Which trend to fit:"linear"- a linear model fitted between RoC and age."non_linear"- a conservative GAM (RoC ~ s(age, k = 3)) using themgcvpackage.
- silent
logical. IfTRUE, do not warn about RoC values of zero (default =FALSE).
Details
Both trends assume a Gamma distribution of RoC (Tweedie with power 2)
with a log link, which is defined only for values above zero. RoC values
of zero are therefore replaced, for the fit only, by half of the
smallest RoC value above zero (see util_replace_zero_roc()), with a
warning unless silent = TRUE.
ROC must not contain NA, because the fitted values must match the
rows of data_source; remove such rows first (see
util_skip_na_roc()).
