Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjclark committed Dec 2, 2024
1 parent 146d9ba commit d03d92c
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 42 deletions.
4 changes: 1 addition & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ description
```

```{r, echo=FALSE}
str_break = function(x, width = 90L) {
str_break = function(x, width = 105L) {
n = nchar(x)
if (n <= width) return(x)
n1 = seq(1L, n, by = width)
Expand All @@ -243,12 +243,10 @@ cat(str_break(description$methods_text), sep = '\n')
cat('\nPrimary references\n')
for(i in seq_along(description$citations)){
message(description$citations[[i]])
message()
}
cat('\nOther useful references\n')
for(i in seq_along(description$other_citations)){
message(description$other_citations[[i]])
message()
}
```

Expand Down
67 changes: 28 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,38 +246,38 @@ summary(lynx_mvgam)
#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
#> (Intercept) 6.400 6.60 6.900 1.00 1033
#> s(season).1 -0.660 -0.13 0.340 1.00 1236
#> s(season).2 0.730 1.30 1.900 1.00 991
#> s(season).3 1.300 1.90 2.500 1.01 730
#> s(season).4 -0.040 0.52 1.100 1.00 989
#> s(season).5 -1.300 -0.68 -0.095 1.00 893
#> s(season).6 -1.200 -0.56 0.150 1.00 1002
#> s(season).7 0.051 0.75 1.400 1.00 1056
#> s(season).8 0.640 1.40 2.100 1.00 840
#> s(season).9 -0.360 0.22 0.800 1.00 767
#> s(season).10 -1.400 -0.87 -0.380 1.00 1004
#> (Intercept) 6.400 6.60 6.900 1.01 926
#> s(season).1 -0.630 -0.13 0.340 1.00 1365
#> s(season).2 0.730 1.30 1.900 1.00 1060
#> s(season).3 1.200 1.90 2.600 1.00 993
#> s(season).4 -0.087 0.55 1.200 1.00 975
#> s(season).5 -1.300 -0.70 -0.074 1.00 968
#> s(season).6 -1.300 -0.56 0.120 1.00 1252
#> s(season).7 0.032 0.73 1.400 1.00 1259
#> s(season).8 0.610 1.40 2.100 1.00 729
#> s(season).9 -0.370 0.23 0.890 1.00 829
#> s(season).10 -1.400 -0.86 -0.360 1.00 1233
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
#> s(season) 9.94 10 55.6 <2e-16 ***
#> s(season) 9.97 10 48.6 <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.58 0.82 0.98 1 636
#> sigma[1] 0.38 0.47 0.60 1 838
#> ar1[1] 0.60 0.83 0.98 1.01 671
#> sigma[1] 0.38 0.47 0.60 1.00 750
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 0 of 2000 iterations ended with a divergence (0%)
#> 13 of 2000 iterations saturated the maximum tree depth of 10 (0.65%)
#> 3 of 2000 iterations saturated the maximum tree depth of 10 (0.15%)
#> *Run with max_treedepth set to a larger value to avoid saturation
#> E-FMI indicated no pathological behavior
#>
#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 9:24:49 AM 2024.
#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 9:38:07 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
Expand Down Expand Up @@ -420,8 +420,8 @@ plot(lynx_mvgam, type = 'forecast', newdata = lynx_test)

<img src="man/figures/README-unnamed-chunk-21-1.png" alt="Plotting forecast distributions using mvgam in R" width="60%" style="display: block; margin: auto;" />

#> Out of sample DRPS:
#> 2454.53054775
#> Out of sample CRPS:
#> 2453.7903515

And the estimated latent trend component, again using the more flexible
`plot_mvgam_...()` option to show first derivatives of the estimated
Expand Down Expand Up @@ -475,42 +475,31 @@ description
```

#> Methods text skeleton
#> We used the R package mvgam (version 1.1.4; Clark & Wells, 2023) to construct, fit and int
#> errogate the model. mvgam fits Bayesian State-Space models that can include flexible predi
#> ctor effects in both the process and observation components by incorporating functionaliti
#> es from the brms (Bürkner 2017), mgcv (Wood 2017) and splines2 (Wang & Yan, 2023) packages
#> . The mvgam-constructed model and observed data were passed to the probabilistic programmi
#> ng environment Stan (version 2.34.1; Carpenter et al. 2017, Stan Development Team 2024), s
#> pecifically through the cmdstanr interface (Gabry & Češnovar, 2021). We ran 4 Hamiltonian
#> Monte Carlo chains for 500 warmup iterations and 500 sampling iterations for joint posteri
#> or estimation. Rank normalized split Rhat (Vehtari et al. 2021) and effective sample sizes
#> were used to monitor convergence.
#> We used the R package mvgam (version 1.1.4; Clark & Wells, 2023) to construct, fit and interrogate the mo
#> del. mvgam fits Bayesian State-Space models that can include flexible predictor effects in both the proce
#> ss and observation components by incorporating functionalities from the brms (Bürkner 2017), mgcv (Wood 2
#> 017) and splines2 (Wang & Yan, 2023) packages. The mvgam-constructed model and observed data were passed
#> to the probabilistic programming environment Stan (version 2.34.1; Carpenter et al. 2017, Stan Developmen
#> t Team 2024), specifically through the cmdstanr interface (Gabry & Češnovar, 2021). We ran 4 Hamiltonian
#> Monte Carlo chains for 500 warmup iterations and 500 sampling iterations for joint posterior estimation.
#> Rank normalized split Rhat (Vehtari et al. 2021) and effective sample sizes were used to monitor converge
#> nce.

#>
#> Primary references
#> Clark, NJ and Wells K (2022). Dynamic Generalized Additive Models (DGAMs) for forecasting discrete ecological time series. Methods in Ecology and Evolution, 14, 771-784. doi.org/10.1111/2041-210X.13974
#>
#> Bürkner, PC (2017). brms: An R Package for Bayesian Multilevel Models Using Stan. Journal of Statistical Software, 80(1), 1-28. doi:10.18637/jss.v080.i01
#>
#> Wood, SN (2017). Generalized Additive Models: An Introduction with R (2nd edition). Chapman and Hall/CRC.
#>
#> Wang W and Yan J (2021). Shape-Restricted Regression Splines with R Package splines2. Journal of Data Science, 19(3), 498-517. doi:10.6339/21-JDS1020 <https://doi.org/10.6339/21-JDS1020>.
#>
#> Carpenter, B, Gelman, A, Hoffman, MD, Lee, D, Goodrich, B, Betancourt, M, Brubaker, M, Guo, J, Li, P and Riddell, A (2017). Stan: A probabilistic programming language. Journal of Statistical Software 76.
#>
#> Gabry J, Češnovar R, Johnson A, and Bronder S (2024). cmdstanr: R Interface to 'CmdStan'. https://mc-stan.org/cmdstanr/, https://discourse.mc-stan.org.
#>
#> Vehtari A, Gelman A, Simpson D, Carpenter B, and Bürkner P (2021). “Rank-normalization, folding, and localization: An improved Rhat for assessing convergence of MCMC (with discussion).” Bayesian Analysis 16(2) 667-718. https://doi.org/10.1214/20-BA1221.
#>
#>
#> Other useful references
#> Arel-Bundock V (2024). marginaleffects: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests. R package version 0.19.0.4, https://marginaleffects.com/.
#> 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.
#>
#> 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.
#>
#> Bürkner, 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
#>

## Extended observation families

Expand Down Expand Up @@ -629,7 +618,7 @@ summary(mod, include_betas = FALSE)
#> 0 of 2000 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 9:26:10 AM 2024.
#> Samples were drawn using NUTS(diag_e) at Tue Dec 03 9:39:28 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
Expand Down
Binary file modified man/figures/README-unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-13-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-14-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-15-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-16-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-17-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-18-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-19-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-20-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-21-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-22-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-23-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-24-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d03d92c

Please sign in to comment.