diff --git a/R/how_to_cite.R b/R/how_to_cite.R index 11880d4e..92e79283 100644 --- a/R/how_to_cite.R +++ b/R/how_to_cite.R @@ -239,7 +239,7 @@ how_to_cite.mvgam <- function(object, ...){ # List of additional, possibly very useful references other_citations <- vector(mode = 'list') - other_citations[[1]] <- "Arel-Bundock V (2024). marginaleffects: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests. R package version 0.19.0.4, https://marginaleffects.com/." + other_citations[[1]] <- "Arel-Bundock, V, Greifer, N, and Heiss, A (2024). How to interpret statistical models using marginaleffects for R and Python. Journal of Statistical Software, 111(9), 1–32. https://doi.org/10.18637/jss.v111.i09" other_citations[[2]] <- "Gabry J, Simpson D, Vehtari A, Betancourt M, and Gelman A (2019). Visualization in Bayesian workflow. Journal of the Royal Statatistical Society A, 182, 389-402. doi:10.1111/rssa.12378." other_citations[[3]] <- "Vehtari A, Gelman A, and Gabry J (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing, 27, 1413-1432. doi:10.1007/s11222-016-9696-4." other_citations[[4]] <- "Burkner, PC, Gabry, J, and Vehtari, A. (2020). Approximate leave-future-out cross-validation for Bayesian time series models. Journal of Statistical Computation and Simulation, 90(14), 2499-2523. https://doi.org/10.1080/00949655.2020.1783262" diff --git a/R/mvgam.R b/R/mvgam.R index ebc576a2..bd73bc07 100644 --- a/R/mvgam.R +++ b/R/mvgam.R @@ -132,6 +132,7 @@ #'should depend on. The `series` column should have a single unique entry for each series in the #'data (names should perfectly match factor levels of the `series` variable in `data`). Note that #'if this is supplied, the intercept parameter in the process model will NOT be automatically suppressed. +#'Not yet supported for models in wich the latent factors evolve in continuous time (`CAR()`). #'See examples for details #'@param noncentred \code{logical} Use the non-centred parameterisation for autoregressive #'trend models? Setting to `TRUE` will reparameterise the model to avoid possible diff --git a/R/validations.R b/R/validations.R index b68b3316..50574a81 100644 --- a/R/validations.R +++ b/R/validations.R @@ -666,11 +666,11 @@ validate_trendmap = function(trend_map, call. = FALSE) } - # No point in trend mapping if trend model is 'None' - # if(trend_model == 'None'){ - # stop('cannot set up latent trends when "trend_model = None"', - # call. = FALSE) - # } + # Cannot yet map observations to trends that evolve as CAR1 + if(trend_model == 'CAR1'){ + stop('cannot yet use trend mapping for CAR1 dynamics', + call. = FALSE) + } # trend_map must have an entry for each unique time series if(!all(sort(trend_map$series) == sort(unique(data_train$series)))){ diff --git a/docs/reference/figures/README-unnamed-chunk-12-1.png b/docs/reference/figures/README-unnamed-chunk-12-1.png index ba237196..0850bb10 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-12-1.png and b/docs/reference/figures/README-unnamed-chunk-12-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-13-1.png b/docs/reference/figures/README-unnamed-chunk-13-1.png index 127034a1..bb602c92 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-13-1.png and b/docs/reference/figures/README-unnamed-chunk-13-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-14-1.png b/docs/reference/figures/README-unnamed-chunk-14-1.png index a99aefbf..d8bff99a 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-14-1.png and b/docs/reference/figures/README-unnamed-chunk-14-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-15-1.png b/docs/reference/figures/README-unnamed-chunk-15-1.png index 18ea06c7..40bf451c 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-15-1.png and b/docs/reference/figures/README-unnamed-chunk-15-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-16-1.png b/docs/reference/figures/README-unnamed-chunk-16-1.png index 12a473f3..e7c65480 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-16-1.png and b/docs/reference/figures/README-unnamed-chunk-16-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-17-1.png b/docs/reference/figures/README-unnamed-chunk-17-1.png index 3de4b3bb..9e8014fa 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-17-1.png and b/docs/reference/figures/README-unnamed-chunk-17-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-18-1.png b/docs/reference/figures/README-unnamed-chunk-18-1.png index f28779ef..08f9e75a 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-18-1.png and b/docs/reference/figures/README-unnamed-chunk-18-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-19-1.png b/docs/reference/figures/README-unnamed-chunk-19-1.png index ed452b78..88ab7c52 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-19-1.png and b/docs/reference/figures/README-unnamed-chunk-19-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-20-1.png b/docs/reference/figures/README-unnamed-chunk-20-1.png index cd9e7c18..a8890069 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-20-1.png and b/docs/reference/figures/README-unnamed-chunk-20-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-21-1.png b/docs/reference/figures/README-unnamed-chunk-21-1.png index 01a1b184..1d3c38da 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-21-1.png and b/docs/reference/figures/README-unnamed-chunk-21-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-22-1.png b/docs/reference/figures/README-unnamed-chunk-22-1.png index c795a5b4..c5b32b71 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-22-1.png and b/docs/reference/figures/README-unnamed-chunk-22-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-23-1.png b/docs/reference/figures/README-unnamed-chunk-23-1.png index f1489416..0ca5e159 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-23-1.png and b/docs/reference/figures/README-unnamed-chunk-23-1.png differ diff --git a/docs/reference/figures/README-unnamed-chunk-24-1.png b/docs/reference/figures/README-unnamed-chunk-24-1.png index 85316a55..1496cf88 100644 Binary files a/docs/reference/figures/README-unnamed-chunk-24-1.png and b/docs/reference/figures/README-unnamed-chunk-24-1.png differ diff --git a/docs/reference/get_mvgam_priors.html b/docs/reference/get_mvgam_priors.html index ae25ef0e..cf714f8b 100644 --- a/docs/reference/get_mvgam_priors.html +++ b/docs/reference/get_mvgam_priors.html @@ -227,6 +227,7 @@

ArgumentsCAR()). See examples for details

diff --git a/docs/reference/mvgam-1.png b/docs/reference/mvgam-1.png index 430cb723..30c0c29e 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 ab6fc134..3e183369 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 0f864a45..416b2b96 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 7fb172a3..bcbb890a 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 5c5198d1..5a22bf8b 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 05d7a3e8..a38654de 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 5aeef53d..ea4b3b07 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 4c128b6a..fb1ba042 100644 Binary files a/docs/reference/mvgam-16.png and b/docs/reference/mvgam-16.png differ diff --git a/docs/reference/mvgam-2.png b/docs/reference/mvgam-2.png index 8a176cf1..cf764245 100644 Binary files a/docs/reference/mvgam-2.png and b/docs/reference/mvgam-2.png differ diff --git a/docs/reference/mvgam-24.png b/docs/reference/mvgam-24.png index 76b2451b..031abbd0 100644 Binary files a/docs/reference/mvgam-24.png and b/docs/reference/mvgam-24.png differ diff --git a/docs/reference/mvgam-3.png b/docs/reference/mvgam-3.png index 6d0bc3b9..62a9851f 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 b290e5c0..f936b951 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 7b430034..b4484735 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 bdd1850d..b1ecf3ec 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 b07e1e63..e3046657 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 7895105e..ee5062ae 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 017508fd..c4e7f9c6 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 c4ad0ae3..390bfcd0 100644 --- a/docs/reference/mvgam.html +++ b/docs/reference/mvgam.html @@ -270,6 +270,7 @@

ArgumentsCAR()). See examples for details

@@ -534,6 +535,7 @@

Examples # Plot key summary statistics for a single series plot_mvgam_series(data = dat$data_train, series = 1) +#> Warning: Removed 5 rows containing non-finite outside the scale range (`stat_bin()`). # Plot all series together @@ -692,37 +694,37 @@

Examples#> 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: 300 / 1000 [ 30%] (Warmup) #> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup) -#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup) -#> Chain 2 Iteration: 501 / 1000 [ 50%] (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: 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: 700 / 1000 [ 70%] (Sampling) +#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling) +#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) #> 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: 900 / 1000 [ 90%] (Sampling) +#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) +#> Chain 1 finished in 2.1 seconds. #> Chain 2 finished in 1.9 seconds. -#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 1 finished in 2.2 seconds. #> #> Both chains finished successfully. #> Mean chain execution time: 2.0 seconds. -#> Total execution time: 2.5 seconds. +#> Total execution time: 2.4 seconds. #> # Extract the model summary summary(mod1) #> GAM formula: #> y ~ s(season, bs = "cc", k = 6) -#> <environment: 0x0000025921362870> +#> <environment: 0x0000025cc9b7c500> #> #> Family: #> poisson @@ -748,26 +750,26 @@

Examples#> #> GAM coefficient (beta) estimates: #> 2.5% 50% 97.5% Rhat n_eff -#> (Intercept) 1.900 2.00 2.10 1 704 -#> s(season).1 0.047 0.30 0.52 1 586 -#> s(season).2 0.590 0.82 1.10 1 491 -#> s(season).3 -0.045 0.18 0.42 1 676 -#> s(season).4 -0.660 -0.42 -0.18 1 698 +#> (Intercept) 1.900 2.00 2.10 1.01 700 +#> s(season).1 0.073 0.31 0.54 1.00 812 +#> s(season).2 0.600 0.82 1.10 1.00 657 +#> s(season).3 -0.067 0.18 0.41 1.00 808 +#> s(season).4 -0.680 -0.42 -0.20 1.00 679 #> #> Approximate significance of GAM smooths: -#> edf Ref.df Chi.sq p-value -#> s(season) 3.8 4 35.4 <2e-16 *** +#> edf Ref.df Chi.sq p-value +#> s(season) 3.65 4 37.2 <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.33 0.71 0.980 1.00 335 -#> ar1[2] -0.96 -0.41 0.032 1.01 197 -#> ar1[3] 0.21 0.69 0.970 1.00 279 -#> sigma[1] 0.41 0.56 0.770 1.01 413 -#> sigma[2] 0.33 0.49 0.700 1.00 338 -#> sigma[3] 0.37 0.51 0.700 1.00 337 +#> ar1[1] 0.27 0.72 0.990 1.00 323 +#> ar1[2] -0.95 -0.43 0.013 1.00 222 +#> ar1[3] 0.23 0.69 0.980 1.01 313 +#> sigma[1] 0.42 0.57 0.770 1.00 482 +#> sigma[2] 0.34 0.49 0.670 1.00 339 +#> sigma[3] 0.38 0.51 0.710 1.00 468 #> #> Stan MCMC diagnostics: #> n_eff / iter looks reasonable for all parameters @@ -776,10 +778,12 @@

Examples#> 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 Fri Nov 22 7:55:50 AM 2024. +#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 3:39:38 PM 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) +#> +#> Use how_to_cite(mod1) to get started describing this model # Plot the estimated historical trend and forecast for one series plot(mod1, type = 'trend', series = 1) @@ -792,7 +796,7 @@

Examples resids <- residuals(mod1) str(resids) -#> num [1:180, 1:4] -0.152 NaN -0.123 0.295 -0.862 ... +#> num [1:180, 1:4] -0.153 NaN -0.14 0.259 -0.824 ... #> - attr(*, "dimnames")=List of 2 #> ..$ : NULL #> ..$ : chr [1:4] "Estimate" "Est.Error" "Q2.5" "Q97.5" @@ -802,16 +806,16 @@

Examples#> # A tibble: 180 × 14 #> y season year series time .observed .fitted .fit.variability #> <int> <int> <int> <fct> <int> <int> <dbl> <dbl> -#> 1 4 1 1 series_1 1 4 4.67 1.59 -#> 2 NA 1 1 series_2 1 NA 6.76 3.47 -#> 3 4 1 1 series_3 1 4 4.56 1.50 -#> 4 5 2 1 series_1 2 5 4.72 1.72 -#> 5 2 2 1 series_2 2 2 3.87 1.43 -#> 6 NA 2 1 series_3 2 NA 5.10 2.75 -#> 7 7 3 1 series_1 3 7 8.53 2.39 -#> 8 12 3 1 series_2 3 12 11.4 2.88 -#> 9 4 3 1 series_3 3 4 5.34 1.81 -#> 10 39 4 1 series_1 4 39 35.9 5.66 +#> 1 4 1 1 series_1 1 4 4.67 1.63 +#> 2 NA 1 1 series_2 1 NA 6.91 3.71 +#> 3 4 1 1 series_3 1 4 4.63 1.65 +#> 4 5 2 1 series_1 2 5 4.77 1.65 +#> 5 2 2 1 series_2 2 2 3.81 1.53 +#> 6 NA 2 1 series_3 2 NA 5.21 2.96 +#> 7 7 3 1 series_1 3 7 8.50 2.47 +#> 8 12 3 1 series_2 3 12 11.4 2.87 +#> 9 4 3 1 series_3 3 4 5.33 1.88 +#> 10 39 4 1 series_1 4 39 36.3 5.63 #> # ℹ 170 more rows #> # ℹ 6 more variables: .fit.cred.low <dbl>, .fit.cred.high <dbl>, .resid <dbl>, #> # .resid.variability <dbl>, .resid.cred.low <dbl>, .resid.cred.high <dbl> @@ -821,7 +825,7 @@

Examplesstr(fc) #> List of 16 #> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6) -#> .. ..- attr(*, ".Environment")=<environment: 0x0000025921362870> +#> .. ..- attr(*, ".Environment")=<environment: 0x0000025cc9b7c500> #> $ trend_call : NULL #> $ family : chr "poisson" #> $ family_pars : NULL @@ -850,26 +854,26 @@

Examples#> ..$ 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] 0 3 5 2 7 7 7 4 7 3 ... +#> ..$ series_1: num [1:1000, 1:60] 9 3 3 4 3 0 1 3 5 1 ... #> .. ..- 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] 13 3 18 5 7 6 20 0 3 3 ... +#> ..$ series_2: num [1:1000, 1:60] 8 8 8 5 7 2 7 4 14 15 ... #> .. ..- 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] 8 3 3 7 12 6 5 3 3 9 ... +#> ..$ series_3: num [1:1000, 1:60] 8 7 2 7 2 6 4 8 2 3 ... #> .. ..- 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] 8 2 1 11 5 5 3 7 16 4 ... -#> ..$ series_2: int [1:1000, 1:20] 5 2 3 5 28 24 9 7 3 7 ... -#> ..$ series_3: int [1:1000, 1:20] 4 12 15 4 5 13 10 1 4 8 ... +#> ..$ series_1: int [1:1000, 1:20] 4 7 0 5 2 2 4 5 3 2 ... +#> ..$ series_2: int [1:1000, 1:20] 7 1 7 2 1 6 4 23 6 9 ... +#> ..$ series_3: int [1:1000, 1:20] 17 17 6 4 24 59 4 7 3 2 ... #> - attr(*, "class")= chr "mvgam_forecast" plot(fc) #> Out of sample DRPS: -#> 57.690845 +#> 58.635904 # Plot the estimated seasonal smooth function @@ -907,19 +911,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 2.03254 0.299574 0.729872 -0.08774370 -0.152966 -#> 2 1.93907 0.389768 0.775010 0.17542300 -0.338085 -#> 3 1.96962 0.373643 0.756057 0.14505700 -0.108823 -#> 4 1.99381 0.293762 0.869831 0.10669500 -0.353948 -#> 5 2.02935 0.156223 0.861661 -0.00555928 -0.397319 -#> 6 1.92826 0.288386 0.894447 0.07278630 -0.402713 +#> 1 1.97964 0.413653 0.554764 0.0807428 -0.315228 +#> 2 2.10693 0.248991 0.697108 0.3061830 -0.319406 +#> 3 2.00565 0.320152 0.618197 0.1136640 -0.277634 +#> 4 2.00294 0.264006 0.717158 0.3905300 -0.310346 +#> 5 1.92716 0.326294 0.817396 0.1930310 -0.251881 +#> 6 1.95209 0.312626 0.835127 0.1844960 -0.216079 str(beta_draws_df) #> 'data.frame': 1000 obs. of 5 variables: -#> $ (Intercept): num 2.03 1.94 1.97 1.99 2.03 ... -#> $ s(season).1: num 0.3 0.39 0.374 0.294 0.156 ... -#> $ s(season).2: num 0.73 0.775 0.756 0.87 0.862 ... -#> $ s(season).3: num -0.08774 0.17542 0.14506 0.10669 -0.00556 ... -#> $ s(season).4: num -0.153 -0.338 -0.109 -0.354 -0.397 ... +#> $ (Intercept): num 1.98 2.11 2.01 2 1.93 ... +#> $ s(season).1: num 0.414 0.249 0.32 0.264 0.326 ... +#> $ s(season).2: num 0.555 0.697 0.618 0.717 0.817 ... +#> $ s(season).3: num 0.0807 0.3062 0.1137 0.3905 0.193 ... +#> $ s(season).4: num -0.315 -0.319 -0.278 -0.31 -0.252 ... # Investigate model fit mc.cores.def <- getOption('mc.cores') @@ -930,18 +934,18 @@

Examples#> Computed from 1000 by 164 log-likelihood matrix. #> #> Estimate SE -#> elpd_loo -462.1 9.0 -#> p_loo 91.9 5.0 -#> looic 924.3 18.0 +#> elpd_loo -455.4 8.3 +#> p_loo 85.3 4.3 +#> looic 910.8 16.6 #> ------ #> MCSE of elpd_loo is NA. -#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.4, 1.9]). +#> MCSE and ESS estimates assume MCMC draws (r_eff in [0.4, 2.0]). #> #> Pareto k diagnostic values: #> Count Pct. Min. ESS -#> (-Inf, 0.67] (good) 73 44.5% 50 -#> (0.67, 1] (bad) 82 50.0% <NA> -#> (1, Inf) (very bad) 9 5.5% <NA> +#> (-Inf, 0.67] (good) 81 49.4% 84 +#> (0.67, 1] (bad) 75 45.7% <NA> +#> (1, Inf) (very bad) 8 4.9% <NA> #> See help('pareto-k-diagnostic') for details. options(mc.cores = mc.cores.def) @@ -972,32 +976,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: 700 / 1000 [ 70%] (Sampling) #> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling) -#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 2 finished in 2.4 seconds. +#> 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 3.0 seconds. +#> Chain 1 finished in 3.1 seconds. +#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) +#> Chain 2 finished in 3.2 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 2.7 seconds. -#> Total execution time: 3.3 seconds. +#> Mean chain execution time: 3.1 seconds. +#> Total execution time: 3.7 seconds. #> # The mapping matrix is now supplied as data to the model in the 'Z' element @@ -1181,20 +1185,20 @@

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 1.3 seconds. +#> Chain 1 finished in 1.4 seconds. #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) #> Chain 2 finished in 1.4 seconds. #> #> Both chains finished successfully. #> Mean chain execution time: 1.4 seconds. -#> Total execution time: 1.8 seconds. +#> Total execution time: 1.9 seconds. #> # Inspect the model summary, forecast and time-varying coefficient distribution summary(mod) #> GAM formula: #> out ~ gp(time, by = temp, c = 5/4, k = 40, scale = FALSE) -#> <environment: 0x0000025921362870> +#> <environment: 0x0000025cc9b7c500> #> #> Family: #> gaussian @@ -1278,10 +1282,12 @@

Examples#> 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 Fri Nov 22 7:57:41 AM 2024. +#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 3:41:27 PM 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) +#> +#> Use how_to_cite(mod) to get started describing this model plot(mod, type = 'smooths') fc <- forecast(mod, newdata = data_test) @@ -1331,8 +1337,8 @@

Examples#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup) #> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup) #> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup) -#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling) #> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup) +#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling) #> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling) #> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling) @@ -1343,13 +1349,13 @@

Examples#> 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 12.7 seconds. +#> Chain 2 finished in 12.9 seconds. #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 1 finished in 13.8 seconds. +#> Chain 1 finished in 13.9 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 13.2 seconds. -#> Total execution time: 14.0 seconds. +#> Mean chain execution time: 13.4 seconds. +#> Total execution time: 14.2 seconds. #> # Inspect the model file to see the modification to the linear predictor @@ -1558,12 +1564,12 @@

Examples#> #> Both chains finished successfully. #> Mean chain execution time: 2.6 seconds. -#> Total execution time: 2.9 seconds. +#> Total execution time: 3.1 seconds. #> summary(mod) #> GAM formula: #> cbind(y, ntrials) ~ series + s(x, by = series) -#> <environment: 0x0000025921362870> +#> <environment: 0x0000025cc9b7c500> #> #> Family: #> binomial @@ -1623,10 +1629,12 @@

Examples#> 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 Fri Nov 22 7:59:26 AM 2024. +#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 3:43:14 PM 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) +#> +#> Use how_to_cite(mod) to get started describing this model pp_check(mod, type = "bars_grouped", group = "series", ndraws = 50) diff --git a/docs/reference/update.mvgam-1.png b/docs/reference/update.mvgam-1.png index df7b3b51..754c9a42 100644 Binary files a/docs/reference/update.mvgam-1.png and b/docs/reference/update.mvgam-1.png differ diff --git a/docs/reference/update.mvgam-2.png b/docs/reference/update.mvgam-2.png index 308521a2..95886f7e 100644 Binary files a/docs/reference/update.mvgam-2.png and b/docs/reference/update.mvgam-2.png differ diff --git a/docs/reference/update.mvgam-3.png b/docs/reference/update.mvgam-3.png index 5a8ef548..d38d15bb 100644 Binary files a/docs/reference/update.mvgam-3.png and b/docs/reference/update.mvgam-3.png differ diff --git a/docs/reference/update.mvgam.html b/docs/reference/update.mvgam.html index 9bb42778..5e426ca5 100644 --- a/docs/reference/update.mvgam.html +++ b/docs/reference/update.mvgam.html @@ -238,6 +238,7 @@

ArgumentsCAR()). See examples for details

@@ -371,29 +372,29 @@

Examples#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup) #> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup) -#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup) #> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling) +#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup) +#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling) #> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup) #> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling) -#> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling) -#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling) +#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) #> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) #> Chain 1 finished in 0.9 seconds. #> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling) #> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 2 finished in 1.2 seconds. +#> Chain 2 finished in 1.3 seconds. #> #> Both chains finished successfully. #> Mean chain execution time: 1.1 seconds. -#> Total execution time: 1.6 seconds. +#> Total execution time: 1.8 seconds. #> summary(mod) #> GAM formula: #> y ~ s(season, bs = "cc") -#> <environment: 0x0000024db9be6178> +#> <environment: 0x0000025cdedd43e0> #> #> Family: #> poisson @@ -447,10 +448,12 @@

Examples#> 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 Mon Nov 18 10:36:57 AM 2024. +#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 3:44:24 PM 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) +#> +#> Use how_to_cite(mod) to get started describing this model conditional_effects(mod, type = 'link') @@ -464,14 +467,14 @@

Examples#> #> 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: 1 / 1000 [ 0%] (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 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 1 Iteration: 600 / 1000 [ 60%] (Sampling) @@ -485,18 +488,18 @@

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 1.0 seconds. +#> Chain 1 finished in 1.1 seconds. #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 2 finished in 1.0 seconds. +#> Chain 2 finished in 1.1 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 1.0 seconds. -#> Total execution time: 1.4 seconds. +#> Mean chain execution time: 1.1 seconds. +#> Total execution time: 1.5 seconds. #> summary(updated_mod) #> GAM formula: #> y ~ s(season, bs = "cc") -#> <environment: 0x0000024db9be6178> +#> <environment: 0x0000025cdedd43e0> #> #> Family: #> poisson @@ -549,10 +552,12 @@

Examples#> 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 Mon Nov 18 10:37:46 AM 2024. +#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 3:45:15 PM 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) +#> +#> Use how_to_cite(updated_mod) to get started describing this model conditional_effects(updated_mod, type = 'link') @@ -575,10 +580,10 @@

Examples#> 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 2 Iteration: 100 / 1000 [ 10%] (Warmup) +#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup) #> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup) #> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup) @@ -587,23 +592,23 @@

Examples#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling) #> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling) #> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) -#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) #> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) +#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) #> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling) -#> Chain 1 finished in 0.8 seconds. +#> Chain 1 finished in 0.9 seconds. #> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 2 finished in 0.8 seconds. +#> Chain 2 finished in 0.9 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 0.8 seconds. +#> Mean chain execution time: 0.9 seconds. #> Total execution time: 1.3 seconds. #> summary(updated_mod) #> GAM formula: #> cbind(y, trials) ~ s(season, bs = "cc") -#> <environment: 0x0000024db9be6178> +#> <environment: 0x0000025cdedd43e0> #> #> Family: #> binomial @@ -657,10 +662,12 @@

Examples#> 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 Mon Nov 18 10:38:34 AM 2024. +#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 3:46:04 PM 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) +#> +#> Use how_to_cite(updated_mod) to get started describing this model conditional_effects(updated_mod, type = 'link') # } diff --git a/man/get_mvgam_priors.Rd b/man/get_mvgam_priors.Rd index 9a1fe91a..b50f3ecc 100644 --- a/man/get_mvgam_priors.Rd +++ b/man/get_mvgam_priors.Rd @@ -146,6 +146,7 @@ different observation processes. If supplied, a latent factor model is set up by should depend on. The \code{series} column should have a single unique entry for each series in the data (names should perfectly match factor levels of the \code{series} variable in \code{data}). Note that if this is supplied, the intercept parameter in the process model will NOT be automatically suppressed. +Not yet supported for models in wich the latent factors evolve in continuous time (\code{CAR()}). See examples for details} \item{...}{Not currently used} diff --git a/man/mvgam.Rd b/man/mvgam.Rd index 1b10e416..2fe399f3 100644 --- a/man/mvgam.Rd +++ b/man/mvgam.Rd @@ -174,6 +174,7 @@ different observation processes. If supplied, a latent factor model is set up by should depend on. The \code{series} column should have a single unique entry for each series in the data (names should perfectly match factor levels of the \code{series} variable in \code{data}). Note that if this is supplied, the intercept parameter in the process model will NOT be automatically suppressed. +Not yet supported for models in wich the latent factors evolve in continuous time (\code{CAR()}). See examples for details} \item{priors}{An optional \code{data.frame} with prior diff --git a/man/update.mvgam.Rd b/man/update.mvgam.Rd index e2091211..ad20fdff 100644 --- a/man/update.mvgam.Rd +++ b/man/update.mvgam.Rd @@ -163,6 +163,7 @@ different observation processes. If supplied, a latent factor model is set up by should depend on. The \code{series} column should have a single unique entry for each series in the data (names should perfectly match factor levels of the \code{series} variable in \code{data}). Note that if this is supplied, the intercept parameter in the process model will NOT be automatically suppressed. +Not yet supported for models in wich the latent factors evolve in continuous time (\code{CAR()}). See examples for details} \item{use_lv}{\code{logical}. If \code{TRUE}, use dynamic factors to estimate series'