Approximate leave-future-out cross-validation of fitted mvgam
objects
+ Approximate leave-future-out cross-validation of fitted mvgam
objects
Source: R/lfo_cv.mvgam.R
lfo_cv.mvgam.Rd
Examples newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -201,7 +202,8 @@ Examples newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -217,10 +219,12 @@ Examples# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/docs/reference/loo.mvgam-1.png b/docs/reference/loo.mvgam-1.png
index 41070110..2c2aff89 100644
Binary files a/docs/reference/loo.mvgam-1.png and b/docs/reference/loo.mvgam-1.png differ
diff --git a/docs/reference/loo.mvgam-2.png b/docs/reference/loo.mvgam-2.png
index ae40aeba..17599ad9 100644
Binary files a/docs/reference/loo.mvgam-2.png and b/docs/reference/loo.mvgam-2.png differ
diff --git a/docs/reference/loo.mvgam-3.png b/docs/reference/loo.mvgam-3.png
index 7939f149..ec9d50e3 100644
Binary files a/docs/reference/loo.mvgam-3.png and b/docs/reference/loo.mvgam-3.png differ
diff --git a/docs/reference/loo.mvgam-4.png b/docs/reference/loo.mvgam-4.png
index 719bce1a..706d040d 100644
Binary files a/docs/reference/loo.mvgam-4.png and b/docs/reference/loo.mvgam-4.png differ
diff --git a/docs/reference/loo.mvgam-5.png b/docs/reference/loo.mvgam-5.png
index 7efd656e..6a45504e 100644
Binary files a/docs/reference/loo.mvgam-5.png and b/docs/reference/loo.mvgam-5.png differ
diff --git a/docs/reference/loo.mvgam-6.png b/docs/reference/loo.mvgam-6.png
index 52c735d8..adcbeb61 100644
Binary files a/docs/reference/loo.mvgam-6.png and b/docs/reference/loo.mvgam-6.png differ
diff --git a/docs/reference/loo.mvgam-7.png b/docs/reference/loo.mvgam-7.png
index e1c28134..6c4bc345 100644
Binary files a/docs/reference/loo.mvgam-7.png and b/docs/reference/loo.mvgam-7.png differ
diff --git a/docs/reference/loo.mvgam.html b/docs/reference/loo.mvgam.html
index 053e8ed0..bc9ab038 100644
--- a/docs/reference/loo.mvgam.html
+++ b/docs/reference/loo.mvgam.html
@@ -148,43 +148,21 @@ Examples data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.7 seconds.
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.7 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 0.7 seconds.
-#> Total execution time: 1.1 seconds.
-#>
+ 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/RtmpqqsueL/model-19b8407b5d02.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
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -196,12 +174,12 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -363.8 11.1
-#> p_loo 7.0 0.6
-#> looic 727.6 22.1
+#> elpd_loo -364.2 11.1
+#> p_loo 7.4 0.6
+#> looic 728.4 22.1
#> ------
#> MCSE of elpd_loo is 0.1.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.9, 1.9]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.7, 2.3]).
#>
#> All Pareto k estimates are good (k < 0.67).
#> See help('pareto-k-diagnostic') for details.
@@ -211,46 +189,24 @@ Examples formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.3 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.6 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 2.5 seconds.
-#> Total execution time: 2.8 seconds.
-#>
+#> 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/RtmpqqsueL/model-19b830efb18.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
conditional_effects(mod2)
@@ -259,12 +215,12 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -309.4 11.4
-#> p_loo 12.9 1.0
-#> looic 618.8 22.7
+#> elpd_loo -309.7 11.4
+#> p_loo 13.3 1.1
+#> looic 619.5 22.8
#> ------
#> MCSE of elpd_loo is 0.1.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.6, 1.2]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.7, 1.3]).
#>
#> All Pareto k estimates are good (k < 0.67).
#> See help('pareto-k-diagnostic') for details.
@@ -272,47 +228,24 @@ Examples# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
-#> Your model may benefit from using "noncentred = TRUE"
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 10.1 seconds.
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 14.6 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 12.4 seconds.
-#> Total execution time: 14.8 seconds.
-#>
+#> 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/RtmpqqsueL/model-19b84ce92891.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
conditional_effects(mod3)
@@ -324,18 +257,18 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -261.8 10.1
-#> p_loo 155.4 7.0
-#> looic 523.7 20.3
+#> elpd_loo -251.0 9.9
+#> p_loo 163.6 7.1
+#> looic 502.0 19.9
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.1]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.0]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 151 50.3% 1
-#> (0.67, 1] (bad) 142 47.3% <NA>
-#> (1, Inf) (very bad) 7 2.3% <NA>
+#> (-Inf, 0.67] (good) 127 42.3% 1
+#> (0.67, 1] (bad) 160 53.3% <NA>
+#> (1, Inf) (very bad) 13 4.3% <NA>
#> See help('pareto-k-diagnostic') for details.
# Compare models using LOO
@@ -343,8 +276,8 @@ Examples#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#> elpd_diff se_diff
#> mod3 0.0 0.0
-#> mod2 -47.6 4.3
-#> mod1 -101.9 9.1
+#> mod2 -58.7 4.8
+#> mod1 -113.2 9.3
options(mc.cores = mc.cores.def)
# Compare forecast abilities using an expanding training window and
@@ -358,39 +291,52 @@ Examples#> Warning: model has repeated 1-d smooths of same variable.
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b824896df3.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 1.0 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 1.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.2 seconds.
+#> Chain 2 finished in 1.2 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 2.0 seconds.
-#> Total execution time: 2.4 seconds.
+#> Mean chain execution time: 1.1 seconds.
+#> Total execution time: 1.3 seconds.
#>
lfo_mod3 <- lfo_cv(mod3, min_t = 92)
#> Warning: model has repeated 1-d smooths of same variable.
@@ -399,39 +345,52 @@ Examples#> Your model may benefit from using "noncentred = TRUE"
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b85d765643.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 12.8 seconds.
+#> Chain 2 finished in 6.6 seconds.
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 36.4 seconds.
+#> Chain 1 finished in 11.1 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 24.6 seconds.
-#> Total execution time: 36.7 seconds.
+#> Mean chain execution time: 8.8 seconds.
+#> Total execution time: 11.1 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -446,32 +405,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 17.0 seconds.
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 21.1 seconds.
+#> Chain 2 finished in 7.0 seconds.
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 7.9 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 19.1 seconds.
-#> Total execution time: 21.5 seconds.
+#> Mean chain execution time: 7.4 seconds.
+#> Total execution time: 7.9 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -486,32 +445,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 8.8 seconds.
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 24.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 25.4 seconds.
+#> Chain 2 finished in 25.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 25.2 seconds.
-#> Total execution time: 25.7 seconds.
+#> Mean chain execution time: 16.9 seconds.
+#> Total execution time: 25.2 seconds.
#>
# Take the difference in forecast ELPDs; a model with higher ELPD is preferred,
diff --git a/docs/reference/mvgam-1.png b/docs/reference/mvgam-1.png
index e328ce49..430cb723 100644
Binary files a/docs/reference/mvgam-1.png and b/docs/reference/mvgam-1.png differ
diff --git a/docs/reference/mvgam-10.png b/docs/reference/mvgam-10.png
index 65d6b581..2eaa0a02 100644
Binary files a/docs/reference/mvgam-10.png and b/docs/reference/mvgam-10.png differ
diff --git a/docs/reference/mvgam-11.png b/docs/reference/mvgam-11.png
index 61b0cff8..93b6a939 100644
Binary files a/docs/reference/mvgam-11.png and b/docs/reference/mvgam-11.png differ
diff --git a/docs/reference/mvgam-12.png b/docs/reference/mvgam-12.png
index 12c720a1..6153dd79 100644
Binary files a/docs/reference/mvgam-12.png and b/docs/reference/mvgam-12.png differ
diff --git a/docs/reference/mvgam-13.png b/docs/reference/mvgam-13.png
index 9db19eac..b18d849a 100644
Binary files a/docs/reference/mvgam-13.png and b/docs/reference/mvgam-13.png differ
diff --git a/docs/reference/mvgam-14.png b/docs/reference/mvgam-14.png
index 4fbfac7e..b7a6d24e 100644
Binary files a/docs/reference/mvgam-14.png and b/docs/reference/mvgam-14.png differ
diff --git a/docs/reference/mvgam-15.png b/docs/reference/mvgam-15.png
index 53c22aa9..274fc0c4 100644
Binary files a/docs/reference/mvgam-15.png and b/docs/reference/mvgam-15.png differ
diff --git a/docs/reference/mvgam-16.png b/docs/reference/mvgam-16.png
index 3eec9485..a580b628 100644
Binary files a/docs/reference/mvgam-16.png and b/docs/reference/mvgam-16.png differ
diff --git a/docs/reference/mvgam-18.png b/docs/reference/mvgam-18.png
index 3fe344b1..d57a4a5c 100644
Binary files a/docs/reference/mvgam-18.png and b/docs/reference/mvgam-18.png differ
diff --git a/docs/reference/mvgam-19.png b/docs/reference/mvgam-19.png
index 409f7c0d..0d9c672a 100644
Binary files a/docs/reference/mvgam-19.png and b/docs/reference/mvgam-19.png differ
diff --git a/docs/reference/mvgam-2.png b/docs/reference/mvgam-2.png
index b05f9ef4..8a176cf1 100644
Binary files a/docs/reference/mvgam-2.png and b/docs/reference/mvgam-2.png differ
diff --git a/docs/reference/mvgam-20.png b/docs/reference/mvgam-20.png
index 119662eb..cde55640 100644
Binary files a/docs/reference/mvgam-20.png and b/docs/reference/mvgam-20.png differ
diff --git a/docs/reference/mvgam-21.png b/docs/reference/mvgam-21.png
index c4f5049a..7f27ab77 100644
Binary files a/docs/reference/mvgam-21.png and b/docs/reference/mvgam-21.png differ
diff --git a/docs/reference/mvgam-22.png b/docs/reference/mvgam-22.png
index bb509d3a..0257cdd7 100644
Binary files a/docs/reference/mvgam-22.png and b/docs/reference/mvgam-22.png differ
diff --git a/docs/reference/mvgam-23.png b/docs/reference/mvgam-23.png
index 19fad5cb..c2c65dea 100644
Binary files a/docs/reference/mvgam-23.png and b/docs/reference/mvgam-23.png differ
diff --git a/docs/reference/mvgam-24.png b/docs/reference/mvgam-24.png
index b0639411..6c761a3a 100644
Binary files a/docs/reference/mvgam-24.png and b/docs/reference/mvgam-24.png differ
diff --git a/docs/reference/mvgam-25.png b/docs/reference/mvgam-25.png
index 36440c7e..89492454 100644
Binary files a/docs/reference/mvgam-25.png and b/docs/reference/mvgam-25.png differ
diff --git a/docs/reference/mvgam-26.png b/docs/reference/mvgam-26.png
index 2294aba4..b47b23d5 100644
Binary files a/docs/reference/mvgam-26.png and b/docs/reference/mvgam-26.png differ
diff --git a/docs/reference/mvgam-27.png b/docs/reference/mvgam-27.png
index 7ba58fa4..3d338ca8 100644
Binary files a/docs/reference/mvgam-27.png and b/docs/reference/mvgam-27.png differ
diff --git a/docs/reference/mvgam-28.png b/docs/reference/mvgam-28.png
index 31295326..626f5d23 100644
Binary files a/docs/reference/mvgam-28.png and b/docs/reference/mvgam-28.png differ
diff --git a/docs/reference/mvgam-3.png b/docs/reference/mvgam-3.png
index fe800df7..189c670a 100644
Binary files a/docs/reference/mvgam-3.png and b/docs/reference/mvgam-3.png differ
diff --git a/docs/reference/mvgam-4.png b/docs/reference/mvgam-4.png
index 3e996752..a556ce01 100644
Binary files a/docs/reference/mvgam-4.png and b/docs/reference/mvgam-4.png differ
diff --git a/docs/reference/mvgam-5.png b/docs/reference/mvgam-5.png
index 57ff823d..67abe00d 100644
Binary files a/docs/reference/mvgam-5.png and b/docs/reference/mvgam-5.png differ
diff --git a/docs/reference/mvgam-6.png b/docs/reference/mvgam-6.png
index c3ee394b..8218f902 100644
Binary files a/docs/reference/mvgam-6.png and b/docs/reference/mvgam-6.png differ
diff --git a/docs/reference/mvgam-7.png b/docs/reference/mvgam-7.png
index 12389767..95d23a12 100644
Binary files a/docs/reference/mvgam-7.png and b/docs/reference/mvgam-7.png differ
diff --git a/docs/reference/mvgam-8.png b/docs/reference/mvgam-8.png
index d50d67c1..f17f71c8 100644
Binary files a/docs/reference/mvgam-8.png and b/docs/reference/mvgam-8.png differ
diff --git a/docs/reference/mvgam-9.png b/docs/reference/mvgam-9.png
index 4f70efb2..195031df 100644
Binary files a/docs/reference/mvgam-9.png and b/docs/reference/mvgam-9.png differ
diff --git a/docs/reference/mvgam.html b/docs/reference/mvgam.html
index e902ed33..7d1df4e9 100644
--- a/docs/reference/mvgam.html
+++ b/docs/reference/mvgam.html
@@ -116,8 +116,8 @@ Usage
algorithm = getOption("brms.algorithm", "sampling"),
autoformat = TRUE,
save_all_pars = FALSE,
- max_treedepth = 12,
- adapt_delta = 0.85,
+ max_treedepth = 10,
+ adapt_delta = 0.8,
silent = 1,
jags_path,
...
@@ -418,7 +418,7 @@ ArgumentsExamplessdata1 <- standata(mod1)
str(sdata1)
#> List of 18
-#> $ y : num [1:60, 1:3] 12 17 12 31 30 8 0 1 3 5 ...
+#> $ y : num [1:60, 1:3] 4 5 7 39 51 26 6 6 4 2 ...
#> $ n : int 60
#> $ X : num [1:180, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
@@ -712,7 +712,7 @@ Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/docs/reference/loo.mvgam-1.png b/docs/reference/loo.mvgam-1.png
index 41070110..2c2aff89 100644
Binary files a/docs/reference/loo.mvgam-1.png and b/docs/reference/loo.mvgam-1.png differ
diff --git a/docs/reference/loo.mvgam-2.png b/docs/reference/loo.mvgam-2.png
index ae40aeba..17599ad9 100644
Binary files a/docs/reference/loo.mvgam-2.png and b/docs/reference/loo.mvgam-2.png differ
diff --git a/docs/reference/loo.mvgam-3.png b/docs/reference/loo.mvgam-3.png
index 7939f149..ec9d50e3 100644
Binary files a/docs/reference/loo.mvgam-3.png and b/docs/reference/loo.mvgam-3.png differ
diff --git a/docs/reference/loo.mvgam-4.png b/docs/reference/loo.mvgam-4.png
index 719bce1a..706d040d 100644
Binary files a/docs/reference/loo.mvgam-4.png and b/docs/reference/loo.mvgam-4.png differ
diff --git a/docs/reference/loo.mvgam-5.png b/docs/reference/loo.mvgam-5.png
index 7efd656e..6a45504e 100644
Binary files a/docs/reference/loo.mvgam-5.png and b/docs/reference/loo.mvgam-5.png differ
diff --git a/docs/reference/loo.mvgam-6.png b/docs/reference/loo.mvgam-6.png
index 52c735d8..adcbeb61 100644
Binary files a/docs/reference/loo.mvgam-6.png and b/docs/reference/loo.mvgam-6.png differ
diff --git a/docs/reference/loo.mvgam-7.png b/docs/reference/loo.mvgam-7.png
index e1c28134..6c4bc345 100644
Binary files a/docs/reference/loo.mvgam-7.png and b/docs/reference/loo.mvgam-7.png differ
diff --git a/docs/reference/loo.mvgam.html b/docs/reference/loo.mvgam.html
index 053e8ed0..bc9ab038 100644
--- a/docs/reference/loo.mvgam.html
+++ b/docs/reference/loo.mvgam.html
@@ -148,43 +148,21 @@ Examples data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.7 seconds.
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.7 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 0.7 seconds.
-#> Total execution time: 1.1 seconds.
-#>
+ 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/RtmpqqsueL/model-19b8407b5d02.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
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -196,12 +174,12 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -363.8 11.1
-#> p_loo 7.0 0.6
-#> looic 727.6 22.1
+#> elpd_loo -364.2 11.1
+#> p_loo 7.4 0.6
+#> looic 728.4 22.1
#> ------
#> MCSE of elpd_loo is 0.1.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.9, 1.9]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.7, 2.3]).
#>
#> All Pareto k estimates are good (k < 0.67).
#> See help('pareto-k-diagnostic') for details.
@@ -211,46 +189,24 @@ Examples formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.3 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.6 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 2.5 seconds.
-#> Total execution time: 2.8 seconds.
-#>
+#> 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/RtmpqqsueL/model-19b830efb18.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
conditional_effects(mod2)
@@ -259,12 +215,12 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -309.4 11.4
-#> p_loo 12.9 1.0
-#> looic 618.8 22.7
+#> elpd_loo -309.7 11.4
+#> p_loo 13.3 1.1
+#> looic 619.5 22.8
#> ------
#> MCSE of elpd_loo is 0.1.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.6, 1.2]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.7, 1.3]).
#>
#> All Pareto k estimates are good (k < 0.67).
#> See help('pareto-k-diagnostic') for details.
@@ -272,47 +228,24 @@ Examples# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
-#> Your model may benefit from using "noncentred = TRUE"
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 10.1 seconds.
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 14.6 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 12.4 seconds.
-#> Total execution time: 14.8 seconds.
-#>
+#> 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/RtmpqqsueL/model-19b84ce92891.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
conditional_effects(mod3)
@@ -324,18 +257,18 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -261.8 10.1
-#> p_loo 155.4 7.0
-#> looic 523.7 20.3
+#> elpd_loo -251.0 9.9
+#> p_loo 163.6 7.1
+#> looic 502.0 19.9
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.1]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.0]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 151 50.3% 1
-#> (0.67, 1] (bad) 142 47.3% <NA>
-#> (1, Inf) (very bad) 7 2.3% <NA>
+#> (-Inf, 0.67] (good) 127 42.3% 1
+#> (0.67, 1] (bad) 160 53.3% <NA>
+#> (1, Inf) (very bad) 13 4.3% <NA>
#> See help('pareto-k-diagnostic') for details.
# Compare models using LOO
@@ -343,8 +276,8 @@ Examples#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#> elpd_diff se_diff
#> mod3 0.0 0.0
-#> mod2 -47.6 4.3
-#> mod1 -101.9 9.1
+#> mod2 -58.7 4.8
+#> mod1 -113.2 9.3
options(mc.cores = mc.cores.def)
# Compare forecast abilities using an expanding training window and
@@ -358,39 +291,52 @@ Examples#> Warning: model has repeated 1-d smooths of same variable.
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b824896df3.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 1.0 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 1.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.2 seconds.
+#> Chain 2 finished in 1.2 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 2.0 seconds.
-#> Total execution time: 2.4 seconds.
+#> Mean chain execution time: 1.1 seconds.
+#> Total execution time: 1.3 seconds.
#>
lfo_mod3 <- lfo_cv(mod3, min_t = 92)
#> Warning: model has repeated 1-d smooths of same variable.
@@ -399,39 +345,52 @@ Examples#> Your model may benefit from using "noncentred = TRUE"
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b85d765643.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 12.8 seconds.
+#> Chain 2 finished in 6.6 seconds.
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 36.4 seconds.
+#> Chain 1 finished in 11.1 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 24.6 seconds.
-#> Total execution time: 36.7 seconds.
+#> Mean chain execution time: 8.8 seconds.
+#> Total execution time: 11.1 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -446,32 +405,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 17.0 seconds.
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 21.1 seconds.
+#> Chain 2 finished in 7.0 seconds.
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 7.9 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 19.1 seconds.
-#> Total execution time: 21.5 seconds.
+#> Mean chain execution time: 7.4 seconds.
+#> Total execution time: 7.9 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -486,32 +445,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 8.8 seconds.
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 24.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 25.4 seconds.
+#> Chain 2 finished in 25.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 25.2 seconds.
-#> Total execution time: 25.7 seconds.
+#> Mean chain execution time: 16.9 seconds.
+#> Total execution time: 25.2 seconds.
#>
# Take the difference in forecast ELPDs; a model with higher ELPD is preferred,
diff --git a/docs/reference/mvgam-1.png b/docs/reference/mvgam-1.png
index e328ce49..430cb723 100644
Binary files a/docs/reference/mvgam-1.png and b/docs/reference/mvgam-1.png differ
diff --git a/docs/reference/mvgam-10.png b/docs/reference/mvgam-10.png
index 65d6b581..2eaa0a02 100644
Binary files a/docs/reference/mvgam-10.png and b/docs/reference/mvgam-10.png differ
diff --git a/docs/reference/mvgam-11.png b/docs/reference/mvgam-11.png
index 61b0cff8..93b6a939 100644
Binary files a/docs/reference/mvgam-11.png and b/docs/reference/mvgam-11.png differ
diff --git a/docs/reference/mvgam-12.png b/docs/reference/mvgam-12.png
index 12c720a1..6153dd79 100644
Binary files a/docs/reference/mvgam-12.png and b/docs/reference/mvgam-12.png differ
diff --git a/docs/reference/mvgam-13.png b/docs/reference/mvgam-13.png
index 9db19eac..b18d849a 100644
Binary files a/docs/reference/mvgam-13.png and b/docs/reference/mvgam-13.png differ
diff --git a/docs/reference/mvgam-14.png b/docs/reference/mvgam-14.png
index 4fbfac7e..b7a6d24e 100644
Binary files a/docs/reference/mvgam-14.png and b/docs/reference/mvgam-14.png differ
diff --git a/docs/reference/mvgam-15.png b/docs/reference/mvgam-15.png
index 53c22aa9..274fc0c4 100644
Binary files a/docs/reference/mvgam-15.png and b/docs/reference/mvgam-15.png differ
diff --git a/docs/reference/mvgam-16.png b/docs/reference/mvgam-16.png
index 3eec9485..a580b628 100644
Binary files a/docs/reference/mvgam-16.png and b/docs/reference/mvgam-16.png differ
diff --git a/docs/reference/mvgam-18.png b/docs/reference/mvgam-18.png
index 3fe344b1..d57a4a5c 100644
Binary files a/docs/reference/mvgam-18.png and b/docs/reference/mvgam-18.png differ
diff --git a/docs/reference/mvgam-19.png b/docs/reference/mvgam-19.png
index 409f7c0d..0d9c672a 100644
Binary files a/docs/reference/mvgam-19.png and b/docs/reference/mvgam-19.png differ
diff --git a/docs/reference/mvgam-2.png b/docs/reference/mvgam-2.png
index b05f9ef4..8a176cf1 100644
Binary files a/docs/reference/mvgam-2.png and b/docs/reference/mvgam-2.png differ
diff --git a/docs/reference/mvgam-20.png b/docs/reference/mvgam-20.png
index 119662eb..cde55640 100644
Binary files a/docs/reference/mvgam-20.png and b/docs/reference/mvgam-20.png differ
diff --git a/docs/reference/mvgam-21.png b/docs/reference/mvgam-21.png
index c4f5049a..7f27ab77 100644
Binary files a/docs/reference/mvgam-21.png and b/docs/reference/mvgam-21.png differ
diff --git a/docs/reference/mvgam-22.png b/docs/reference/mvgam-22.png
index bb509d3a..0257cdd7 100644
Binary files a/docs/reference/mvgam-22.png and b/docs/reference/mvgam-22.png differ
diff --git a/docs/reference/mvgam-23.png b/docs/reference/mvgam-23.png
index 19fad5cb..c2c65dea 100644
Binary files a/docs/reference/mvgam-23.png and b/docs/reference/mvgam-23.png differ
diff --git a/docs/reference/mvgam-24.png b/docs/reference/mvgam-24.png
index b0639411..6c761a3a 100644
Binary files a/docs/reference/mvgam-24.png and b/docs/reference/mvgam-24.png differ
diff --git a/docs/reference/mvgam-25.png b/docs/reference/mvgam-25.png
index 36440c7e..89492454 100644
Binary files a/docs/reference/mvgam-25.png and b/docs/reference/mvgam-25.png differ
diff --git a/docs/reference/mvgam-26.png b/docs/reference/mvgam-26.png
index 2294aba4..b47b23d5 100644
Binary files a/docs/reference/mvgam-26.png and b/docs/reference/mvgam-26.png differ
diff --git a/docs/reference/mvgam-27.png b/docs/reference/mvgam-27.png
index 7ba58fa4..3d338ca8 100644
Binary files a/docs/reference/mvgam-27.png and b/docs/reference/mvgam-27.png differ
diff --git a/docs/reference/mvgam-28.png b/docs/reference/mvgam-28.png
index 31295326..626f5d23 100644
Binary files a/docs/reference/mvgam-28.png and b/docs/reference/mvgam-28.png differ
diff --git a/docs/reference/mvgam-3.png b/docs/reference/mvgam-3.png
index fe800df7..189c670a 100644
Binary files a/docs/reference/mvgam-3.png and b/docs/reference/mvgam-3.png differ
diff --git a/docs/reference/mvgam-4.png b/docs/reference/mvgam-4.png
index 3e996752..a556ce01 100644
Binary files a/docs/reference/mvgam-4.png and b/docs/reference/mvgam-4.png differ
diff --git a/docs/reference/mvgam-5.png b/docs/reference/mvgam-5.png
index 57ff823d..67abe00d 100644
Binary files a/docs/reference/mvgam-5.png and b/docs/reference/mvgam-5.png differ
diff --git a/docs/reference/mvgam-6.png b/docs/reference/mvgam-6.png
index c3ee394b..8218f902 100644
Binary files a/docs/reference/mvgam-6.png and b/docs/reference/mvgam-6.png differ
diff --git a/docs/reference/mvgam-7.png b/docs/reference/mvgam-7.png
index 12389767..95d23a12 100644
Binary files a/docs/reference/mvgam-7.png and b/docs/reference/mvgam-7.png differ
diff --git a/docs/reference/mvgam-8.png b/docs/reference/mvgam-8.png
index d50d67c1..f17f71c8 100644
Binary files a/docs/reference/mvgam-8.png and b/docs/reference/mvgam-8.png differ
diff --git a/docs/reference/mvgam-9.png b/docs/reference/mvgam-9.png
index 4f70efb2..195031df 100644
Binary files a/docs/reference/mvgam-9.png and b/docs/reference/mvgam-9.png differ
diff --git a/docs/reference/mvgam.html b/docs/reference/mvgam.html
index e902ed33..7d1df4e9 100644
--- a/docs/reference/mvgam.html
+++ b/docs/reference/mvgam.html
@@ -116,8 +116,8 @@ Usage
algorithm = getOption("brms.algorithm", "sampling"),
autoformat = TRUE,
save_all_pars = FALSE,
- max_treedepth = 12,
- adapt_delta = 0.85,
+ max_treedepth = 10,
+ adapt_delta = 0.8,
silent = 1,
jags_path,
...
@@ -418,7 +418,7 @@ ArgumentsExamplessdata1 <- standata(mod1)
str(sdata1)
#> List of 18
-#> $ y : num [1:60, 1:3] 12 17 12 31 30 8 0 1 3 5 ...
+#> $ y : num [1:60, 1:3] 4 5 7 39 51 26 6 6 4 2 ...
#> $ n : int 60
#> $ X : num [1:180, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
@@ -712,7 +712,7 @@ Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -363.8 11.1
-#> p_loo 7.0 0.6
-#> looic 727.6 22.1
+#> elpd_loo -364.2 11.1
+#> p_loo 7.4 0.6
+#> looic 728.4 22.1
#> ------
#> MCSE of elpd_loo is 0.1.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.9, 1.9]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.7, 2.3]).
#>
#> All Pareto k estimates are good (k < 0.67).
#> See help('pareto-k-diagnostic') for details.
@@ -211,46 +189,24 @@ Examples formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.3 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.6 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 2.5 seconds.
-#> Total execution time: 2.8 seconds.
-#>
+#> 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/RtmpqqsueL/model-19b830efb18.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
conditional_effects(mod2)
@@ -259,12 +215,12 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -309.4 11.4
-#> p_loo 12.9 1.0
-#> looic 618.8 22.7
+#> elpd_loo -309.7 11.4
+#> p_loo 13.3 1.1
+#> looic 619.5 22.8
#> ------
#> MCSE of elpd_loo is 0.1.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.6, 1.2]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.7, 1.3]).
#>
#> All Pareto k estimates are good (k < 0.67).
#> See help('pareto-k-diagnostic') for details.
@@ -272,47 +228,24 @@ Examples# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
-#> Your model may benefit from using "noncentred = TRUE"
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 10.1 seconds.
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 14.6 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 12.4 seconds.
-#> Total execution time: 14.8 seconds.
-#>
+#> 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/RtmpqqsueL/model-19b84ce92891.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
conditional_effects(mod3)
@@ -324,18 +257,18 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -261.8 10.1
-#> p_loo 155.4 7.0
-#> looic 523.7 20.3
+#> elpd_loo -251.0 9.9
+#> p_loo 163.6 7.1
+#> looic 502.0 19.9
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.1]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.0]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 151 50.3% 1
-#> (0.67, 1] (bad) 142 47.3% <NA>
-#> (1, Inf) (very bad) 7 2.3% <NA>
+#> (-Inf, 0.67] (good) 127 42.3% 1
+#> (0.67, 1] (bad) 160 53.3% <NA>
+#> (1, Inf) (very bad) 13 4.3% <NA>
#> See help('pareto-k-diagnostic') for details.
# Compare models using LOO
@@ -343,8 +276,8 @@ Examples#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#> elpd_diff se_diff
#> mod3 0.0 0.0
-#> mod2 -47.6 4.3
-#> mod1 -101.9 9.1
+#> mod2 -58.7 4.8
+#> mod1 -113.2 9.3
options(mc.cores = mc.cores.def)
# Compare forecast abilities using an expanding training window and
@@ -358,39 +291,52 @@ Examples#> Warning: model has repeated 1-d smooths of same variable.
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b824896df3.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 1.0 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 1.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.2 seconds.
+#> Chain 2 finished in 1.2 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 2.0 seconds.
-#> Total execution time: 2.4 seconds.
+#> Mean chain execution time: 1.1 seconds.
+#> Total execution time: 1.3 seconds.
#>
lfo_mod3 <- lfo_cv(mod3, min_t = 92)
#> Warning: model has repeated 1-d smooths of same variable.
@@ -399,39 +345,52 @@ Examples#> Your model may benefit from using "noncentred = TRUE"
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b85d765643.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 12.8 seconds.
+#> Chain 2 finished in 6.6 seconds.
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 36.4 seconds.
+#> Chain 1 finished in 11.1 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 24.6 seconds.
-#> Total execution time: 36.7 seconds.
+#> Mean chain execution time: 8.8 seconds.
+#> Total execution time: 11.1 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -446,32 +405,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 17.0 seconds.
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 21.1 seconds.
+#> Chain 2 finished in 7.0 seconds.
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 7.9 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 19.1 seconds.
-#> Total execution time: 21.5 seconds.
+#> Mean chain execution time: 7.4 seconds.
+#> Total execution time: 7.9 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -486,32 +445,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 8.8 seconds.
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 24.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 25.4 seconds.
+#> Chain 2 finished in 25.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 25.2 seconds.
-#> Total execution time: 25.7 seconds.
+#> Mean chain execution time: 16.9 seconds.
+#> Total execution time: 25.2 seconds.
#>
# Take the difference in forecast ELPDs; a model with higher ELPD is preferred,
diff --git a/docs/reference/mvgam-1.png b/docs/reference/mvgam-1.png
index e328ce49..430cb723 100644
Binary files a/docs/reference/mvgam-1.png and b/docs/reference/mvgam-1.png differ
diff --git a/docs/reference/mvgam-10.png b/docs/reference/mvgam-10.png
index 65d6b581..2eaa0a02 100644
Binary files a/docs/reference/mvgam-10.png and b/docs/reference/mvgam-10.png differ
diff --git a/docs/reference/mvgam-11.png b/docs/reference/mvgam-11.png
index 61b0cff8..93b6a939 100644
Binary files a/docs/reference/mvgam-11.png and b/docs/reference/mvgam-11.png differ
diff --git a/docs/reference/mvgam-12.png b/docs/reference/mvgam-12.png
index 12c720a1..6153dd79 100644
Binary files a/docs/reference/mvgam-12.png and b/docs/reference/mvgam-12.png differ
diff --git a/docs/reference/mvgam-13.png b/docs/reference/mvgam-13.png
index 9db19eac..b18d849a 100644
Binary files a/docs/reference/mvgam-13.png and b/docs/reference/mvgam-13.png differ
diff --git a/docs/reference/mvgam-14.png b/docs/reference/mvgam-14.png
index 4fbfac7e..b7a6d24e 100644
Binary files a/docs/reference/mvgam-14.png and b/docs/reference/mvgam-14.png differ
diff --git a/docs/reference/mvgam-15.png b/docs/reference/mvgam-15.png
index 53c22aa9..274fc0c4 100644
Binary files a/docs/reference/mvgam-15.png and b/docs/reference/mvgam-15.png differ
diff --git a/docs/reference/mvgam-16.png b/docs/reference/mvgam-16.png
index 3eec9485..a580b628 100644
Binary files a/docs/reference/mvgam-16.png and b/docs/reference/mvgam-16.png differ
diff --git a/docs/reference/mvgam-18.png b/docs/reference/mvgam-18.png
index 3fe344b1..d57a4a5c 100644
Binary files a/docs/reference/mvgam-18.png and b/docs/reference/mvgam-18.png differ
diff --git a/docs/reference/mvgam-19.png b/docs/reference/mvgam-19.png
index 409f7c0d..0d9c672a 100644
Binary files a/docs/reference/mvgam-19.png and b/docs/reference/mvgam-19.png differ
diff --git a/docs/reference/mvgam-2.png b/docs/reference/mvgam-2.png
index b05f9ef4..8a176cf1 100644
Binary files a/docs/reference/mvgam-2.png and b/docs/reference/mvgam-2.png differ
diff --git a/docs/reference/mvgam-20.png b/docs/reference/mvgam-20.png
index 119662eb..cde55640 100644
Binary files a/docs/reference/mvgam-20.png and b/docs/reference/mvgam-20.png differ
diff --git a/docs/reference/mvgam-21.png b/docs/reference/mvgam-21.png
index c4f5049a..7f27ab77 100644
Binary files a/docs/reference/mvgam-21.png and b/docs/reference/mvgam-21.png differ
diff --git a/docs/reference/mvgam-22.png b/docs/reference/mvgam-22.png
index bb509d3a..0257cdd7 100644
Binary files a/docs/reference/mvgam-22.png and b/docs/reference/mvgam-22.png differ
diff --git a/docs/reference/mvgam-23.png b/docs/reference/mvgam-23.png
index 19fad5cb..c2c65dea 100644
Binary files a/docs/reference/mvgam-23.png and b/docs/reference/mvgam-23.png differ
diff --git a/docs/reference/mvgam-24.png b/docs/reference/mvgam-24.png
index b0639411..6c761a3a 100644
Binary files a/docs/reference/mvgam-24.png and b/docs/reference/mvgam-24.png differ
diff --git a/docs/reference/mvgam-25.png b/docs/reference/mvgam-25.png
index 36440c7e..89492454 100644
Binary files a/docs/reference/mvgam-25.png and b/docs/reference/mvgam-25.png differ
diff --git a/docs/reference/mvgam-26.png b/docs/reference/mvgam-26.png
index 2294aba4..b47b23d5 100644
Binary files a/docs/reference/mvgam-26.png and b/docs/reference/mvgam-26.png differ
diff --git a/docs/reference/mvgam-27.png b/docs/reference/mvgam-27.png
index 7ba58fa4..3d338ca8 100644
Binary files a/docs/reference/mvgam-27.png and b/docs/reference/mvgam-27.png differ
diff --git a/docs/reference/mvgam-28.png b/docs/reference/mvgam-28.png
index 31295326..626f5d23 100644
Binary files a/docs/reference/mvgam-28.png and b/docs/reference/mvgam-28.png differ
diff --git a/docs/reference/mvgam-3.png b/docs/reference/mvgam-3.png
index fe800df7..189c670a 100644
Binary files a/docs/reference/mvgam-3.png and b/docs/reference/mvgam-3.png differ
diff --git a/docs/reference/mvgam-4.png b/docs/reference/mvgam-4.png
index 3e996752..a556ce01 100644
Binary files a/docs/reference/mvgam-4.png and b/docs/reference/mvgam-4.png differ
diff --git a/docs/reference/mvgam-5.png b/docs/reference/mvgam-5.png
index 57ff823d..67abe00d 100644
Binary files a/docs/reference/mvgam-5.png and b/docs/reference/mvgam-5.png differ
diff --git a/docs/reference/mvgam-6.png b/docs/reference/mvgam-6.png
index c3ee394b..8218f902 100644
Binary files a/docs/reference/mvgam-6.png and b/docs/reference/mvgam-6.png differ
diff --git a/docs/reference/mvgam-7.png b/docs/reference/mvgam-7.png
index 12389767..95d23a12 100644
Binary files a/docs/reference/mvgam-7.png and b/docs/reference/mvgam-7.png differ
diff --git a/docs/reference/mvgam-8.png b/docs/reference/mvgam-8.png
index d50d67c1..f17f71c8 100644
Binary files a/docs/reference/mvgam-8.png and b/docs/reference/mvgam-8.png differ
diff --git a/docs/reference/mvgam-9.png b/docs/reference/mvgam-9.png
index 4f70efb2..195031df 100644
Binary files a/docs/reference/mvgam-9.png and b/docs/reference/mvgam-9.png differ
diff --git a/docs/reference/mvgam.html b/docs/reference/mvgam.html
index e902ed33..7d1df4e9 100644
--- a/docs/reference/mvgam.html
+++ b/docs/reference/mvgam.html
@@ -116,8 +116,8 @@ Usage
algorithm = getOption("brms.algorithm", "sampling"),
autoformat = TRUE,
save_all_pars = FALSE,
- max_treedepth = 12,
- adapt_delta = 0.85,
+ max_treedepth = 10,
+ adapt_delta = 0.8,
silent = 1,
jags_path,
...
@@ -418,7 +418,7 @@ ArgumentsExamplessdata1 <- standata(mod1)
str(sdata1)
#> List of 18
-#> $ y : num [1:60, 1:3] 12 17 12 31 30 8 0 1 3 5 ...
+#> $ y : num [1:60, 1:3] 4 5 7 39 51 26 6 6 4 2 ...
#> $ n : int 60
#> $ X : num [1:180, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
@@ -712,7 +712,7 @@ Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -309.4 11.4
-#> p_loo 12.9 1.0
-#> looic 618.8 22.7
+#> elpd_loo -309.7 11.4
+#> p_loo 13.3 1.1
+#> looic 619.5 22.8
#> ------
#> MCSE of elpd_loo is 0.1.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.6, 1.2]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.7, 1.3]).
#>
#> All Pareto k estimates are good (k < 0.67).
#> See help('pareto-k-diagnostic') for details.
@@ -272,47 +228,24 @@ Examples# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
-#> Your model may benefit from using "noncentred = TRUE"
-#> Compiling Stan program using cmdstanr
-#>
-#> Start sampling
-#> Running MCMC with 2 parallel chains...
-#>
-#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 10.1 seconds.
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 14.6 seconds.
-#>
-#> Both chains finished successfully.
-#> Mean chain execution time: 12.4 seconds.
-#> Total execution time: 14.8 seconds.
-#>
+#> 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/RtmpqqsueL/model-19b84ce92891.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
conditional_effects(mod3)
@@ -324,18 +257,18 @@ Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -261.8 10.1
-#> p_loo 155.4 7.0
-#> looic 523.7 20.3
+#> elpd_loo -251.0 9.9
+#> p_loo 163.6 7.1
+#> looic 502.0 19.9
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.1]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.0]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 151 50.3% 1
-#> (0.67, 1] (bad) 142 47.3% <NA>
-#> (1, Inf) (very bad) 7 2.3% <NA>
+#> (-Inf, 0.67] (good) 127 42.3% 1
+#> (0.67, 1] (bad) 160 53.3% <NA>
+#> (1, Inf) (very bad) 13 4.3% <NA>
#> See help('pareto-k-diagnostic') for details.
# Compare models using LOO
@@ -343,8 +276,8 @@ Examples#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#> elpd_diff se_diff
#> mod3 0.0 0.0
-#> mod2 -47.6 4.3
-#> mod1 -101.9 9.1
+#> mod2 -58.7 4.8
+#> mod1 -113.2 9.3
options(mc.cores = mc.cores.def)
# Compare forecast abilities using an expanding training window and
@@ -358,39 +291,52 @@ Examples#> Warning: model has repeated 1-d smooths of same variable.
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b824896df3.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 1.0 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 1.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.2 seconds.
+#> Chain 2 finished in 1.2 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 2.0 seconds.
-#> Total execution time: 2.4 seconds.
+#> Mean chain execution time: 1.1 seconds.
+#> Total execution time: 1.3 seconds.
#>
lfo_mod3 <- lfo_cv(mod3, min_t = 92)
#> Warning: model has repeated 1-d smooths of same variable.
@@ -399,39 +345,52 @@ Examples#> Your model may benefit from using "noncentred = TRUE"
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b85d765643.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 12.8 seconds.
+#> Chain 2 finished in 6.6 seconds.
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 36.4 seconds.
+#> Chain 1 finished in 11.1 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 24.6 seconds.
-#> Total execution time: 36.7 seconds.
+#> Mean chain execution time: 8.8 seconds.
+#> Total execution time: 11.1 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -446,32 +405,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 17.0 seconds.
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 21.1 seconds.
+#> Chain 2 finished in 7.0 seconds.
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 7.9 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 19.1 seconds.
-#> Total execution time: 21.5 seconds.
+#> Mean chain execution time: 7.4 seconds.
+#> Total execution time: 7.9 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -486,32 +445,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 8.8 seconds.
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 24.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 25.4 seconds.
+#> Chain 2 finished in 25.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 25.2 seconds.
-#> Total execution time: 25.7 seconds.
+#> Mean chain execution time: 16.9 seconds.
+#> Total execution time: 25.2 seconds.
#>
# Take the difference in forecast ELPDs; a model with higher ELPD is preferred,
diff --git a/docs/reference/mvgam-1.png b/docs/reference/mvgam-1.png
index e328ce49..430cb723 100644
Binary files a/docs/reference/mvgam-1.png and b/docs/reference/mvgam-1.png differ
diff --git a/docs/reference/mvgam-10.png b/docs/reference/mvgam-10.png
index 65d6b581..2eaa0a02 100644
Binary files a/docs/reference/mvgam-10.png and b/docs/reference/mvgam-10.png differ
diff --git a/docs/reference/mvgam-11.png b/docs/reference/mvgam-11.png
index 61b0cff8..93b6a939 100644
Binary files a/docs/reference/mvgam-11.png and b/docs/reference/mvgam-11.png differ
diff --git a/docs/reference/mvgam-12.png b/docs/reference/mvgam-12.png
index 12c720a1..6153dd79 100644
Binary files a/docs/reference/mvgam-12.png and b/docs/reference/mvgam-12.png differ
diff --git a/docs/reference/mvgam-13.png b/docs/reference/mvgam-13.png
index 9db19eac..b18d849a 100644
Binary files a/docs/reference/mvgam-13.png and b/docs/reference/mvgam-13.png differ
diff --git a/docs/reference/mvgam-14.png b/docs/reference/mvgam-14.png
index 4fbfac7e..b7a6d24e 100644
Binary files a/docs/reference/mvgam-14.png and b/docs/reference/mvgam-14.png differ
diff --git a/docs/reference/mvgam-15.png b/docs/reference/mvgam-15.png
index 53c22aa9..274fc0c4 100644
Binary files a/docs/reference/mvgam-15.png and b/docs/reference/mvgam-15.png differ
diff --git a/docs/reference/mvgam-16.png b/docs/reference/mvgam-16.png
index 3eec9485..a580b628 100644
Binary files a/docs/reference/mvgam-16.png and b/docs/reference/mvgam-16.png differ
diff --git a/docs/reference/mvgam-18.png b/docs/reference/mvgam-18.png
index 3fe344b1..d57a4a5c 100644
Binary files a/docs/reference/mvgam-18.png and b/docs/reference/mvgam-18.png differ
diff --git a/docs/reference/mvgam-19.png b/docs/reference/mvgam-19.png
index 409f7c0d..0d9c672a 100644
Binary files a/docs/reference/mvgam-19.png and b/docs/reference/mvgam-19.png differ
diff --git a/docs/reference/mvgam-2.png b/docs/reference/mvgam-2.png
index b05f9ef4..8a176cf1 100644
Binary files a/docs/reference/mvgam-2.png and b/docs/reference/mvgam-2.png differ
diff --git a/docs/reference/mvgam-20.png b/docs/reference/mvgam-20.png
index 119662eb..cde55640 100644
Binary files a/docs/reference/mvgam-20.png and b/docs/reference/mvgam-20.png differ
diff --git a/docs/reference/mvgam-21.png b/docs/reference/mvgam-21.png
index c4f5049a..7f27ab77 100644
Binary files a/docs/reference/mvgam-21.png and b/docs/reference/mvgam-21.png differ
diff --git a/docs/reference/mvgam-22.png b/docs/reference/mvgam-22.png
index bb509d3a..0257cdd7 100644
Binary files a/docs/reference/mvgam-22.png and b/docs/reference/mvgam-22.png differ
diff --git a/docs/reference/mvgam-23.png b/docs/reference/mvgam-23.png
index 19fad5cb..c2c65dea 100644
Binary files a/docs/reference/mvgam-23.png and b/docs/reference/mvgam-23.png differ
diff --git a/docs/reference/mvgam-24.png b/docs/reference/mvgam-24.png
index b0639411..6c761a3a 100644
Binary files a/docs/reference/mvgam-24.png and b/docs/reference/mvgam-24.png differ
diff --git a/docs/reference/mvgam-25.png b/docs/reference/mvgam-25.png
index 36440c7e..89492454 100644
Binary files a/docs/reference/mvgam-25.png and b/docs/reference/mvgam-25.png differ
diff --git a/docs/reference/mvgam-26.png b/docs/reference/mvgam-26.png
index 2294aba4..b47b23d5 100644
Binary files a/docs/reference/mvgam-26.png and b/docs/reference/mvgam-26.png differ
diff --git a/docs/reference/mvgam-27.png b/docs/reference/mvgam-27.png
index 7ba58fa4..3d338ca8 100644
Binary files a/docs/reference/mvgam-27.png and b/docs/reference/mvgam-27.png differ
diff --git a/docs/reference/mvgam-28.png b/docs/reference/mvgam-28.png
index 31295326..626f5d23 100644
Binary files a/docs/reference/mvgam-28.png and b/docs/reference/mvgam-28.png differ
diff --git a/docs/reference/mvgam-3.png b/docs/reference/mvgam-3.png
index fe800df7..189c670a 100644
Binary files a/docs/reference/mvgam-3.png and b/docs/reference/mvgam-3.png differ
diff --git a/docs/reference/mvgam-4.png b/docs/reference/mvgam-4.png
index 3e996752..a556ce01 100644
Binary files a/docs/reference/mvgam-4.png and b/docs/reference/mvgam-4.png differ
diff --git a/docs/reference/mvgam-5.png b/docs/reference/mvgam-5.png
index 57ff823d..67abe00d 100644
Binary files a/docs/reference/mvgam-5.png and b/docs/reference/mvgam-5.png differ
diff --git a/docs/reference/mvgam-6.png b/docs/reference/mvgam-6.png
index c3ee394b..8218f902 100644
Binary files a/docs/reference/mvgam-6.png and b/docs/reference/mvgam-6.png differ
diff --git a/docs/reference/mvgam-7.png b/docs/reference/mvgam-7.png
index 12389767..95d23a12 100644
Binary files a/docs/reference/mvgam-7.png and b/docs/reference/mvgam-7.png differ
diff --git a/docs/reference/mvgam-8.png b/docs/reference/mvgam-8.png
index d50d67c1..f17f71c8 100644
Binary files a/docs/reference/mvgam-8.png and b/docs/reference/mvgam-8.png differ
diff --git a/docs/reference/mvgam-9.png b/docs/reference/mvgam-9.png
index 4f70efb2..195031df 100644
Binary files a/docs/reference/mvgam-9.png and b/docs/reference/mvgam-9.png differ
diff --git a/docs/reference/mvgam.html b/docs/reference/mvgam.html
index e902ed33..7d1df4e9 100644
--- a/docs/reference/mvgam.html
+++ b/docs/reference/mvgam.html
@@ -116,8 +116,8 @@ Usage
algorithm = getOption("brms.algorithm", "sampling"),
autoformat = TRUE,
save_all_pars = FALSE,
- max_treedepth = 12,
- adapt_delta = 0.85,
+ max_treedepth = 10,
+ adapt_delta = 0.8,
silent = 1,
jags_path,
...
@@ -418,7 +418,7 @@ ArgumentsExamplessdata1 <- standata(mod1)
str(sdata1)
#> List of 18
-#> $ y : num [1:60, 1:3] 12 17 12 31 30 8 0 1 3 5 ...
+#> $ y : num [1:60, 1:3] 4 5 7 39 51 26 6 6 4 2 ...
#> $ n : int 60
#> $ X : num [1:180, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
@@ -712,7 +712,7 @@ Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Computed from 1000 by 300 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -261.8 10.1
-#> p_loo 155.4 7.0
-#> looic 523.7 20.3
+#> elpd_loo -251.0 9.9
+#> p_loo 163.6 7.1
+#> looic 502.0 19.9
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.1]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 0.0]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 151 50.3% 1
-#> (0.67, 1] (bad) 142 47.3% <NA>
-#> (1, Inf) (very bad) 7 2.3% <NA>
+#> (-Inf, 0.67] (good) 127 42.3% 1
+#> (0.67, 1] (bad) 160 53.3% <NA>
+#> (1, Inf) (very bad) 13 4.3% <NA>
#> See help('pareto-k-diagnostic') for details.
# Compare models using LOO
@@ -343,8 +276,8 @@ Examples#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#> elpd_diff se_diff
#> mod3 0.0 0.0
-#> mod2 -47.6 4.3
-#> mod1 -101.9 9.1
+#> mod2 -58.7 4.8
+#> mod1 -113.2 9.3
options(mc.cores = mc.cores.def)
# Compare forecast abilities using an expanding training window and
@@ -358,39 +291,52 @@ Examples#> Warning: model has repeated 1-d smooths of same variable.
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b824896df3.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 1.0 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 1.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.2 seconds.
+#> Chain 2 finished in 1.2 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 2.0 seconds.
-#> Total execution time: 2.4 seconds.
+#> Mean chain execution time: 1.1 seconds.
+#> Total execution time: 1.3 seconds.
#>
lfo_mod3 <- lfo_cv(mod3, min_t = 92)
#> Warning: model has repeated 1-d smooths of same variable.
@@ -399,39 +345,52 @@ Examples#> Your model may benefit from using "noncentred = TRUE"
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b85d765643.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 12.8 seconds.
+#> Chain 2 finished in 6.6 seconds.
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 36.4 seconds.
+#> Chain 1 finished in 11.1 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 24.6 seconds.
-#> Total execution time: 36.7 seconds.
+#> Mean chain execution time: 8.8 seconds.
+#> Total execution time: 11.1 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -446,32 +405,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 17.0 seconds.
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 21.1 seconds.
+#> Chain 2 finished in 7.0 seconds.
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 7.9 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 19.1 seconds.
-#> Total execution time: 21.5 seconds.
+#> Mean chain execution time: 7.4 seconds.
+#> Total execution time: 7.9 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -486,32 +445,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 8.8 seconds.
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 24.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 25.4 seconds.
+#> Chain 2 finished in 25.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 25.2 seconds.
-#> Total execution time: 25.7 seconds.
+#> Mean chain execution time: 16.9 seconds.
+#> Total execution time: 25.2 seconds.
#>
# Take the difference in forecast ELPDs; a model with higher ELPD is preferred,
diff --git a/docs/reference/mvgam-1.png b/docs/reference/mvgam-1.png
index e328ce49..430cb723 100644
Binary files a/docs/reference/mvgam-1.png and b/docs/reference/mvgam-1.png differ
diff --git a/docs/reference/mvgam-10.png b/docs/reference/mvgam-10.png
index 65d6b581..2eaa0a02 100644
Binary files a/docs/reference/mvgam-10.png and b/docs/reference/mvgam-10.png differ
diff --git a/docs/reference/mvgam-11.png b/docs/reference/mvgam-11.png
index 61b0cff8..93b6a939 100644
Binary files a/docs/reference/mvgam-11.png and b/docs/reference/mvgam-11.png differ
diff --git a/docs/reference/mvgam-12.png b/docs/reference/mvgam-12.png
index 12c720a1..6153dd79 100644
Binary files a/docs/reference/mvgam-12.png and b/docs/reference/mvgam-12.png differ
diff --git a/docs/reference/mvgam-13.png b/docs/reference/mvgam-13.png
index 9db19eac..b18d849a 100644
Binary files a/docs/reference/mvgam-13.png and b/docs/reference/mvgam-13.png differ
diff --git a/docs/reference/mvgam-14.png b/docs/reference/mvgam-14.png
index 4fbfac7e..b7a6d24e 100644
Binary files a/docs/reference/mvgam-14.png and b/docs/reference/mvgam-14.png differ
diff --git a/docs/reference/mvgam-15.png b/docs/reference/mvgam-15.png
index 53c22aa9..274fc0c4 100644
Binary files a/docs/reference/mvgam-15.png and b/docs/reference/mvgam-15.png differ
diff --git a/docs/reference/mvgam-16.png b/docs/reference/mvgam-16.png
index 3eec9485..a580b628 100644
Binary files a/docs/reference/mvgam-16.png and b/docs/reference/mvgam-16.png differ
diff --git a/docs/reference/mvgam-18.png b/docs/reference/mvgam-18.png
index 3fe344b1..d57a4a5c 100644
Binary files a/docs/reference/mvgam-18.png and b/docs/reference/mvgam-18.png differ
diff --git a/docs/reference/mvgam-19.png b/docs/reference/mvgam-19.png
index 409f7c0d..0d9c672a 100644
Binary files a/docs/reference/mvgam-19.png and b/docs/reference/mvgam-19.png differ
diff --git a/docs/reference/mvgam-2.png b/docs/reference/mvgam-2.png
index b05f9ef4..8a176cf1 100644
Binary files a/docs/reference/mvgam-2.png and b/docs/reference/mvgam-2.png differ
diff --git a/docs/reference/mvgam-20.png b/docs/reference/mvgam-20.png
index 119662eb..cde55640 100644
Binary files a/docs/reference/mvgam-20.png and b/docs/reference/mvgam-20.png differ
diff --git a/docs/reference/mvgam-21.png b/docs/reference/mvgam-21.png
index c4f5049a..7f27ab77 100644
Binary files a/docs/reference/mvgam-21.png and b/docs/reference/mvgam-21.png differ
diff --git a/docs/reference/mvgam-22.png b/docs/reference/mvgam-22.png
index bb509d3a..0257cdd7 100644
Binary files a/docs/reference/mvgam-22.png and b/docs/reference/mvgam-22.png differ
diff --git a/docs/reference/mvgam-23.png b/docs/reference/mvgam-23.png
index 19fad5cb..c2c65dea 100644
Binary files a/docs/reference/mvgam-23.png and b/docs/reference/mvgam-23.png differ
diff --git a/docs/reference/mvgam-24.png b/docs/reference/mvgam-24.png
index b0639411..6c761a3a 100644
Binary files a/docs/reference/mvgam-24.png and b/docs/reference/mvgam-24.png differ
diff --git a/docs/reference/mvgam-25.png b/docs/reference/mvgam-25.png
index 36440c7e..89492454 100644
Binary files a/docs/reference/mvgam-25.png and b/docs/reference/mvgam-25.png differ
diff --git a/docs/reference/mvgam-26.png b/docs/reference/mvgam-26.png
index 2294aba4..b47b23d5 100644
Binary files a/docs/reference/mvgam-26.png and b/docs/reference/mvgam-26.png differ
diff --git a/docs/reference/mvgam-27.png b/docs/reference/mvgam-27.png
index 7ba58fa4..3d338ca8 100644
Binary files a/docs/reference/mvgam-27.png and b/docs/reference/mvgam-27.png differ
diff --git a/docs/reference/mvgam-28.png b/docs/reference/mvgam-28.png
index 31295326..626f5d23 100644
Binary files a/docs/reference/mvgam-28.png and b/docs/reference/mvgam-28.png differ
diff --git a/docs/reference/mvgam-3.png b/docs/reference/mvgam-3.png
index fe800df7..189c670a 100644
Binary files a/docs/reference/mvgam-3.png and b/docs/reference/mvgam-3.png differ
diff --git a/docs/reference/mvgam-4.png b/docs/reference/mvgam-4.png
index 3e996752..a556ce01 100644
Binary files a/docs/reference/mvgam-4.png and b/docs/reference/mvgam-4.png differ
diff --git a/docs/reference/mvgam-5.png b/docs/reference/mvgam-5.png
index 57ff823d..67abe00d 100644
Binary files a/docs/reference/mvgam-5.png and b/docs/reference/mvgam-5.png differ
diff --git a/docs/reference/mvgam-6.png b/docs/reference/mvgam-6.png
index c3ee394b..8218f902 100644
Binary files a/docs/reference/mvgam-6.png and b/docs/reference/mvgam-6.png differ
diff --git a/docs/reference/mvgam-7.png b/docs/reference/mvgam-7.png
index 12389767..95d23a12 100644
Binary files a/docs/reference/mvgam-7.png and b/docs/reference/mvgam-7.png differ
diff --git a/docs/reference/mvgam-8.png b/docs/reference/mvgam-8.png
index d50d67c1..f17f71c8 100644
Binary files a/docs/reference/mvgam-8.png and b/docs/reference/mvgam-8.png differ
diff --git a/docs/reference/mvgam-9.png b/docs/reference/mvgam-9.png
index 4f70efb2..195031df 100644
Binary files a/docs/reference/mvgam-9.png and b/docs/reference/mvgam-9.png differ
diff --git a/docs/reference/mvgam.html b/docs/reference/mvgam.html
index e902ed33..7d1df4e9 100644
--- a/docs/reference/mvgam.html
+++ b/docs/reference/mvgam.html
@@ -116,8 +116,8 @@ Usage
algorithm = getOption("brms.algorithm", "sampling"),
autoformat = TRUE,
save_all_pars = FALSE,
- max_treedepth = 12,
- adapt_delta = 0.85,
+ max_treedepth = 10,
+ adapt_delta = 0.8,
silent = 1,
jags_path,
...
@@ -418,7 +418,7 @@ ArgumentsExamplessdata1 <- standata(mod1)
str(sdata1)
#> List of 18
-#> $ y : num [1:60, 1:3] 12 17 12 31 30 8 0 1 3 5 ...
+#> $ y : num [1:60, 1:3] 4 5 7 39 51 26 6 6 4 2 ...
#> $ n : int 60
#> $ X : num [1:180, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
@@ -712,7 +712,7 @@ Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Warning: model has repeated 1-d smooths of same variable.
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b824896df3.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 1.0 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 1.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 2.2 seconds.
+#> Chain 2 finished in 1.2 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 2.0 seconds.
-#> Total execution time: 2.4 seconds.
+#> Mean chain execution time: 1.1 seconds.
+#> Total execution time: 1.3 seconds.
#>
lfo_mod3 <- lfo_cv(mod3, min_t = 92)
#> Warning: model has repeated 1-d smooths of same variable.
@@ -399,39 +345,52 @@ Examples#> Your model may benefit from using "noncentred = TRUE"
#> Compiling Stan program using cmdstanr
#>
+#> 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/RtmpqqsueL/model-19b85d765643.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
#> Start sampling
#> Running MCMC with 2 parallel chains...
#>
#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
-#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 12.8 seconds.
+#> Chain 2 finished in 6.6 seconds.
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 36.4 seconds.
+#> Chain 1 finished in 11.1 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 24.6 seconds.
-#> Total execution time: 36.7 seconds.
+#> Mean chain execution time: 8.8 seconds.
+#> Total execution time: 11.1 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -446,32 +405,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 17.0 seconds.
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 21.1 seconds.
+#> Chain 2 finished in 7.0 seconds.
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 7.9 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 19.1 seconds.
-#> Total execution time: 21.5 seconds.
+#> Mean chain execution time: 7.4 seconds.
+#> Total execution time: 7.9 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -486,32 +445,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 8.8 seconds.
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 24.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 25.4 seconds.
+#> Chain 2 finished in 25.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 25.2 seconds.
-#> Total execution time: 25.7 seconds.
+#> Mean chain execution time: 16.9 seconds.
+#> Total execution time: 25.2 seconds.
#>
# Take the difference in forecast ELPDs; a model with higher ELPD is preferred,
diff --git a/docs/reference/mvgam-1.png b/docs/reference/mvgam-1.png
index e328ce49..430cb723 100644
Binary files a/docs/reference/mvgam-1.png and b/docs/reference/mvgam-1.png differ
diff --git a/docs/reference/mvgam-10.png b/docs/reference/mvgam-10.png
index 65d6b581..2eaa0a02 100644
Binary files a/docs/reference/mvgam-10.png and b/docs/reference/mvgam-10.png differ
diff --git a/docs/reference/mvgam-11.png b/docs/reference/mvgam-11.png
index 61b0cff8..93b6a939 100644
Binary files a/docs/reference/mvgam-11.png and b/docs/reference/mvgam-11.png differ
diff --git a/docs/reference/mvgam-12.png b/docs/reference/mvgam-12.png
index 12c720a1..6153dd79 100644
Binary files a/docs/reference/mvgam-12.png and b/docs/reference/mvgam-12.png differ
diff --git a/docs/reference/mvgam-13.png b/docs/reference/mvgam-13.png
index 9db19eac..b18d849a 100644
Binary files a/docs/reference/mvgam-13.png and b/docs/reference/mvgam-13.png differ
diff --git a/docs/reference/mvgam-14.png b/docs/reference/mvgam-14.png
index 4fbfac7e..b7a6d24e 100644
Binary files a/docs/reference/mvgam-14.png and b/docs/reference/mvgam-14.png differ
diff --git a/docs/reference/mvgam-15.png b/docs/reference/mvgam-15.png
index 53c22aa9..274fc0c4 100644
Binary files a/docs/reference/mvgam-15.png and b/docs/reference/mvgam-15.png differ
diff --git a/docs/reference/mvgam-16.png b/docs/reference/mvgam-16.png
index 3eec9485..a580b628 100644
Binary files a/docs/reference/mvgam-16.png and b/docs/reference/mvgam-16.png differ
diff --git a/docs/reference/mvgam-18.png b/docs/reference/mvgam-18.png
index 3fe344b1..d57a4a5c 100644
Binary files a/docs/reference/mvgam-18.png and b/docs/reference/mvgam-18.png differ
diff --git a/docs/reference/mvgam-19.png b/docs/reference/mvgam-19.png
index 409f7c0d..0d9c672a 100644
Binary files a/docs/reference/mvgam-19.png and b/docs/reference/mvgam-19.png differ
diff --git a/docs/reference/mvgam-2.png b/docs/reference/mvgam-2.png
index b05f9ef4..8a176cf1 100644
Binary files a/docs/reference/mvgam-2.png and b/docs/reference/mvgam-2.png differ
diff --git a/docs/reference/mvgam-20.png b/docs/reference/mvgam-20.png
index 119662eb..cde55640 100644
Binary files a/docs/reference/mvgam-20.png and b/docs/reference/mvgam-20.png differ
diff --git a/docs/reference/mvgam-21.png b/docs/reference/mvgam-21.png
index c4f5049a..7f27ab77 100644
Binary files a/docs/reference/mvgam-21.png and b/docs/reference/mvgam-21.png differ
diff --git a/docs/reference/mvgam-22.png b/docs/reference/mvgam-22.png
index bb509d3a..0257cdd7 100644
Binary files a/docs/reference/mvgam-22.png and b/docs/reference/mvgam-22.png differ
diff --git a/docs/reference/mvgam-23.png b/docs/reference/mvgam-23.png
index 19fad5cb..c2c65dea 100644
Binary files a/docs/reference/mvgam-23.png and b/docs/reference/mvgam-23.png differ
diff --git a/docs/reference/mvgam-24.png b/docs/reference/mvgam-24.png
index b0639411..6c761a3a 100644
Binary files a/docs/reference/mvgam-24.png and b/docs/reference/mvgam-24.png differ
diff --git a/docs/reference/mvgam-25.png b/docs/reference/mvgam-25.png
index 36440c7e..89492454 100644
Binary files a/docs/reference/mvgam-25.png and b/docs/reference/mvgam-25.png differ
diff --git a/docs/reference/mvgam-26.png b/docs/reference/mvgam-26.png
index 2294aba4..b47b23d5 100644
Binary files a/docs/reference/mvgam-26.png and b/docs/reference/mvgam-26.png differ
diff --git a/docs/reference/mvgam-27.png b/docs/reference/mvgam-27.png
index 7ba58fa4..3d338ca8 100644
Binary files a/docs/reference/mvgam-27.png and b/docs/reference/mvgam-27.png differ
diff --git a/docs/reference/mvgam-28.png b/docs/reference/mvgam-28.png
index 31295326..626f5d23 100644
Binary files a/docs/reference/mvgam-28.png and b/docs/reference/mvgam-28.png differ
diff --git a/docs/reference/mvgam-3.png b/docs/reference/mvgam-3.png
index fe800df7..189c670a 100644
Binary files a/docs/reference/mvgam-3.png and b/docs/reference/mvgam-3.png differ
diff --git a/docs/reference/mvgam-4.png b/docs/reference/mvgam-4.png
index 3e996752..a556ce01 100644
Binary files a/docs/reference/mvgam-4.png and b/docs/reference/mvgam-4.png differ
diff --git a/docs/reference/mvgam-5.png b/docs/reference/mvgam-5.png
index 57ff823d..67abe00d 100644
Binary files a/docs/reference/mvgam-5.png and b/docs/reference/mvgam-5.png differ
diff --git a/docs/reference/mvgam-6.png b/docs/reference/mvgam-6.png
index c3ee394b..8218f902 100644
Binary files a/docs/reference/mvgam-6.png and b/docs/reference/mvgam-6.png differ
diff --git a/docs/reference/mvgam-7.png b/docs/reference/mvgam-7.png
index 12389767..95d23a12 100644
Binary files a/docs/reference/mvgam-7.png and b/docs/reference/mvgam-7.png differ
diff --git a/docs/reference/mvgam-8.png b/docs/reference/mvgam-8.png
index d50d67c1..f17f71c8 100644
Binary files a/docs/reference/mvgam-8.png and b/docs/reference/mvgam-8.png differ
diff --git a/docs/reference/mvgam-9.png b/docs/reference/mvgam-9.png
index 4f70efb2..195031df 100644
Binary files a/docs/reference/mvgam-9.png and b/docs/reference/mvgam-9.png differ
diff --git a/docs/reference/mvgam.html b/docs/reference/mvgam.html
index e902ed33..7d1df4e9 100644
--- a/docs/reference/mvgam.html
+++ b/docs/reference/mvgam.html
@@ -116,8 +116,8 @@ Usage
algorithm = getOption("brms.algorithm", "sampling"),
autoformat = TRUE,
save_all_pars = FALSE,
- max_treedepth = 12,
- adapt_delta = 0.85,
+ max_treedepth = 10,
+ adapt_delta = 0.8,
silent = 1,
jags_path,
...
@@ -418,7 +418,7 @@ ArgumentsExamplessdata1 <- standata(mod1)
str(sdata1)
#> List of 18
-#> $ y : num [1:60, 1:3] 12 17 12 31 30 8 0 1 3 5 ...
+#> $ y : num [1:60, 1:3] 4 5 7 39 51 26 6 6 4 2 ...
#> $ n : int 60
#> $ X : num [1:180, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
@@ -712,7 +712,7 @@ Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 17.0 seconds.
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 21.1 seconds.
+#> Chain 2 finished in 7.0 seconds.
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 7.9 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 19.1 seconds.
-#> Total execution time: 21.5 seconds.
+#> Mean chain execution time: 7.4 seconds.
+#> Total execution time: 7.9 seconds.
#>
#> Warning: model has repeated 1-d smooths of same variable.
#> Warning: model has repeated 1-d smooths of same variable.
@@ -486,32 +445,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 8.8 seconds.
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 24.9 seconds.
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 25.4 seconds.
+#> Chain 2 finished in 25.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 25.2 seconds.
-#> Total execution time: 25.7 seconds.
+#> Mean chain execution time: 16.9 seconds.
+#> Total execution time: 25.2 seconds.
#>
# Take the difference in forecast ELPDs; a model with higher ELPD is preferred,
diff --git a/docs/reference/mvgam-1.png b/docs/reference/mvgam-1.png
index e328ce49..430cb723 100644
Binary files a/docs/reference/mvgam-1.png and b/docs/reference/mvgam-1.png differ
diff --git a/docs/reference/mvgam-10.png b/docs/reference/mvgam-10.png
index 65d6b581..2eaa0a02 100644
Binary files a/docs/reference/mvgam-10.png and b/docs/reference/mvgam-10.png differ
diff --git a/docs/reference/mvgam-11.png b/docs/reference/mvgam-11.png
index 61b0cff8..93b6a939 100644
Binary files a/docs/reference/mvgam-11.png and b/docs/reference/mvgam-11.png differ
diff --git a/docs/reference/mvgam-12.png b/docs/reference/mvgam-12.png
index 12c720a1..6153dd79 100644
Binary files a/docs/reference/mvgam-12.png and b/docs/reference/mvgam-12.png differ
diff --git a/docs/reference/mvgam-13.png b/docs/reference/mvgam-13.png
index 9db19eac..b18d849a 100644
Binary files a/docs/reference/mvgam-13.png and b/docs/reference/mvgam-13.png differ
diff --git a/docs/reference/mvgam-14.png b/docs/reference/mvgam-14.png
index 4fbfac7e..b7a6d24e 100644
Binary files a/docs/reference/mvgam-14.png and b/docs/reference/mvgam-14.png differ
diff --git a/docs/reference/mvgam-15.png b/docs/reference/mvgam-15.png
index 53c22aa9..274fc0c4 100644
Binary files a/docs/reference/mvgam-15.png and b/docs/reference/mvgam-15.png differ
diff --git a/docs/reference/mvgam-16.png b/docs/reference/mvgam-16.png
index 3eec9485..a580b628 100644
Binary files a/docs/reference/mvgam-16.png and b/docs/reference/mvgam-16.png differ
diff --git a/docs/reference/mvgam-18.png b/docs/reference/mvgam-18.png
index 3fe344b1..d57a4a5c 100644
Binary files a/docs/reference/mvgam-18.png and b/docs/reference/mvgam-18.png differ
diff --git a/docs/reference/mvgam-19.png b/docs/reference/mvgam-19.png
index 409f7c0d..0d9c672a 100644
Binary files a/docs/reference/mvgam-19.png and b/docs/reference/mvgam-19.png differ
diff --git a/docs/reference/mvgam-2.png b/docs/reference/mvgam-2.png
index b05f9ef4..8a176cf1 100644
Binary files a/docs/reference/mvgam-2.png and b/docs/reference/mvgam-2.png differ
diff --git a/docs/reference/mvgam-20.png b/docs/reference/mvgam-20.png
index 119662eb..cde55640 100644
Binary files a/docs/reference/mvgam-20.png and b/docs/reference/mvgam-20.png differ
diff --git a/docs/reference/mvgam-21.png b/docs/reference/mvgam-21.png
index c4f5049a..7f27ab77 100644
Binary files a/docs/reference/mvgam-21.png and b/docs/reference/mvgam-21.png differ
diff --git a/docs/reference/mvgam-22.png b/docs/reference/mvgam-22.png
index bb509d3a..0257cdd7 100644
Binary files a/docs/reference/mvgam-22.png and b/docs/reference/mvgam-22.png differ
diff --git a/docs/reference/mvgam-23.png b/docs/reference/mvgam-23.png
index 19fad5cb..c2c65dea 100644
Binary files a/docs/reference/mvgam-23.png and b/docs/reference/mvgam-23.png differ
diff --git a/docs/reference/mvgam-24.png b/docs/reference/mvgam-24.png
index b0639411..6c761a3a 100644
Binary files a/docs/reference/mvgam-24.png and b/docs/reference/mvgam-24.png differ
diff --git a/docs/reference/mvgam-25.png b/docs/reference/mvgam-25.png
index 36440c7e..89492454 100644
Binary files a/docs/reference/mvgam-25.png and b/docs/reference/mvgam-25.png differ
diff --git a/docs/reference/mvgam-26.png b/docs/reference/mvgam-26.png
index 2294aba4..b47b23d5 100644
Binary files a/docs/reference/mvgam-26.png and b/docs/reference/mvgam-26.png differ
diff --git a/docs/reference/mvgam-27.png b/docs/reference/mvgam-27.png
index 7ba58fa4..3d338ca8 100644
Binary files a/docs/reference/mvgam-27.png and b/docs/reference/mvgam-27.png differ
diff --git a/docs/reference/mvgam-28.png b/docs/reference/mvgam-28.png
index 31295326..626f5d23 100644
Binary files a/docs/reference/mvgam-28.png and b/docs/reference/mvgam-28.png differ
diff --git a/docs/reference/mvgam-3.png b/docs/reference/mvgam-3.png
index fe800df7..189c670a 100644
Binary files a/docs/reference/mvgam-3.png and b/docs/reference/mvgam-3.png differ
diff --git a/docs/reference/mvgam-4.png b/docs/reference/mvgam-4.png
index 3e996752..a556ce01 100644
Binary files a/docs/reference/mvgam-4.png and b/docs/reference/mvgam-4.png differ
diff --git a/docs/reference/mvgam-5.png b/docs/reference/mvgam-5.png
index 57ff823d..67abe00d 100644
Binary files a/docs/reference/mvgam-5.png and b/docs/reference/mvgam-5.png differ
diff --git a/docs/reference/mvgam-6.png b/docs/reference/mvgam-6.png
index c3ee394b..8218f902 100644
Binary files a/docs/reference/mvgam-6.png and b/docs/reference/mvgam-6.png differ
diff --git a/docs/reference/mvgam-7.png b/docs/reference/mvgam-7.png
index 12389767..95d23a12 100644
Binary files a/docs/reference/mvgam-7.png and b/docs/reference/mvgam-7.png differ
diff --git a/docs/reference/mvgam-8.png b/docs/reference/mvgam-8.png
index d50d67c1..f17f71c8 100644
Binary files a/docs/reference/mvgam-8.png and b/docs/reference/mvgam-8.png differ
diff --git a/docs/reference/mvgam-9.png b/docs/reference/mvgam-9.png
index 4f70efb2..195031df 100644
Binary files a/docs/reference/mvgam-9.png and b/docs/reference/mvgam-9.png differ
diff --git a/docs/reference/mvgam.html b/docs/reference/mvgam.html
index e902ed33..7d1df4e9 100644
--- a/docs/reference/mvgam.html
+++ b/docs/reference/mvgam.html
@@ -116,8 +116,8 @@ Usage
algorithm = getOption("brms.algorithm", "sampling"),
autoformat = TRUE,
save_all_pars = FALSE,
- max_treedepth = 12,
- adapt_delta = 0.85,
+ max_treedepth = 10,
+ adapt_delta = 0.8,
silent = 1,
jags_path,
...
@@ -418,7 +418,7 @@ ArgumentsExamplessdata1 <- standata(mod1)
str(sdata1)
#> List of 18
-#> $ y : num [1:60, 1:3] 12 17 12 31 30 8 0 1 3 5 ...
+#> $ y : num [1:60, 1:3] 4 5 7 39 51 26 6 6 4 2 ...
#> $ n : int 60
#> $ X : num [1:180, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
@@ -712,7 +712,7 @@ Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Usage
algorithm = getOption("brms.algorithm", "sampling"),
autoformat = TRUE,
save_all_pars = FALSE,
- max_treedepth = 12,
- adapt_delta = 0.85,
+ max_treedepth = 10,
+ adapt_delta = 0.8,
silent = 1,
jags_path,
...
@@ -418,7 +418,7 @@ ArgumentsExamplessdata1 <- standata(mod1)
str(sdata1)
#> List of 18
-#> $ y : num [1:60, 1:3] 12 17 12 31 30 8 0 1 3 5 ...
+#> $ y : num [1:60, 1:3] 4 5 7 39 51 26 6 6 4 2 ...
#> $ n : int 60
#> $ X : num [1:180, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
@@ -712,7 +712,7 @@ Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> $ zero : num [1:5] 0 0 0 0 0
#> $ p_coefs : Named num 0
#> ..- attr(*, "names")= chr "(Intercept)"
-#> $ p_taus : num 1.09
+#> $ p_taus : num 0.853
#> $ ytimes : int [1:60, 1:3] 1 4 7 10 13 16 19 22 25 28 ...
#> $ n_series : int 3
#> $ sp : Named num 0.368
@@ -721,10 +721,10 @@ Examples#> $ total_obs : int 180
#> $ num_basis : int 5
#> $ n_sp : num 1
-#> $ n_nonmissing: int 161
-#> $ obs_ind : int [1:161] 1 2 3 4 5 6 7 8 9 10 ...
-#> $ flat_ys : num [1:161] 12 17 12 31 30 8 0 1 3 5 ...
-#> $ flat_xs : num [1:161, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
+#> $ n_nonmissing: int 164
+#> $ obs_ind : int [1:164] 1 2 3 4 5 6 7 8 9 10 ...
+#> $ flat_ys : num [1:164] 4 5 7 39 51 26 6 6 4 2 ...
+#> $ flat_xs : num [1:164, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:5] "X.Intercept." "V2" "V3" "V4" ...
@@ -746,7 +746,7 @@ Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> 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/RtmpYHBavU/model-46c3b5e6c17.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b03ff170e8.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)
@@ -758,18 +758,18 @@ Examples#> Chain 1 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
+#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
@@ -778,9 +778,9 @@ Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 1 finished in 0.9 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 0.9 seconds.
@@ -791,7 +791,7 @@ Examplessummary(mod1)
#> GAM formula:
#> y ~ s(season, bs = "cc", k = 6)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> poisson
@@ -816,36 +816,36 @@ Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#>
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 1.80 2.000 2.1000 1.01 350
-#> s(season).1 0.15 0.370 0.6000 1.01 199
-#> s(season).2 -0.33 -0.091 0.1400 1.00 404
-#> s(season).3 -1.00 -0.710 -0.4500 1.01 372
-#> s(season).4 -0.52 -0.270 -0.0059 1.01 528
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 1.900 2.00 2.10 1 555
+#> s(season).1 0.086 0.31 0.52 1 631
+#> s(season).2 0.600 0.82 1.10 1 637
+#> s(season).3 -0.049 0.18 0.40 1 797
+#> s(season).4 -0.680 -0.42 -0.19 1 714
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(season) 3.69 4 26.7 1.1e-06 ***
+#> s(season) 3.52 4 39 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Latent trend parameter AR estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> ar1[1] 0.2400 0.73 0.98 1.01 274
-#> ar1[2] -0.9300 -0.36 0.18 1.01 147
-#> ar1[3] 0.0021 0.38 0.92 1.02 149
-#> sigma[1] 0.3900 0.53 0.73 1.00 314
-#> sigma[2] 0.3900 0.55 0.77 1.00 267
-#> sigma[3] 0.4300 0.59 0.78 1.00 309
+#> 2.5% 50% 97.5% Rhat n_eff
+#> ar1[1] 0.32 0.73 0.990 1.01 289
+#> ar1[2] -0.93 -0.41 0.018 1.02 228
+#> ar1[3] 0.24 0.67 0.980 1.00 254
+#> sigma[1] 0.42 0.56 0.740 1.00 324
+#> sigma[2] 0.35 0.49 0.680 1.01 334
+#> sigma[3] 0.39 0.52 0.700 1.00 318
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:46:32 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:09:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -861,7 +861,7 @@ Examples
resids <- residuals(mod1)
str(resids)
-#> num [1:180, 1:4] 0.0319 -0.06 0.1531 0.5229 -0.0881 ...
+#> num [1:180, 1:4] -0.178 NaN -0.118 0.279 -0.823 ...
#> - attr(*, "dimnames")=List of 2
#> ..$ : NULL
#> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5"
@@ -871,7 +871,7 @@ Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examplesstr(fc)
#> List of 16
#> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6)
-#> .. ..- attr(*, ".Environment")=<environment: 0x0000021ebbca2828>
+#> .. ..- attr(*, ".Environment")=<environment: 0x00000246410de130>
#> $ trend_call : NULL
#> $ family : chr "poisson"
#> $ family_pars : NULL
@@ -890,36 +890,36 @@ Examples#> $ type : chr "response"
#> $ series_names : Factor w/ 3 levels "series_1","series_2",..: 1 2 3
#> $ train_observations:List of 3
-#> ..$ series_1: int [1:60] 12 17 12 31 30 8 0 1 3 5 ...
-#> ..$ series_2: int [1:60] 8 8 21 7 6 NA 1 8 9 3 ...
-#> ..$ series_3: int [1:60] 10 NA 7 2 1 11 4 NA 5 4 ...
+#> ..$ series_1: int [1:60] 4 5 7 39 51 26 6 6 4 2 ...
+#> ..$ series_2: int [1:60] NA 2 12 16 6 31 9 15 5 3 ...
+#> ..$ series_3: int [1:60] 4 NA 4 NA NA 16 7 7 3 NA ...
#> $ train_times : int [1:60] 1 2 3 4 5 6 7 8 9 10 ...
#> $ test_observations :List of 3
-#> ..$ series_1: int [1:20] 4 9 5 6 4 11 NA 3 8 11 ...
-#> ..$ series_2: int [1:20] 19 51 19 10 3 6 7 1 6 4 ...
-#> ..$ series_3: int [1:20] 10 NA 8 5 16 13 0 0 3 2 ...
+#> ..$ series_1: int [1:20] 1 NA NA 13 18 20 16 6 NA 4 ...
+#> ..$ series_2: int [1:20] 4 36 8 6 7 NA NA 1 6 4 ...
+#> ..$ series_3: int [1:20] 6 8 5 5 19 14 1 1 7 0 ...
#> $ test_times : int [1:20] 61 62 63 64 65 66 67 68 69 70 ...
#> $ hindcasts :List of 3
-#> ..$ series_1: num [1:1000, 1:60] 22 9 10 1 18 15 11 19 10 15 ...
+#> ..$ series_1: num [1:1000, 1:60] 4 0 1 3 0 3 4 4 3 4 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,1]" "ypred[2,1]" "ypred[3,1]" "ypred[4,1]" ...
-#> ..$ series_2: num [1:1000, 1:60] 12 13 5 5 12 7 16 12 6 9 ...
+#> ..$ series_2: num [1:1000, 1:60] 10 5 2 0 4 20 5 8 3 7 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,2]" "ypred[2,2]" "ypred[3,2]" "ypred[4,2]" ...
-#> ..$ series_3: num [1:1000, 1:60] 5 11 9 9 6 15 5 6 14 12 ...
+#> ..$ series_3: num [1:1000, 1:60] 6 5 4 2 3 6 6 7 6 8 ...
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : NULL
#> .. .. ..$ : chr [1:60] "ypred[1,3]" "ypred[2,3]" "ypred[3,3]" "ypred[4,3]" ...
#> $ forecasts :List of 3
-#> ..$ series_1: int [1:1000, 1:20] 6 8 9 2 14 4 6 4 17 6 ...
-#> ..$ series_2: int [1:1000, 1:20] 10 13 12 11 8 9 1 9 25 5 ...
-#> ..$ series_3: int [1:1000, 1:20] 43 18 33 11 9 26 13 10 6 3 ...
+#> ..$ series_1: int [1:1000, 1:20] 4 8 0 3 10 3 1 5 2 9 ...
+#> ..$ series_2: int [1:1000, 1:20] 2 5 5 0 4 1 7 5 9 13 ...
+#> ..$ series_3: int [1:1000, 1:20] 7 3 6 10 3 6 6 3 4 11 ...
#> - attr(*, "class")= chr "mvgam_forecast"
plot(fc)
#> Out of sample DRPS:
-#> 55.270817
+#> 57.561702
# Plot the estimated seasonal smooth function
@@ -943,7 +943,7 @@ Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examplesconditional_effects(mod1)
plot_predictions(mod1, condition = 'season', points = 0.5)
-#> Warning: Removed 19 rows containing missing values or values outside the scale range
+#> Warning: Removed 16 rows containing missing values or values outside the scale range
#> (`geom_point()`).
@@ -957,19 +957,19 @@ Examplesbeta_draws_df <- as.data.frame(mod1, variable = 'betas')
head(beta_draws_df)
#> (Intercept) s(season).1 s(season).2 s(season).3 s(season).4
-#> 1 1.94416 0.394466 -0.06900860 -0.783359 -0.426288
-#> 2 1.92798 0.271471 -0.00850006 -0.685065 -0.244868
-#> 3 1.90193 0.230704 -0.04661740 -0.676646 -0.314741
-#> 4 1.88637 0.430494 -0.30333200 -0.634353 -0.345208
-#> 5 1.97914 0.322658 0.15346600 -0.703236 -0.263105
-#> 6 2.02798 0.407478 0.05122050 -0.581718 -0.361806
+#> 1 1.93652 0.335460 0.781389 -0.0251807 -0.423511
+#> 2 2.02126 0.389714 0.795744 0.1534600 -0.584915
+#> 3 1.98538 0.232350 0.944969 0.1425350 -0.444939
+#> 4 1.89741 0.300367 0.785340 0.2458830 -0.414404
+#> 5 1.99933 0.352974 0.763884 0.1705710 -0.261901
+#> 6 1.99175 0.229309 0.742755 0.1530400 -0.495284
str(beta_draws_df)
#> 'data.frame': 1000 obs. of 5 variables:
-#> $ (Intercept): num 1.94 1.93 1.9 1.89 1.98 ...
-#> $ s(season).1: num 0.394 0.271 0.231 0.43 0.323 ...
-#> $ s(season).2: num -0.069 -0.0085 -0.0466 -0.3033 0.1535 ...
-#> $ s(season).3: num -0.783 -0.685 -0.677 -0.634 -0.703 ...
-#> $ s(season).4: num -0.426 -0.245 -0.315 -0.345 -0.263 ...
+#> $ (Intercept): num 1.94 2.02 1.99 1.9 2 ...
+#> $ s(season).1: num 0.335 0.39 0.232 0.3 0.353 ...
+#> $ s(season).2: num 0.781 0.796 0.945 0.785 0.764 ...
+#> $ s(season).3: num -0.0252 0.1535 0.1425 0.2459 0.1706 ...
+#> $ s(season).4: num -0.424 -0.585 -0.445 -0.414 -0.262 ...
# Investigate model fit
mc.cores.def <- getOption('mc.cores')
@@ -977,21 +977,21 @@ Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examplesloo(mod1)
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
-#> Computed from 1000 by 161 log-likelihood matrix.
+#> Computed from 1000 by 164 log-likelihood matrix.
#>
#> Estimate SE
-#> elpd_loo -452.2 8.5
-#> p_loo 91.6 4.8
-#> looic 904.4 17.0
+#> elpd_loo -458.4 9.2
+#> p_loo 88.8 5.2
+#> looic 916.9 18.5
#> ------
#> MCSE of elpd_loo is NA.
-#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.6]).
+#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.3, 1.8]).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
-#> (-Inf, 0.67] (good) 67 41.6% 85
-#> (0.67, 1] (bad) 79 49.1% <NA>
-#> (1, Inf) (very bad) 15 9.3% <NA>
+#> (-Inf, 0.67] (good) 77 47.0% 78
+#> (0.67, 1] (bad) 77 47.0% <NA>
+#> (1, Inf) (very bad) 10 6.1% <NA>
#> See help('pareto-k-diagnostic') for details.
options(mc.cores = mc.cores.def)
@@ -1022,7 +1022,7 @@ Examples#> 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/RtmpYHBavU/model-46c47d355d4.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0192b6bd2.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)
@@ -1035,32 +1035,32 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 1 finished in 1.4 seconds.
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 2.0 seconds.
+#> Chain 2 finished in 1.4 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 1.6 seconds.
-#> Total execution time: 2.2 seconds.
+#> Mean chain execution time: 1.4 seconds.
+#> Total execution time: 1.6 seconds.
#>
# The mapping matrix is now supplied as data to the model in the 'Z' element
@@ -1124,7 +1124,7 @@ Examples#> }
#> model {
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 0, 2.5);
+#> b_raw[1] ~ student_t(3, -2.3, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 5] ~ multi_normal_prec(zero[2 : 5], S1[1 : 4, 1 : 4] * lambda[1]);
@@ -1213,6 +1213,9 @@ Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples data = data_train,
newdata = data_test,
chains = 2)
+#> Warning: gp effects in mvgam cannot yet handle autogrouping
+#> resetting all instances of 'gr = TRUE' to 'gr = FALSE'
+#> This warning is displayed once per session.
#> Compiling Stan program using cmdstanr
#>
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
@@ -1222,7 +1225,7 @@ Examples#> 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/RtmpYHBavU/model-46c9b418f5.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b0744353df.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)
@@ -1255,11 +1258,11 @@ Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 0.8 seconds.
-#> Chain 2 finished in 0.8 seconds.
+#> Chain 1 finished in 0.7 seconds.
+#> Chain 2 finished in 0.7 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 0.8 seconds.
+#> Mean chain execution time: 0.7 seconds.
#> Total execution time: 0.9 seconds.
#>
@@ -1267,7 +1270,7 @@ Examplessummary(mod)
#> GAM formula:
#> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> gaussian
@@ -1292,66 +1295,66 @@ Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#>
#> Observation error parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> sigma_obs[1] 0.44 0.49 0.55 1 1301
+#> sigma_obs[1] 0.44 0.49 0.55 1 1810
#>
#> GAM coefficient (beta) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) 4.000 4.0e+00 4.100 1.00 1985
-#> gp(time):temp.1 0.430 3.2e+00 6.700 1.00 962
-#> gp(time):temp.2 -3.300 1.5e+00 6.500 1.00 969
-#> gp(time):temp.3 -6.200 -1.4e+00 3.300 1.00 1060
-#> gp(time):temp.4 -5.700 -1.5e+00 2.800 1.00 952
-#> gp(time):temp.5 -3.700 2.0e-01 3.800 1.00 1123
-#> gp(time):temp.6 -2.500 6.1e-01 4.700 1.00 1104
-#> gp(time):temp.7 -3.200 -1.9e-01 2.900 1.00 831
-#> gp(time):temp.8 -2.700 -4.8e-02 2.300 1.00 1025
-#> gp(time):temp.9 -1.600 5.8e-01 3.200 1.00 863
-#> gp(time):temp.10 -2.100 -5.0e-02 1.800 1.00 1422
-#> gp(time):temp.11 -2.500 -4.5e-01 1.000 1.00 904
-#> gp(time):temp.12 -1.400 7.1e-02 1.900 1.00 1162
-#> gp(time):temp.13 -0.890 1.7e-01 1.900 1.00 1547
-#> gp(time):temp.14 -1.600 -2.3e-02 1.200 1.00 1174
-#> gp(time):temp.15 -1.600 -1.6e-02 1.000 1.00 1062
-#> gp(time):temp.16 -0.850 1.7e-03 1.500 1.00 1316
-#> gp(time):temp.17 -0.950 4.3e-04 1.300 1.00 1338
-#> gp(time):temp.18 -1.100 -1.8e-15 0.910 1.00 1409
-#> gp(time):temp.19 -0.980 -2.4e-08 0.930 1.00 1809
-#> gp(time):temp.20 -0.970 -3.8e-05 0.690 1.00 1603
-#> gp(time):temp.21 -0.510 3.2e-06 0.860 1.00 1660
-#> gp(time):temp.22 -0.370 3.0e-04 0.950 1.00 799
-#> gp(time):temp.23 -0.700 -5.4e-08 0.480 1.00 1358
-#> gp(time):temp.24 -0.850 -6.9e-07 0.290 1.00 939
-#> gp(time):temp.25 -0.330 5.3e-10 0.680 1.01 872
-#> gp(time):temp.26 -0.380 -6.0e-40 0.560 1.00 1064
-#> gp(time):temp.27 -0.600 -1.6e-09 0.260 1.00 1177
-#> gp(time):temp.28 -0.460 -1.6e-23 0.460 1.00 1112
-#> gp(time):temp.29 -0.230 2.7e-12 0.490 1.00 895
-#> gp(time):temp.30 -0.280 -2.5e-40 0.230 1.00 1522
-#> gp(time):temp.31 -0.610 -2.6e-21 0.200 1.00 934
-#> gp(time):temp.32 -0.240 3.5e-33 0.350 1.00 1125
-#> gp(time):temp.33 -0.200 5.5e-56 0.330 1.00 1734
-#> gp(time):temp.34 -0.210 -4.6e-36 0.150 1.00 1047
-#> gp(time):temp.35 -0.210 1.2e-44 0.230 1.00 1183
-#> gp(time):temp.36 -0.180 2.6e-29 0.190 1.00 1430
-#> gp(time):temp.37 -0.120 -4.7e-53 0.180 1.00 1225
-#> gp(time):temp.38 -0.160 -3.0e-57 0.082 1.00 1136
-#> gp(time):temp.39 -0.180 -5.8e-37 0.068 1.00 964
-#> gp(time):temp.40 -0.043 9.7e-43 0.160 1.00 728
+#> 2.5% 50% 97.5% Rhat n_eff
+#> (Intercept) 4.000 4.0e+00 4.100 1.00 1293
+#> gp(time):temp.1 0.089 3.1e+00 7.100 1.00 710
+#> gp(time):temp.2 -3.700 1.6e+00 7.100 1.00 535
+#> gp(time):temp.3 -6.900 -1.5e+00 3.500 1.00 879
+#> gp(time):temp.4 -6.100 -1.5e+00 2.700 1.00 477
+#> gp(time):temp.5 -3.800 2.1e-01 4.300 1.00 899
+#> gp(time):temp.6 -3.000 4.9e-01 4.100 1.00 710
+#> gp(time):temp.7 -3.700 -1.9e-01 3.400 1.00 353
+#> gp(time):temp.8 -3.100 -1.8e-02 2.300 1.00 1068
+#> gp(time):temp.9 -1.700 4.8e-01 3.400 1.00 432
+#> gp(time):temp.10 -2.400 -4.7e-03 2.400 1.00 699
+#> gp(time):temp.11 -2.500 -3.1e-01 0.820 1.00 712
+#> gp(time):temp.12 -1.200 4.0e-02 2.000 1.00 882
+#> gp(time):temp.13 -0.890 6.6e-02 2.000 1.00 777
+#> gp(time):temp.14 -1.500 -7.0e-03 1.100 1.00 1288
+#> gp(time):temp.15 -1.400 -5.0e-04 0.920 1.00 1238
+#> gp(time):temp.16 -0.710 1.3e-05 1.300 1.00 1092
+#> gp(time):temp.17 -0.710 2.3e-05 0.980 1.00 1305
+#> gp(time):temp.18 -0.940 -1.9e-11 0.790 1.00 1080
+#> gp(time):temp.19 -0.760 -1.4e-10 0.670 1.00 1266
+#> gp(time):temp.20 -0.910 -3.7e-09 0.460 1.00 976
+#> gp(time):temp.21 -0.490 -1.0e-14 0.660 1.00 1346
+#> gp(time):temp.22 -0.260 9.3e-08 0.820 1.00 1068
+#> gp(time):temp.23 -0.600 -7.3e-20 0.390 1.00 1091
+#> gp(time):temp.24 -0.540 -1.1e-08 0.190 1.01 722
+#> gp(time):temp.25 -0.200 8.3e-19 0.480 1.00 1042
+#> gp(time):temp.26 -0.240 1.2e-42 0.400 1.00 1194
+#> gp(time):temp.27 -0.430 -1.5e-18 0.130 1.00 900
+#> gp(time):temp.28 -0.230 -3.0e-56 0.250 1.00 1346
+#> gp(time):temp.29 -0.110 5.1e-24 0.430 1.00 973
+#> gp(time):temp.30 -0.250 -6.4e-35 0.160 1.00 1348
+#> gp(time):temp.31 -0.310 -1.8e-40 0.091 1.00 1028
+#> gp(time):temp.32 -0.140 -9.4e-74 0.130 1.01 827
+#> gp(time):temp.33 -0.063 3.0e-87 0.200 1.00 1123
+#> gp(time):temp.34 -0.160 -9.0e-49 0.068 1.00 1029
+#> gp(time):temp.35 -0.060 2.3e-42 0.120 1.00 1154
+#> gp(time):temp.36 -0.080 -9.4e-64 0.076 1.00 1226
+#> gp(time):temp.37 -0.076 -1.9e-41 0.075 1.00 1410
+#> gp(time):temp.38 -0.110 -4.3e-43 0.034 1.00 1029
+#> gp(time):temp.39 -0.041 2.1e-116 0.052 1.00 1174
+#> gp(time):temp.40 -0.016 3.7e-52 0.058 1.00 871
#>
#> GAM gp term marginal deviation (alpha) and length scale (rho) estimates:
-#> 2.5% 50% 97.5% Rhat n_eff
-#> alpha_gp(time):temp 0.18 0.33 0.78 1.00 508
-#> rho_gp(time):temp 9.30 29.00 90.00 1.01 382
+#> 2.5% 50% 97.5% Rhat n_eff
+#> alpha_gp(time):temp 0.17 0.34 0.83 1 273
+#> rho_gp(time):temp 12.00 32.00 100.00 1 305
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
-#> 29 of 1000 iterations ended with a divergence (2.9%)
+#> 33 of 1000 iterations ended with a divergence (3.3%)
#> *Try running with larger adapt_delta to remove the divergences
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:47:47 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:10:13 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
@@ -1360,7 +1363,7 @@ Examplesfc <- forecast(mod, newdata = data_test)
plot(fc)
#> Out of sample CRPS:
-#> 6.43188275110833
+#> 6.31126950637918
# Propagating the smooth term shows how the coefficient is expected to evolve
@@ -1397,7 +1400,7 @@ Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> 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/RtmpYHBavU/model-46c3dc259d2.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b06c442a55.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)
@@ -1410,32 +1413,32 @@ Examples#> Chain 2 Iteration: 1 / 1000 [ 0%] (Warmup)
#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
-#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
-#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
+#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
+#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
+#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 3.8 seconds.
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 5.0 seconds.
+#> Chain 1 finished in 3.6 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 4.0 seconds.
#>
#> Both chains finished successfully.
-#> Mean chain execution time: 4.4 seconds.
-#> Total execution time: 5.1 seconds.
+#> Mean chain execution time: 3.8 seconds.
+#> Total execution time: 4.2 seconds.
#>
# Inspect the model file to see the modification to the linear predictor
@@ -1488,7 +1491,7 @@ Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> mu_raw ~ std_normal();
#>
#> // prior for (Intercept)...
-#> b_raw[1] ~ student_t(3, 1.4, 2.5);
+#> b_raw[1] ~ student_t(3, 1.6, 2.5);
#>
#> // prior for s(season)...
#> b_raw[2 : 9] ~ multi_normal_prec(zero[2 : 9], S1[1 : 8, 1 : 8] * lambda[1]);
@@ -1537,10 +1540,10 @@ Exampleslayout(matrix(1:2, ncol = 2))
plot(fc, series = 1, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 22.781273
+#> 26.747011
plot(fc, series = 2, ylim = c(0, 75))
#> Out of sample DRPS:
-#> 77.61833
+#> 101.610568
layout(1)
@@ -1550,7 +1553,7 @@ Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examplesfc <- forecast(mod, newdata = dat$data_test)
plot(fc)
#> Out of sample DRPS:
-#> 38.523539
+#> 41.417288
# Relative Risks can be computed by fixing the offset to the same value
@@ -1619,7 +1622,7 @@ Examples#> 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/RtmpYHBavU/model-46c5b973bb6.hpp:2:
+#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp0U8hqj/model-20b02cf01a2b.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)
@@ -1633,27 +1636,27 @@ Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#> Chain 1 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup)
#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup)
-#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup)
+#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup)
#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup)
-#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup)
#> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling)
+#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup)
+#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup)
#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling)
-#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling)
#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling)
-#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling)
-#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling)
-#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling)
#> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling)
-#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 2 finished in 0.9 seconds.
+#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling)
#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling)
-#> Chain 1 finished in 1.1 seconds.
+#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling)
+#> Chain 1 finished in 0.9 seconds.
+#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling)
+#> Chain 2 finished in 1.0 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 1.0 seconds.
@@ -1662,7 +1665,7 @@ Examplessummary(mod)
#> GAM formula:
#> cbind(y, ntrials) ~ series + s(x, by = series)
-#> <environment: 0x0000021ebbca2828>
+#> <environment: 0x00000246410de130>
#>
#> Family:
#> binomial
@@ -1687,42 +1690,44 @@ Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
Examples#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
-#> (Intercept) -0.280 -0.17000 -0.036 1.00 592
-#> seriesseries2 -0.320 -0.15000 0.028 1.00 577
-#> s(x):seriesseries1.1 -0.120 0.02100 0.380 1.01 176
-#> s(x):seriesseries1.2 -0.190 0.00420 0.260 1.00 222
-#> s(x):seriesseries1.3 -0.088 -0.00440 0.063 1.00 307
-#> s(x):seriesseries1.4 -0.150 -0.00084 0.150 1.00 250
-#> s(x):seriesseries1.5 -0.064 0.00330 0.092 1.00 232
-#> s(x):seriesseries1.6 -0.120 -0.00120 0.130 1.00 253
-#> s(x):seriesseries1.7 -0.036 -0.00051 0.028 1.00 364
-#> s(x):seriesseries1.8 -0.440 0.00740 0.500 1.00 223
-#> s(x):seriesseries1.9 0.280 0.70000 0.920 1.01 171
-#> s(x):seriesseries2.1 -0.650 -0.07300 0.070 1.02 76
-#> s(x):seriesseries2.2 -0.270 0.02900 0.520 1.03 138
-#> s(x):seriesseries2.3 -0.068 0.01300 0.170 1.02 191
-#> s(x):seriesseries2.4 -0.160 0.02600 0.340 1.03 142
-#> s(x):seriesseries2.5 -0.180 -0.01700 0.055 1.03 127
-#> s(x):seriesseries2.6 -0.120 0.02400 0.310 1.03 130
-#> s(x):seriesseries2.7 -0.031 0.00420 0.079 1.00 374
-#> s(x):seriesseries2.8 -0.430 0.12000 1.200 1.03 117
-#> s(x):seriesseries2.9 -0.800 -0.58000 0.013 1.02 89
+#> (Intercept) -0.540 -0.41000 -0.260 1.00 679
+#> seriesseries2 0.007 0.19000 0.370 1.00 725
+#> s(x):seriesseries1.1 -0.160 0.04300 0.800 1.06 36
+#> s(x):seriesseries1.2 -0.540 -0.01500 0.480 1.00 136
+#> s(x):seriesseries1.3 -0.430 -0.00990 0.086 1.05 42
+#> s(x):seriesseries1.4 -0.220 -0.00910 0.290 1.00 122
+#> s(x):seriesseries1.5 -0.150 0.00330 0.100 1.00 126
+#> s(x):seriesseries1.6 -0.270 0.01100 0.210 1.00 123
+#> s(x):seriesseries1.7 -0.098 -0.00370 0.110 1.00 128
+#> s(x):seriesseries1.8 -1.300 -0.08100 1.100 1.00 144
+#> s(x):seriesseries1.9 0.034 1.10000 1.400 1.06 36
+#> s(x):seriesseries2.1 -0.320 -0.03100 0.140 1.00 209
+#> s(x):seriesseries2.2 -0.230 0.01100 0.270 1.00 201
+#> s(x):seriesseries2.3 -0.083 0.00850 0.130 1.00 379
+#> s(x):seriesseries2.4 -0.110 0.00150 0.140 1.00 234
+#> s(x):seriesseries2.5 -0.062 0.00180 0.063 1.00 339
+#> s(x):seriesseries2.6 -0.120 -0.00034 0.110 1.00 262
+#> s(x):seriesseries2.7 -0.045 -0.00015 0.053 1.00 273
+#> s(x):seriesseries2.8 -0.550 0.00500 0.690 1.00 228
+#> s(x):seriesseries2.9 -1.000 -0.77000 -0.390 1.00 197
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
-#> s(x):seriesseries1 2.12 9 27.4 < 2e-16 ***
-#> s(x):seriesseries2 1.77 9 38.8 0.00017 ***
+#> s(x):seriesseries1 2.04 9 88.8 <2e-16 ***
+#> s(x):seriesseries2 1.17 9 34.3 2e-04 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
-#> Rhat looks reasonable for all parameters
-#> 0 of 1000 iterations ended with a divergence (0%)
-#> 0 of 1000 iterations saturated the maximum tree depth of 12 (0%)
+#> Rhats above 1.05 found for 3 parameters
+#> *Diagnose further to investigate why the chains have not mixed
+#> 1 of 1000 iterations ended with a divergence (0.1%)
+#> *Try running with larger adapt_delta to remove the divergences
+#> 0 of 1000 iterations saturated the maximum tree depth of 10 (0%)
#> E-FMI indicated no pathological behavior
#>
-#> Samples were drawn using NUTS(diag_e) at Wed Nov 13 8:48:51 AM 2024.
+#> Samples were drawn using NUTS(diag_e) at Fri Nov 15 10:11:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
diff --git a/docs/reference/sim_mvgam-1.png b/docs/reference/sim_mvgam-1.png
index 8df34a89..a1097f1d 100644
Binary files a/docs/reference/sim_mvgam-1.png and b/docs/reference/sim_mvgam-1.png differ
diff --git a/docs/reference/sim_mvgam-2.png b/docs/reference/sim_mvgam-2.png
index ceda0f49..ccb321da 100644
Binary files a/docs/reference/sim_mvgam-2.png and b/docs/reference/sim_mvgam-2.png differ
diff --git a/docs/reference/sim_mvgam.html b/docs/reference/sim_mvgam.html
index f641d637..f5e76735 100644
--- a/docs/reference/sim_mvgam.html
+++ b/docs/reference/sim_mvgam.html
@@ -1,9 +1,11 @@
Simulate a set of time series for mvgam modelling — sim_mvgam • mvgam
@@ -63,8 +65,9 @@
This function simulates sets of time series data for fitting a multivariate GAM that includes
-shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e.
-correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random
+dependencies among series, i.e. correlations in their long-term trends, are included
+in the form of correlated loadings on the latent dynamic factors
@@ -102,13 +105,16 @@ ArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
diff --git a/man/forecast.mvgam.Rd b/man/forecast.mvgam.Rd
index 45070d31..0291f212 100644
--- a/man/forecast.mvgam.Rd
+++ b/man/forecast.mvgam.Rd
@@ -61,7 +61,8 @@ mod <- mvgam(y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Hindcasts on response scale
hc <- hindcast(mod)
diff --git a/man/lfo_cv.mvgam.Rd b/man/lfo_cv.mvgam.Rd
index ea6b0de3..10d61aa9 100644
--- a/man/lfo_cv.mvgam.Rd
+++ b/man/lfo_cv.mvgam.Rd
@@ -98,7 +98,8 @@ mod_ar2 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Fit a less appropriate model
mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
@@ -108,7 +109,8 @@ mod_rw <- mvgam(y ~ s(season, bs = 'cc', k = 6),
newdata = dat$data_test,
burnin = 300,
samples = 300,
- chains = 2)
+ chains = 2,
+ silent = 2)
# Compare Discrete Ranked Probability Scores for the testing period
fc_ar2 <- forecast(mod_ar2)
@@ -124,10 +126,12 @@ sum(score_rw$series_1$score)
# for estimating model parameters
lfo_ar2 <- lfo_cv(mod_ar2,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
lfo_rw <- lfo_cv(mod_rw,
min_t = 40,
- fc_horizon = 3)
+ fc_horizon = 3,
+ silent = 2)
# Plot Pareto-K values and ELPD estimates
plot(lfo_ar2)
diff --git a/man/loo.mvgam.Rd b/man/loo.mvgam.Rd
index 34b184fc..8899fcc5 100644
--- a/man/loo.mvgam.Rd
+++ b/man/loo.mvgam.Rd
@@ -72,7 +72,8 @@ mod1 <- mvgam(y ~ s(season, bs = 'cc', k = 6),
data = rbind(simdat$data_train,
simdat$data_test),
family = gaussian(),
- chains = 2)
+ chains = 2,
+ silent = 2)
# Inspect the model and calculate LOO
conditional_effects(mod1)
@@ -85,14 +86,16 @@ mod2 <- update(mod1,
formula = y ~ s(season, bs = 'cc', k = 6) +
s(season, series, bs = 'fs',
xt = list(bs = 'cc'), k = 4),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod2)
loo(mod2)
# Now add AR1 dynamic errors to mod2
mod3 <- update(mod2,
trend_model = AR(),
- chains = 2)
+ chains = 2,
+ silent = 2)
conditional_effects(mod3)
plot(mod3, type = 'trend')
loo(mod3)
diff --git a/man/mvgam_marginaleffects.Rd b/man/mvgam_marginaleffects.Rd
index 16e6648e..5564cfdb 100644
--- a/man/mvgam_marginaleffects.Rd
+++ b/man/mvgam_marginaleffects.Rd
@@ -86,8 +86,6 @@ arguments.}
\item \code{newdata = datagrid(cyl = c(4, 6))}: \code{cyl} variable equal to 4 and 6 and other regressors fixed at their means or modes.
\item See the Examples section and the \code{\link[marginaleffects:datagrid]{datagrid()}} documentation.
}
-\item \code{\link[=subset]{subset()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = subset(treatment == 1)}
-\item \code{\link[dplyr:filter]{dplyr::filter()}} call with a single argument to select a subset of the dataset used to fit the model, ex: \code{newdata = filter(treatment == 1)}
\item string:
\itemize{
\item "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.
diff --git a/src/RcppExports.o b/src/RcppExports.o
index 03b01119..5cf5ae21 100644
Binary files a/src/RcppExports.o and b/src/RcppExports.o differ
diff --git a/src/trend_funs.o b/src/trend_funs.o
index 1c0d5a8f..e09f58e3 100644
Binary files a/src/trend_funs.o and b/src/trend_funs.o differ
This function simulates sets of time series data for fitting a multivariate GAM that includes -shared seasonality and dependence on state-space latent dynamic factors. Random dependencies among series, i.e. -correlations in their long-term trends, are included in the form of correlated loadings on the latent dynamic factors
+shared seasonality and dependence on state-space latent dynamic factors. Random +dependencies among series, i.e. correlations in their long-term trends, are included +in the form of correlated loadings on the latent dynamic factorsArgumentsArgumentsgam)
+character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that
+contributes to the linear predictor, and the observation process is the only
+source of error; similarly to what is estimated by gam
)
RW
(random walk with possible drift)
AR1
(with possible drift)
AR2
(with possible drift)
@@ -134,7 +142,8 @@ ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
@@ -184,25 +194,30 @@ Arguments
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
+A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies
character
specifying the time series dynamics for the latent trend.
+Options are:
None
(no latent trend component; i.e. the GAM component is all that +contributes to the linear predictor, and the observation process is the only +source of error; similarly to what is estimated bygam
)RW
(random walk with possible drift)AR1
(with possible drift)AR2
(with possible drift)
@@ -134,7 +142,8 @@
ArgumentsArgumentsnb(), poisson()
, bernoulli()
, tweedie()
, gaussian()
,
betar()
, lognormal()
, student()
and Gamma()
Value
-A list
object containing outputs needed for mvgam
, including 'data_train' and 'data_test',
-as well as some additional information about the simulated seasonality and trend dependencies
A list
object containing outputs needed for mvgam
,
+including 'data_train' and 'data_test', as well as some additional information
+about the simulated seasonality and trend dependencies