Add fits and residuals to the data, implementing the generic augment
from
the package broom.
Arguments
- x
An object of class
mvgam
.- robust
If
FALSE
(the default) the mean is used as the measure of central tendency and the standard deviation as the measure of variability. IfTRUE
, the median and the median absolute deviation (MAD) are applied instead.- probs
The percentiles to be computed by the quantile function.
- ...
Unused, included for generic consistency only.
Value
A list
or tibble
(see details) combining:
The data supplied to
mvgam()
.The outcome variable, named as
.observed
.The fitted backcasts, along with their variability and credible bounds.
The residuals, along with their variability and credible bounds.
Details
A list
is returned if class(x$obs_data) == 'list'
, otherwise a tibble
is
returned, but the contents of either object is the same.
The arguments robust
and probs
are applied to both the fit and
residuals calls (see fitted.mvgam()
and residuals.mvgam()
for details).
Examples
# \donttest{
set.seed(0)
dat <- sim_mvgam(T = 80,
n_series = 3,
mu = 2,
trend_model = AR(p = 1),
prop_missing = 0.1,
prop_trend = 0.6)
mod1 <- mvgam(formula = y ~ s(season, bs = 'cc', k = 6),
data = dat$data_train,
trend_model = AR(),
family = poisson(),
noncentred = TRUE,
chains = 2,
silent = 2)
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
#> from stan/lib/stan_math/stan/math/prim/prob/von_mises_ccdf_log.hpp:4,
#> from stan/lib/stan_math/stan/math/prim/prob.hpp:359,
#> from stan/lib/stan_math/stan/math/prim.hpp:16,
#> from stan/lib/stan_math/stan/math/rev.hpp:16,
#> from stan/lib/stan_math/stan/math.hpp:19,
#> from stan/src/stan/model/model_header.hpp:4,
#> from C:/Users/uqnclar2/AppData/Local/Temp/RtmpotLup8/model-9e8c7eb7bd2.hpp:2:
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp: In function 'stan::return_type_t<T_x, T_sigma, T_l> stan::math::von_mises_cdf(const T_x&, const T_mu&, const T_k&)':
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: '-Wmisleading-indentation' is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
#> 194 | if (cdf_n < 0.0)
#> |
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: adding '-flarge-source-files' will allow for more column-tracking support, at the expense of compilation time and memory
augment(mod1, robust = TRUE, probs = c(0.25, 0.75))
#> # A tibble: 180 × 14
#> y season year series time .observed .fitted .fit.variability
#> <int> <int> <int> <fct> <int> <int> <dbl> <dbl>
#> 1 4 1 1 series_1 1 4 4.47 2.91
#> 2 NA 1 1 series_2 1 NA 6.00 3.72
#> 3 4 1 1 series_3 1 4 4.38 2.99
#> 4 5 2 1 series_1 2 5 4.59 2.89
#> 5 2 2 1 series_2 2 2 3.53 3.42
#> 6 NA 2 1 series_3 2 NA 4.46 3.69
#> 7 7 3 1 series_1 3 7 8.11 3.87
#> 8 12 3 1 series_2 3 12 11.2 5.49
#> 9 4 3 1 series_3 3 4 5.14 2.89
#> 10 39 4 1 series_1 4 39 36.0 28.1
#> # ℹ 170 more rows
#> # ℹ 6 more variables: .fit.cred.low <dbl>, .fit.cred.high <dbl>, .resid <dbl>,
#> # .resid.variability <dbl>, .resid.cred.low <dbl>, .resid.cred.high <dbl>
# }