diff --git a/R/jsdgam.R b/R/jsdgam.R index 66114097..1fc0b162 100644 --- a/R/jsdgam.R +++ b/R/jsdgam.R @@ -195,7 +195,7 @@ #' geom_histogram() + #' facet_wrap(~ species, scales = 'free') #' -#' ggplot(dat, aes(x = lat, y = lon, col = log(count + 1))) + +#' ggplot(dat, aes(x = lon, y = lat, col = log(count + 1))) + #' geom_point(size = 2.25) + #' facet_wrap(~ species, scales = 'free') + #' scale_color_viridis_c() + @@ -209,7 +209,7 @@ #' #' # Each factor estimates a different nonlinear spatial process, using #' # 'by = trend' as in other mvgam State-Space models -#' factor_formula = ~ gp(lat, lon, k = 6, by = trend) - 1, +#' factor_formula = ~ gp(lon, lat, k = 6, by = trend) - 1, #' n_lv = 3, #' #' # The data and grouping variables @@ -230,7 +230,7 @@ #' #' # Each factor estimates a different nonlinear spatial process, using #' # 'by = trend' as in other mvgam State-Space models -#' factor_formula = ~ gp(lat, lon, k = 6, by = trend) - 1, +#' factor_formula = ~ gp(lon, lat, k = 6, by = trend) - 1, #' n_lv = 3, #' #' # Change default priors for fixed random effect variances and @@ -238,11 +238,11 @@ #' priors = c(prior(std_normal(), #' class = sigma_raw), #' prior(std_normal(), -#' class = `alpha_gp_trend(lat, lon):trendtrend1`), +#' class = `alpha_gp_trend(lon, lat):trendtrend1`), #' prior(std_normal(), -#' class = `alpha_gp_trend(lat, lon):trendtrend2`), +#' class = `alpha_gp_trend(lon, lat):trendtrend2`), #' prior(std_normal(), -#' class = `alpha_gp_trend(lat, lon):trendtrend3`)), +#' class = `alpha_gp_trend(lon, lat):trendtrend3`)), #' #' # The data and the grouping variables #' data = dat, @@ -303,7 +303,7 @@ #' #' # Plot the median log(count) predictions on a grid #' newdata$log_count <- preds[,1] -#' ggplot(newdata, aes(x = lat, y = lon, col = log_count)) + +#' ggplot(newdata, aes(x = lon, y = lat, col = log_count)) + #' geom_point(size = 1.5) + #' facet_wrap(~ species, scales = 'free') + #' scale_color_viridis_c() + diff --git a/docs/reference/code.html b/docs/reference/code.html index b9c7f095..2900bcb8 100644 --- a/docs/reference/code.html +++ b/docs/reference/code.html @@ -195,7 +195,7 @@

Examples#> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : NULL #> .. ..$ : chr [1:37] "X.Intercept." "V2" "V3" "V4" ... -#> $ S1 : num [1:9, 1:18] 3.758 -0.625 -1.816 0.191 2.357 ... +#> $ S1 : num [1:9, 1:18] 3.819 0.796 1.727 -0.323 2.686 ... #> $ zero : num [1:37] 0 0 0 0 0 0 0 0 0 0 ... #> $ S2 : num [1:9, 1:18] 8.555 -1.22 4.352 0.822 -5.594 ... #> $ S3 : num [1:9, 1:18] 8.555 -1.22 4.352 0.822 -5.594 ... diff --git a/docs/reference/conditional_effects.mvgam-1.png b/docs/reference/conditional_effects.mvgam-1.png index be7de5fe..1c32e342 100644 Binary files a/docs/reference/conditional_effects.mvgam-1.png and b/docs/reference/conditional_effects.mvgam-1.png differ diff --git a/docs/reference/conditional_effects.mvgam-10.png b/docs/reference/conditional_effects.mvgam-10.png index f021f136..490b8897 100644 Binary files a/docs/reference/conditional_effects.mvgam-10.png and b/docs/reference/conditional_effects.mvgam-10.png differ diff --git a/docs/reference/conditional_effects.mvgam-11.png b/docs/reference/conditional_effects.mvgam-11.png index cc65cc81..4bfb6060 100644 Binary files a/docs/reference/conditional_effects.mvgam-11.png and b/docs/reference/conditional_effects.mvgam-11.png differ diff --git a/docs/reference/conditional_effects.mvgam-12.png b/docs/reference/conditional_effects.mvgam-12.png index b2eae986..51641814 100644 Binary files a/docs/reference/conditional_effects.mvgam-12.png and b/docs/reference/conditional_effects.mvgam-12.png differ diff --git a/docs/reference/conditional_effects.mvgam-2.png b/docs/reference/conditional_effects.mvgam-2.png index 8897093d..17507eea 100644 Binary files a/docs/reference/conditional_effects.mvgam-2.png and b/docs/reference/conditional_effects.mvgam-2.png differ diff --git a/docs/reference/conditional_effects.mvgam-3.png b/docs/reference/conditional_effects.mvgam-3.png index 771cc74e..426674db 100644 Binary files a/docs/reference/conditional_effects.mvgam-3.png and b/docs/reference/conditional_effects.mvgam-3.png differ diff --git a/docs/reference/conditional_effects.mvgam-4.png b/docs/reference/conditional_effects.mvgam-4.png index 34dedfea..0dc8e5a9 100644 Binary files a/docs/reference/conditional_effects.mvgam-4.png and b/docs/reference/conditional_effects.mvgam-4.png differ diff --git a/docs/reference/conditional_effects.mvgam-5.png b/docs/reference/conditional_effects.mvgam-5.png index a116d9b6..d010bb92 100644 Binary files a/docs/reference/conditional_effects.mvgam-5.png and b/docs/reference/conditional_effects.mvgam-5.png differ diff --git a/docs/reference/conditional_effects.mvgam-6.png b/docs/reference/conditional_effects.mvgam-6.png index 10dbe093..b812afcd 100644 Binary files a/docs/reference/conditional_effects.mvgam-6.png and b/docs/reference/conditional_effects.mvgam-6.png differ diff --git a/docs/reference/conditional_effects.mvgam-7.png b/docs/reference/conditional_effects.mvgam-7.png index b2e25928..503b430a 100644 Binary files a/docs/reference/conditional_effects.mvgam-7.png and b/docs/reference/conditional_effects.mvgam-7.png differ diff --git a/docs/reference/conditional_effects.mvgam-8.png b/docs/reference/conditional_effects.mvgam-8.png index 6ba2d7ef..9ce76f3e 100644 Binary files a/docs/reference/conditional_effects.mvgam-8.png and b/docs/reference/conditional_effects.mvgam-8.png differ diff --git a/docs/reference/conditional_effects.mvgam-9.png b/docs/reference/conditional_effects.mvgam-9.png index fbf7e285..289f78c9 100644 Binary files a/docs/reference/conditional_effects.mvgam-9.png and b/docs/reference/conditional_effects.mvgam-9.png differ diff --git a/docs/reference/conditional_effects.mvgam.html b/docs/reference/conditional_effects.mvgam.html index 479cd2e1..f772d28c 100644 --- a/docs/reference/conditional_effects.mvgam.html +++ b/docs/reference/conditional_effects.mvgam.html @@ -180,6 +180,19 @@

Examples chains = 2) #> 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/RtmpsvBanv/model-1dc43b255805.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... #> @@ -191,28 +204,28 @@

Examples#> 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 1 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: 500 / 1000 [ 50%] (Warmup) +#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling) #> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) +#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) #> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling) -#> Chain 1 Iteration: 800 / 1000 [ 80%] (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.9 seconds. +#> Chain 2 finished in 1.4 seconds. #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 1 finished in 3.2 seconds. +#> Chain 1 finished in 1.6 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 3.0 seconds. -#> Total execution time: 3.4 seconds. +#> Mean chain execution time: 1.5 seconds. +#> Total execution time: 1.9 seconds. #> # Plot all main effects on the response scale @@ -241,6 +254,19 @@

Examples chains = 2) #> 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/RtmpsvBanv/model-1dc4b245942.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... #> @@ -248,32 +274,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: 200 / 1000 [ 20%] (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 1 Iteration: 600 / 1000 [ 60%] (Sampling) -#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) +#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling) +#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling) -#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling) +#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) #> Chain 1 Iteration: 800 / 1000 [ 80%] (Sampling) -#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) +#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling) #> Chain 1 Iteration: 900 / 1000 [ 90%] (Sampling) -#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 2 finished in 4.5 seconds. +#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 1 finished in 4.8 seconds. +#> Chain 1 finished in 3.6 seconds. +#> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) +#> Chain 2 finished in 3.8 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 4.7 seconds. -#> Total execution time: 5.1 seconds. +#> Mean chain execution time: 3.7 seconds. +#> Total execution time: 4.0 seconds. #> conditional_effects(mod) diff --git a/docs/reference/get_mvgam_priors.html b/docs/reference/get_mvgam_priors.html index cf714f8b..080e706d 100644 --- a/docs/reference/get_mvgam_priors.html +++ b/docs/reference/get_mvgam_priors.html @@ -450,13 +450,13 @@

Examples#> 6 trend sd sigma ~ student_t(3, 0, 2.5); #> 7 inverse of NB dispsersion phi_inv ~ student_t(3, 0, 0.1); #> example_change new_lowerbound new_upperbound -#> 1 lambda ~ exponential(0.13); NA NA -#> 2 mu_raw ~ normal(-0.49, 0.25); NA NA -#> 3 sigma_raw ~ exponential(0.38); NA NA -#> 4 ar1 ~ normal(-0.64, 0.76); NA NA -#> 5 ar2 ~ normal(-0.05, 0.86); NA NA -#> 6 sigma ~ exponential(0.1); NA NA -#> 7 phi_inv ~ normal(-0.74, 0.35); NA NA +#> 1 lambda ~ exponential(0.32); NA NA +#> 2 mu_raw ~ normal(0.2, 0.47); NA NA +#> 3 sigma_raw ~ exponential(0.39); NA NA +#> 4 ar1 ~ normal(-0.23, 0.94); NA NA +#> 5 ar2 ~ normal(-0.14, 0.5); NA NA +#> 6 sigma ~ exponential(0.27); NA NA +#> 7 phi_inv ~ normal(-0.04, 0.65); NA NA # Make a few changes; first, change the population mean for the series-level # random intercepts @@ -996,7 +996,7 @@

Examples#> lambda ~ normal(5, 30); #> #> // priors for latent trend variance parameters -#> sigma ~ student_t(3, 0, 2.5); +#> sigma ~ student_t(3, 0, 2.9); #> #> // trend estimates #> trend[1, 1 : n_series] ~ normal(0, sigma); @@ -1105,7 +1105,7 @@

Examples#> lambda ~ normal(5, 30); #> #> // priors for latent trend variance parameters -#> sigma ~ student_t(3, 0, 2.5); +#> sigma ~ student_t(3, 0, 2.9); #> #> // trend estimates #> trend[1, 1 : n_series] ~ normal(0, sigma); diff --git a/docs/reference/index.html b/docs/reference/index.html index a2ff8b29..7bc429c0 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -400,7 +400,7 @@

All functionsseries_to_mvgam()
This function converts univariate or multivariate time series (xts or ts objects) -to the format necessary for mvgam
+to the format necessary for mvgam
sim_mvgam() diff --git a/docs/reference/jsdgam-1.png b/docs/reference/jsdgam-1.png index 21fbde03..6a3f8289 100644 Binary files a/docs/reference/jsdgam-1.png and b/docs/reference/jsdgam-1.png differ diff --git a/docs/reference/jsdgam-2.png b/docs/reference/jsdgam-2.png index d1d188ea..295c28ce 100644 Binary files a/docs/reference/jsdgam-2.png and b/docs/reference/jsdgam-2.png differ diff --git a/docs/reference/jsdgam-3.png b/docs/reference/jsdgam-3.png index 9da9a742..72dcba36 100644 Binary files a/docs/reference/jsdgam-3.png and b/docs/reference/jsdgam-3.png differ diff --git a/docs/reference/jsdgam-4.png b/docs/reference/jsdgam-4.png index 0c4e22a6..fa7baf27 100644 Binary files a/docs/reference/jsdgam-4.png and b/docs/reference/jsdgam-4.png differ diff --git a/docs/reference/jsdgam-5.png b/docs/reference/jsdgam-5.png index 27049f45..b9a1c8d4 100644 Binary files a/docs/reference/jsdgam-5.png and b/docs/reference/jsdgam-5.png differ diff --git a/docs/reference/jsdgam-6.png b/docs/reference/jsdgam-6.png index bf118a63..da5ea25f 100644 Binary files a/docs/reference/jsdgam-6.png and b/docs/reference/jsdgam-6.png differ diff --git a/docs/reference/jsdgam-7.png b/docs/reference/jsdgam-7.png index 93a04b8b..632f5407 100644 Binary files a/docs/reference/jsdgam-7.png and b/docs/reference/jsdgam-7.png differ diff --git a/docs/reference/jsdgam-8.png b/docs/reference/jsdgam-8.png index 13a0e6fe..1032dae2 100644 Binary files a/docs/reference/jsdgam-8.png and b/docs/reference/jsdgam-8.png differ diff --git a/docs/reference/jsdgam-9.png b/docs/reference/jsdgam-9.png index e5911e86..e0859065 100644 Binary files a/docs/reference/jsdgam-9.png and b/docs/reference/jsdgam-9.png differ diff --git a/docs/reference/jsdgam.html b/docs/reference/jsdgam.html index 439ddf1b..fd0a91b4 100644 --- a/docs/reference/jsdgam.html +++ b/docs/reference/jsdgam.html @@ -450,7 +450,7 @@

Examples#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. -ggplot(dat, aes(x = lat, y = lon, col = log(count + 1))) + +ggplot(dat, aes(x = lon, y = lat, col = log(count + 1))) + geom_point(size = 2.25) + facet_wrap(~ species, scales = 'free') + scale_color_viridis_c() + @@ -465,7 +465,7 @@

Examples # Each factor estimates a different nonlinear spatial process, using # 'by = trend' as in other mvgam State-Space models - factor_formula = ~ gp(lat, lon, k = 6, by = trend) - 1, + factor_formula = ~ gp(lon, lat, k = 6, by = trend) - 1, n_lv = 3, # The data and grouping variables @@ -483,30 +483,30 @@

Examples#> 1 (Intercept) 1 #> 2 vector[1] mu_raw; 1 #> 3 vector<lower=0>[1] sigma_raw; 1 -#> 4 real<lower=0> alpha_gp_trend(lat, lon):trendtrend1; 1 -#> 5 real<lower=0> alpha_gp_trend(lat, lon):trendtrend2; 1 -#> 6 real<lower=0> alpha_gp_trend(lat, lon):trendtrend3; 1 +#> 4 real<lower=0> alpha_gp_trend(lon, lat):trendtrend1; 1 +#> 5 real<lower=0> alpha_gp_trend(lon, lat):trendtrend2; 1 +#> 6 real<lower=0> alpha_gp_trend(lon, lat):trendtrend3; 1 #> param_info #> 1 (Intercept) #> 2 s(species):temperature pop mean #> 3 s(species):temperature pop sd -#> 4 gp(lat, lon):trendtrend1 marginal deviation -#> 5 gp(lat, lon):trendtrend2 marginal deviation -#> 6 gp(lat, lon):trendtrend3 marginal deviation +#> 4 gp(lon, lat):trendtrend1 marginal deviation +#> 5 gp(lon, lat):trendtrend2 marginal deviation +#> 6 gp(lon, lat):trendtrend3 marginal deviation #> prior #> 1 (Intercept) ~ student_t(3, 2.1, 2.5); #> 2 mu_raw ~ std_normal(); #> 3 sigma_raw ~ student_t(3, 0, 2.5); -#> 4 alpha_gp_trend(lat, lon):trendtrend1 ~ student_t(3, 0, 2.5); -#> 5 alpha_gp_trend(lat, lon):trendtrend2 ~ student_t(3, 0, 2.5); -#> 6 alpha_gp_trend(lat, lon):trendtrend3 ~ student_t(3, 0, 2.5); +#> 4 alpha_gp_trend(lon, lat):trendtrend1 ~ student_t(3, 0, 2.5); +#> 5 alpha_gp_trend(lon, lat):trendtrend2 ~ student_t(3, 0, 2.5); +#> 6 alpha_gp_trend(lon, lat):trendtrend3 ~ student_t(3, 0, 2.5); #> example_change new_lowerbound #> 1 (Intercept) ~ normal(0, 1); <NA> #> 2 mu_raw ~ normal(0.65, 0.15); <NA> #> 3 sigma_raw ~ exponential(0.27); <NA> -#> 4 alpha_gp_trend(lat, lon):trendtrend1 ~ normal(0, 0.86); <NA> -#> 5 alpha_gp_trend(lat, lon):trendtrend2 ~ normal(0, 0.84); <NA> -#> 6 alpha_gp_trend(lat, lon):trendtrend3 ~ normal(0, 0.78); <NA> +#> 4 alpha_gp_trend(lon, lat):trendtrend1 ~ normal(0, 0.86); <NA> +#> 5 alpha_gp_trend(lon, lat):trendtrend2 ~ normal(0, 0.84); <NA> +#> 6 alpha_gp_trend(lon, lat):trendtrend3 ~ normal(0, 0.78); <NA> #> new_upperbound #> 1 <NA> #> 2 <NA> @@ -524,7 +524,7 @@

Examples # Each factor estimates a different nonlinear spatial process, using # 'by = trend' as in other mvgam State-Space models - factor_formula = ~ gp(lat, lon, k = 6, by = trend) - 1, + factor_formula = ~ gp(lon, lat, k = 6, by = trend) - 1, n_lv = 3, # Change default priors for fixed random effect variances and @@ -532,11 +532,11 @@

Examples priors = c(prior(std_normal(), class = sigma_raw), prior(std_normal(), - class = `alpha_gp_trend(lat, lon):trendtrend1`), + class = `alpha_gp_trend(lon, lat):trendtrend1`), prior(std_normal(), - class = `alpha_gp_trend(lat, lon):trendtrend2`), + class = `alpha_gp_trend(lon, lat):trendtrend2`), prior(std_normal(), - class = `alpha_gp_trend(lat, lon):trendtrend3`)), + class = `alpha_gp_trend(lon, lat):trendtrend3`)), # The data and the grouping variables data = dat, @@ -547,6 +547,19 @@

Examples family = poisson(), 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/RtmpwbtRRG/model-2c78394a3e74.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 # Plot species-level intercept estimates plot_predictions(mod, condition = 'species', @@ -577,25 +590,25 @@

Examples# some of the estimated correlations post_cors$cor[1:5, 1:5] #> species_1 species_2 species_3 species_4 species_5 -#> species_1 1.0000000 0.7336280 0.72991602 0.7861474 -0.24696228 -#> species_2 0.7336280 1.0000000 0.15420441 0.3813268 -0.47995732 -#> species_3 0.7299160 0.1542044 1.00000000 0.8908844 -0.03924676 -#> species_4 0.7861474 0.3813268 0.89088435 1.0000000 -0.44731327 -#> species_5 -0.2469623 -0.4799573 -0.03924676 -0.4473133 1.00000000 +#> species_1 1.0000000 0.7606789 0.70196887 0.7628489 -0.25099259 +#> species_2 0.7606789 1.0000000 0.18720736 0.4210261 -0.49124204 +#> species_3 0.7019689 0.1872074 1.00000000 0.8902954 -0.06361541 +#> species_4 0.7628489 0.4210261 0.89029541 1.0000000 -0.47114518 +#> species_5 -0.2509926 -0.4912420 -0.06361541 -0.4711452 1.00000000 post_cors$cor_upper[1:5, 1:5] #> species_1 species_2 species_3 species_4 species_5 -#> species_1 1.0000000 0.9242392 0.9566867 0.9575828 0.1509028 -#> species_2 0.9242392 1.0000000 0.5199946 0.7191710 -0.1730502 -#> species_3 0.9566867 0.5199946 1.0000000 0.9774616 0.3136909 -#> species_4 0.9575828 0.7191710 0.9774616 1.0000000 -0.1076519 -#> species_5 0.1509028 -0.1730502 0.3136909 -0.1076519 1.0000000 +#> species_1 1.0000000 0.9596571 0.9345862 0.9434505 0.1851578 +#> species_2 0.9596571 1.0000000 0.5336101 0.7186475 -0.1905583 +#> species_3 0.9345862 0.5336101 1.0000000 0.9751394 0.2694864 +#> species_4 0.9434505 0.7186475 0.9751394 1.0000000 -0.1440963 +#> species_5 0.1851578 -0.1905583 0.2694864 -0.1440963 1.0000000 post_cors$cor_lower[1:5, 1:5] #> species_1 species_2 species_3 species_4 species_5 -#> species_1 1.0000000 0.4226772 0.4168132 0.4720316 -0.6018739 -#> species_2 0.4226772 1.0000000 -0.2345903 -0.0158343 -0.7385235 -#> species_3 0.4168132 -0.2345903 1.0000000 0.7304959 -0.3965220 -#> species_4 0.4720316 -0.0158343 0.7304959 1.0000000 -0.7197583 -#> species_5 -0.6018739 -0.7385235 -0.3965220 -0.7197583 1.0000000 +#> species_1 1.0000000 0.4727149 0.2516898 0.3537814 -0.6142443 +#> species_2 0.4727149 1.0000000 -0.1914547 0.0542295 -0.7282459 +#> species_3 0.2516898 -0.1914547 1.0000000 0.7389518 -0.3915772 +#> species_4 0.3537814 0.0542295 0.7389518 1.0000000 -0.7116399 +#> species_5 -0.6142443 -0.7282459 -0.3915772 -0.7116399 1.0000000 # A quick and dirty plot of the posterior median correlations image(post_cors$cor) @@ -610,17 +623,17 @@

Examples#> Computed from 1000 by 600 log-likelihood matrix. #> #> Estimate SE -#> elpd_loo -2190.8 51.4 -#> p_loo 421.9 27.1 -#> looic 4381.6 102.8 +#> elpd_loo -2189.4 50.5 +#> p_loo 421.9 26.3 +#> looic 4378.8 100.9 #> ------ #> MCSE of elpd_loo is NA. #> MCSE and ESS estimates assume MCMC draws (r_eff in [0.0, 1.6]). #> #> Pareto k diagnostic values: #> Count Pct. Min. ESS -#> (-Inf, 0.67] (good) 438 73.0% 1 -#> (0.67, 1] (bad) 132 22.0% <NA> +#> (-Inf, 0.67] (good) 441 73.5% 1 +#> (0.67, 1] (bad) 129 21.5% <NA> #> (1, Inf) (very bad) 30 5.0% <NA> #> See help('pareto-k-diagnostic') for details. @@ -639,7 +652,7 @@

Examples # Plot the median log(count) predictions on a grid newdata$log_count <- preds[,1] -ggplot(newdata, aes(x = lat, y = lon, col = log_count)) + +ggplot(newdata, aes(x = lon, y = lat, col = log_count)) + geom_point(size = 1.5) + facet_wrap(~ species, scales = 'free') + scale_color_viridis_c() + diff --git a/docs/reference/monotonic-2.png b/docs/reference/monotonic-2.png index d3e82045..51576e8d 100644 Binary files a/docs/reference/monotonic-2.png and b/docs/reference/monotonic-2.png differ diff --git a/docs/reference/monotonic-3.png b/docs/reference/monotonic-3.png index 70756718..b66c65a0 100644 Binary files a/docs/reference/monotonic-3.png and b/docs/reference/monotonic-3.png differ diff --git a/docs/reference/monotonic-4.png b/docs/reference/monotonic-4.png index 85522328..4687d35f 100644 Binary files a/docs/reference/monotonic-4.png and b/docs/reference/monotonic-4.png differ diff --git a/docs/reference/monotonic-7.png b/docs/reference/monotonic-7.png index 8465a9ce..c5fdff6d 100644 Binary files a/docs/reference/monotonic-7.png and b/docs/reference/monotonic-7.png differ diff --git a/docs/reference/monotonic-8.png b/docs/reference/monotonic-8.png index 1b0b3c97..021f1ae1 100644 Binary files a/docs/reference/monotonic-8.png and b/docs/reference/monotonic-8.png differ diff --git a/docs/reference/monotonic.html b/docs/reference/monotonic.html index 7f7dee23..fe5d2e4a 100644 --- a/docs/reference/monotonic.html +++ b/docs/reference/monotonic.html @@ -156,9 +156,8 @@

Examples # A standard TRPS smooth doesn't capture monotonicity library(mgcv) -#> Warning: package ‘mgcv’ was built under R version 4.2.3 #> Loading required package: nlme -#> This is mgcv 1.9-1. For overview type 'help("mgcv-package")'. +#> This is mgcv 1.8-42. For overview type 'help("mgcv-package")'. #> #> Attaching package: ‘mgcv’ #> The following objects are masked from ‘package:mvgam’: @@ -186,6 +185,19 @@

Examples chains = 2) #> 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/RtmpsvBanv/model-1dc44a367b07.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... #> @@ -201,24 +213,24 @@

Examples#> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling) #> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup) #> 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 1 Iteration: 700 / 1000 [ 70%] (Sampling) -#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) +#> Chain 2 Iteration: 600 / 1000 [ 60%] (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 2 Iteration: 700 / 1000 [ 70%] (Sampling) #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) +#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling) +#> Chain 1 finished in 1.0 seconds. +#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 1 finished in 1.2 seconds. -#> Chain 2 finished in 1.1 seconds. +#> Chain 2 finished in 1.2 seconds. #> #> Both chains finished successfully. #> Mean chain execution time: 1.1 seconds. -#> Total execution time: 1.5 seconds. +#> Total execution time: 1.4 seconds. #> plot_predictions(mod2, @@ -260,22 +272,35 @@

Examples chains = 2) #> 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/RtmpsvBanv/model-1dc4631b3d6f.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 1 Iteration: 200 / 1000 [ 20%] (Warmup) #> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup) -#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup) +#> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup) #> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup) -#> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup) #> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup) +#> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup) #> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup) -#> Chain 1 Iteration: 500 / 1000 [ 50%] (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 1 Iteration: 501 / 1000 [ 50%] (Sampling) #> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) @@ -286,13 +311,13 @@

Examples#> 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 2.0 seconds. +#> Chain 1 finished in 1.8 seconds. #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 2 finished in 1.8 seconds. +#> Chain 2 finished in 2.0 seconds. #> #> Both chains finished successfully. #> Mean chain execution time: 1.9 seconds. -#> Total execution time: 2.3 seconds. +#> Total execution time: 2.2 seconds. #> # Visualise the different monotonic functions @@ -308,18 +333,18 @@

Examples by = c('x', 'fac'), type = 'link')) #> -#> Term Contrast x fac Estimate 2.5 % 97.5 % -#> x mean(dY/dX) -0.987 a 0.326 0.104 0.836 -#> x mean(dY/dX) -0.841 a 0.504 0.323 0.778 -#> x mean(dY/dX) -0.796 a 0.545 0.372 0.796 -#> x mean(dY/dX) -0.636 a 0.650 0.476 0.854 -#> x mean(dY/dX) -0.594 a 0.664 0.497 0.871 +#> Term Contrast x fac Estimate 2.5 % 97.5 % +#> x mean(dY/dX) -0.987 a 0.331 0.1062 0.846 +#> x mean(dY/dX) -0.841 a 0.190 0.0289 0.616 +#> x mean(dY/dX) -0.796 a 0.520 0.3133 0.796 +#> x mean(dY/dX) -0.636 a 0.298 0.1328 0.575 +#> x mean(dY/dX) -0.594 a 0.560 0.3568 0.798 #> --- 150 rows omitted. See ?print.marginaleffects --- -#> x mean(dY/dX) 2.649 b 2.082 1.614 2.617 -#> x mean(dY/dX) 2.712 b 2.284 1.723 2.933 -#> x mean(dY/dX) 2.853 b 3.045 1.274 4.747 -#> x mean(dY/dX) 2.870 b 3.196 1.144 5.122 -#> x mean(dY/dX) 2.879 b 3.269 1.072 5.310 +#> x mean(dY/dX) 2.649 b 2.977 1.2782 4.700 +#> x mean(dY/dX) 2.712 b 0.259 0.0301 1.000 +#> x mean(dY/dX) 2.853 b 3.114 1.1297 5.085 +#> x mean(dY/dX) 2.870 b 0.266 0.0278 1.043 +#> x mean(dY/dX) 2.879 b 3.161 1.0538 5.299 #> Columns: rowid, term, contrast, x, fac, estimate, conf.low, conf.high, predicted_lo, predicted_hi, predicted, tmp_idx #> Type: link #> diff --git a/docs/reference/mvgam-10.png b/docs/reference/mvgam-10.png index 3e183369..6e5e37a3 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 416b2b96..cfe4fecc 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 bcbb890a..fed837d9 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 5a22bf8b..be4c25f8 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 a38654de..608ca873 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 ea4b3b07..a33899e4 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 fb1ba042..44e2bff1 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 22e74763..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 5a8f4ef1..0d9c672a 100644 Binary files a/docs/reference/mvgam-19.png and b/docs/reference/mvgam-19.png differ diff --git a/docs/reference/mvgam-20.png b/docs/reference/mvgam-20.png index 6a476af3..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 a39a04de..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 118c2a8e..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 94466e1e..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 031abbd0..e86a1a53 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 85fd9f1f..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 d7876f13..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 3e344f01..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 9a0876d5..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 62a9851f..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 f936b951..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 b4484735..2494010c 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 b1ecf3ec..cdc27a36 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 e3046657..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 ee5062ae..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 c4e7f9c6..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 390bfcd0..6456fa66 100644 --- a/docs/reference/mvgam.html +++ b/docs/reference/mvgam.html @@ -685,6 +685,19 @@

Examples chains = 2) #> 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/RtmpsvBanv/model-1dc465613ec6.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... #> @@ -695,36 +708,36 @@

Examples#> 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 2 Iteration: 300 / 1000 [ 30%] (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 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 1 Iteration: 900 / 1000 [ 90%] (Sampling) +#> Chain 2 Iteration: 800 / 1000 [ 80%] (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 finished in 1.4 seconds. +#> Chain 2 finished in 1.5 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 2.0 seconds. -#> Total execution time: 2.4 seconds. +#> Mean chain execution time: 1.4 seconds. +#> Total execution time: 1.6 seconds. #> # Extract the model summary summary(mod1) #> GAM formula: #> y ~ s(season, bs = "cc", k = 6) -#> <environment: 0x0000025cc9b7c500> +#> <environment: 0x000001da64e155c0> #> #> Family: #> poisson @@ -750,26 +763,26 @@

Examples#> #> GAM coefficient (beta) estimates: #> 2.5% 50% 97.5% Rhat n_eff -#> (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 +#> (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.65 4 37.2 <2e-16 *** +#> 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.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 +#> 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 @@ -778,7 +791,7 @@

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 Tue Dec 03 3:39:38 PM 2024. +#> Samples were drawn using NUTS(diag_e) at Thu Dec 19 7:02:45 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) @@ -796,7 +809,7 @@

Examples resids <- residuals(mod1) str(resids) -#> num [1:180, 1:4] -0.153 NaN -0.14 0.259 -0.824 ... +#> 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" @@ -806,16 +819,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.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 +#> 1 4 1 1 series_1 1 4 4.73 1.62 +#> 2 NA 1 1 series_2 1 NA 6.75 3.76 +#> 3 4 1 1 series_3 1 4 4.59 1.69 +#> 4 5 2 1 series_1 2 5 4.74 1.66 +#> 5 2 2 1 series_2 2 2 3.80 1.52 +#> 6 NA 2 1 series_3 2 NA 5.39 3.17 +#> 7 7 3 1 series_1 3 7 8.43 2.55 +#> 8 12 3 1 series_2 3 12 11.5 2.86 +#> 9 4 3 1 series_3 3 4 5.38 1.89 +#> 10 39 4 1 series_1 4 39 36.1 5.64 #> # ℹ 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> @@ -825,7 +838,7 @@

Examplesstr(fc) #> List of 16 #> $ call :Class 'formula' language y ~ s(season, bs = "cc", k = 6) -#> .. ..- attr(*, ".Environment")=<environment: 0x0000025cc9b7c500> +#> .. ..- attr(*, ".Environment")=<environment: 0x000001da64e155c0> #> $ trend_call : NULL #> $ family : chr "poisson" #> $ family_pars : NULL @@ -854,26 +867,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] 9 3 3 4 3 0 1 3 5 1 ... +#> ..$ 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] 8 8 8 5 7 2 7 4 14 15 ... +#> ..$ 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] 8 7 2 7 2 6 4 8 2 3 ... +#> ..$ 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] 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 ... +#> ..$ series_1: int [1:1000, 1:20] 3 7 5 4 0 4 6 6 0 1 ... +#> ..$ series_2: int [1:1000, 1:20] 3 8 7 14 5 9 9 8 19 6 ... +#> ..$ series_3: int [1:1000, 1:20] 8 15 1 3 14 10 19 3 11 6 ... #> - attr(*, "class")= chr "mvgam_forecast" plot(fc) #> Out of sample DRPS: -#> 58.635904 +#> 57.056876 # Plot the estimated seasonal smooth function @@ -911,19 +924,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.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 +#> 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.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 ... +#> $ (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') @@ -934,18 +947,18 @@

Examples#> Computed from 1000 by 164 log-likelihood matrix. #> #> Estimate SE -#> elpd_loo -455.4 8.3 -#> p_loo 85.3 4.3 -#> looic 910.8 16.6 +#> 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.4, 2.0]). +#> 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) 81 49.4% 84 -#> (0.67, 1] (bad) 75 45.7% <NA> -#> (1, Inf) (very bad) 8 4.9% <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) @@ -969,39 +982,52 @@

Examples chains = 2) #> 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/RtmpsvBanv/model-1dc432810bb.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 2 Iteration: 1 / 1000 [ 0%] (Warmup) #> Chain 1 Iteration: 200 / 1000 [ 20%] (Warmup) -#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup) +#> Chain 2 Iteration: 100 / 1000 [ 10%] (Warmup) #> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup) -#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup) +#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup) #> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup) -#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup) +#> Chain 2 Iteration: 300 / 1000 [ 30%] (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 1 Iteration: 700 / 1000 [ 70%] (Sampling) +#> Chain 2 Iteration: 600 / 1000 [ 60%] (Sampling) #> 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 2 Iteration: 800 / 1000 [ 80%] (Sampling) #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 1 finished in 3.1 seconds. +#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) +#> Chain 1 finished in 1.6 seconds. #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 2 finished in 3.2 seconds. +#> Chain 2 finished in 1.6 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 3.1 seconds. -#> Total execution time: 3.7 seconds. +#> Mean chain execution time: 1.6 seconds. +#> Total execution time: 1.8 seconds. #> # The mapping matrix is now supplied as data to the model in the 'Z' element @@ -1154,11 +1180,21 @@

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, +#> 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/RtmpsvBanv/model-1dc4342a757f.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... #> @@ -1166,39 +1202,39 @@

Examples#> 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: 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: 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) #> 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 1 Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) -#> Chain 1 finished in 1.4 seconds. +#> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 2 finished in 1.4 seconds. +#> Chain 1 finished in 0.8 seconds. +#> Chain 2 finished in 0.7 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 1.4 seconds. -#> Total execution time: 1.9 seconds. +#> Mean chain execution time: 0.8 seconds. +#> Total execution time: 0.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: 0x0000025cc9b7c500> +#> <environment: 0x000001da64e155c0> #> #> Family: #> gaussian @@ -1223,66 +1259,66 @@

Examples#> #> Observation error parameter estimates: #> 2.5% 50% 97.5% Rhat n_eff -#> sigma_obs[1] 0.44 0.49 0.55 1 1879 +#> 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 2559 -#> gp(time):temp.1 0.380 3.1e+00 6.400 1.00 1090 -#> gp(time):temp.2 -3.100 1.6e+00 6.800 1.00 948 -#> gp(time):temp.3 -5.700 -1.3e+00 3.500 1.00 1072 -#> gp(time):temp.4 -5.600 -1.5e+00 2.500 1.00 1183 -#> gp(time):temp.5 -3.700 1.7e-01 3.500 1.00 1228 -#> gp(time):temp.6 -2.300 6.0e-01 4.400 1.00 1211 -#> gp(time):temp.7 -3.300 -2.7e-01 2.700 1.00 1416 -#> gp(time):temp.8 -2.600 -1.3e-02 2.500 1.00 1391 -#> gp(time):temp.9 -1.400 4.5e-01 3.400 1.00 990 -#> gp(time):temp.10 -2.400 -1.4e-02 2.200 1.00 1310 -#> gp(time):temp.11 -2.700 -3.3e-01 1.100 1.00 1218 -#> gp(time):temp.12 -1.400 5.4e-02 2.000 1.00 1154 -#> gp(time):temp.13 -0.990 1.0e-01 2.100 1.00 815 -#> gp(time):temp.14 -1.700 -5.6e-03 1.100 1.00 1094 -#> gp(time):temp.15 -1.400 -7.2e-03 1.100 1.00 1073 -#> gp(time):temp.16 -0.940 6.9e-05 1.200 1.00 1071 -#> gp(time):temp.17 -0.870 4.3e-09 1.200 1.00 912 -#> gp(time):temp.18 -1.000 -1.7e-19 1.000 1.00 987 -#> gp(time):temp.19 -1.000 -3.3e-13 0.740 1.00 1411 -#> gp(time):temp.20 -0.880 -3.1e-07 0.580 1.00 1158 -#> gp(time):temp.21 -0.660 4.3e-18 0.670 1.00 1237 -#> gp(time):temp.22 -0.280 4.4e-06 0.930 1.01 949 -#> gp(time):temp.23 -0.720 -6.5e-16 0.380 1.00 1653 -#> gp(time):temp.24 -0.760 -6.3e-10 0.220 1.00 559 -#> gp(time):temp.25 -0.300 5.5e-26 0.560 1.00 1198 -#> gp(time):temp.26 -0.270 3.1e-20 0.450 1.00 1242 -#> gp(time):temp.27 -0.600 -4.0e-21 0.210 1.00 1101 -#> gp(time):temp.28 -0.350 -2.3e-36 0.280 1.00 1191 -#> gp(time):temp.29 -0.110 2.2e-25 0.460 1.00 681 -#> gp(time):temp.30 -0.260 -6.4e-57 0.220 1.00 1228 -#> gp(time):temp.31 -0.460 -1.2e-40 0.120 1.00 997 -#> gp(time):temp.32 -0.190 4.2e-51 0.270 1.00 876 -#> gp(time):temp.33 -0.120 1.5e-38 0.250 1.00 1287 -#> gp(time):temp.34 -0.150 -3.9e-60 0.140 1.00 1146 -#> gp(time):temp.35 -0.120 -1.8e-59 0.110 1.00 774 -#> gp(time):temp.36 -0.094 -7.0e-80 0.140 1.00 1139 -#> gp(time):temp.37 -0.052 -1.8e-63 0.110 1.00 646 -#> gp(time):temp.38 -0.095 -6.8e-81 0.054 1.00 888 -#> gp(time):temp.39 -0.075 -1.7e-88 0.059 1.00 711 -#> gp(time):temp.40 -0.039 1.8e-65 0.110 1.00 2892 +#> 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.16 0.34 0.69 1.00 580 -#> rho_gp(time):temp 11.00 31.00 100.00 1.02 127 +#> 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 -#> 41 of 1000 iterations ended with a divergence (4.1%) +#> 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 10 (0%) #> E-FMI indicated no pathological behavior #> -#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 3:41:27 PM 2024. +#> Samples were drawn using NUTS(diag_e) at Thu Dec 19 7:04:22 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) @@ -1293,7 +1329,7 @@

Examplesfc <- forecast(mod, newdata = data_test) plot(fc) #> Out of sample CRPS: -#> 6.41565320625866 +#> 6.31126950637918 # Propagating the smooth term shows how the coefficient is expected to evolve @@ -1323,6 +1359,19 @@

Examples chains = 2) #> 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/RtmpsvBanv/model-1dc436e23119.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... #> @@ -1330,32 +1379,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: 200 / 1000 [ 20%] (Warmup) #> Chain 1 Iteration: 300 / 1000 [ 30%] (Warmup) -#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup) #> Chain 1 Iteration: 400 / 1000 [ 40%] (Warmup) -#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup) +#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup) #> 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 2 Iteration: 400 / 1000 [ 40%] (Warmup) #> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling) -#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) +#> Chain 2 Iteration: 500 / 1000 [ 50%] (Warmup) #> Chain 1 Iteration: 700 / 1000 [ 70%] (Sampling) -#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling) +#> Chain 2 Iteration: 501 / 1000 [ 50%] (Sampling) +#> Chain 2 Iteration: 600 / 1000 [ 60%] (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 12.9 seconds. +#> Chain 2 Iteration: 700 / 1000 [ 70%] (Sampling) #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 1 finished in 13.9 seconds. +#> Chain 1 finished in 3.6 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 4.8 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 13.4 seconds. -#> Total execution time: 14.2 seconds. +#> Mean chain execution time: 4.2 seconds. +#> Total execution time: 5.1 seconds. #> # Inspect the model file to see the modification to the linear predictor @@ -1457,10 +1506,10 @@

Exampleslayout(matrix(1:2, ncol = 2)) plot(fc, series = 1, ylim = c(0, 75)) #> Out of sample DRPS: -#> 26.749404 +#> 26.747011 plot(fc, series = 2, ylim = c(0, 75)) #> Out of sample DRPS: -#> 101.807653 +#> 101.610568 layout(1) @@ -1470,7 +1519,7 @@

Examplesfc <- forecast(mod, newdata = dat$data_test) plot(fc) #> Out of sample DRPS: -#> 41.465009 +#> 41.417288 # Relative Risks can be computed by fixing the offset to the same value @@ -1532,44 +1581,57 @@

Examples#> 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, +#> 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/RtmpsvBanv/model-1dc4575a6648.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: 200 / 1000 [ 20%] (Warmup) -#> Chain 2 Iteration: 200 / 1000 [ 20%] (Warmup) +#> Chain 2 Iteration: 100 / 1000 [ 10%] (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 2 Iteration: 200 / 1000 [ 20%] (Warmup) #> Chain 1 Iteration: 500 / 1000 [ 50%] (Warmup) #> Chain 1 Iteration: 501 / 1000 [ 50%] (Sampling) +#> Chain 2 Iteration: 300 / 1000 [ 30%] (Warmup) +#> Chain 2 Iteration: 400 / 1000 [ 40%] (Warmup) +#> Chain 1 Iteration: 600 / 1000 [ 60%] (Sampling) +#> Chain 1 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 1 Iteration: 800 / 1000 [ 80%] (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 1 Iteration: 900 / 1000 [ 90%] (Sampling) -#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 1 Iteration: 1000 / 1000 [100%] (Sampling) +#> Chain 2 Iteration: 800 / 1000 [ 80%] (Sampling) +#> Chain 1 finished in 0.9 seconds. +#> Chain 2 Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 2 Iteration: 1000 / 1000 [100%] (Sampling) -#> Chain 1 finished in 2.7 seconds. -#> Chain 2 finished in 2.6 seconds. +#> Chain 2 finished in 1.0 seconds. #> #> Both chains finished successfully. -#> Mean chain execution time: 2.6 seconds. -#> Total execution time: 3.1 seconds. +#> Mean chain execution time: 1.0 seconds. +#> Total execution time: 1.3 seconds. #> summary(mod) #> GAM formula: #> cbind(y, ntrials) ~ series + s(x, by = series) -#> <environment: 0x0000025cc9b7c500> +#> <environment: 0x000001da64e155c0> #> #> Family: #> binomial @@ -1594,42 +1656,44 @@

Examples#> #> GAM coefficient (beta) estimates: #> 2.5% 50% 97.5% Rhat n_eff -#> (Intercept) -0.610 -0.48000 -0.350 1.00 693 -#> seriesseries2 0.110 0.28000 0.460 1.00 835 -#> s(x):seriesseries1.1 -0.270 -0.01500 0.120 1.01 305 -#> s(x):seriesseries1.2 -0.170 0.00300 0.180 1.00 481 -#> s(x):seriesseries1.3 -0.083 -0.00340 0.055 1.01 323 -#> s(x):seriesseries1.4 -0.120 -0.00017 0.100 1.00 414 -#> s(x):seriesseries1.5 -0.046 -0.00130 0.031 1.00 881 -#> s(x):seriesseries1.6 -0.074 -0.00030 0.087 1.00 418 -#> s(x):seriesseries1.7 -0.030 -0.00075 0.027 1.00 638 -#> s(x):seriesseries1.8 -0.590 -0.00230 0.460 1.00 392 -#> s(x):seriesseries1.9 0.490 0.88000 1.100 1.01 308 -#> s(x):seriesseries2.1 -0.150 0.00460 0.160 1.00 662 -#> s(x):seriesseries2.2 -0.160 0.00490 0.190 1.00 364 -#> s(x):seriesseries2.3 -0.046 0.00330 0.062 1.00 505 -#> s(x):seriesseries2.4 -0.100 0.00690 0.120 1.01 312 -#> s(x):seriesseries2.5 -0.030 0.00190 0.040 1.00 786 -#> s(x):seriesseries2.6 -0.099 -0.00620 0.069 1.00 358 -#> s(x):seriesseries2.7 -0.024 -0.00047 0.023 1.00 624 -#> s(x):seriesseries2.8 -0.440 0.04900 0.620 1.00 336 -#> s(x):seriesseries2.9 -0.990 -0.74000 -0.470 1.00 679 +#> (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 1.07 9 43.7 5.8e-05 *** -#> s(x):seriesseries2 2.25 9 29.2 < 2e-16 *** +#> 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%) +#> 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 Tue Dec 03 3:43:14 PM 2024. +#> Samples were drawn using NUTS(diag_e) at Thu Dec 19 7:05:37 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) diff --git a/docs/reference/mvgam_marginaleffects.html b/docs/reference/mvgam_marginaleffects.html index 9a53c822..4e897e07 100644 --- a/docs/reference/mvgam_marginaleffects.html +++ b/docs/reference/mvgam_marginaleffects.html @@ -156,8 +156,6 @@

Argumentsdatagrid() call to specify a custom grid of regressors. For example:

  • newdata = datagrid(cyl = c(4, 6)): cyl variable equal to 4 and 6 and other regressors fixed at their means or modes.

  • See the Examples section and the datagrid() documentation.

-
  • subset() call with a single argument to select a subset of the dataset used to fit the model, ex: newdata = subset(treatment == 1)

  • -
  • dplyr::filter() call with a single argument to select a subset of the dataset used to fit the model, ex: newdata = filter(treatment == 1)

  • string: