diff --git a/README.Rmd b/README.Rmd index 9966b743..1043332c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -26,9 +26,8 @@ knitr::opts_chunk$set( > **M**ulti**V**ariate (Dynamic) **G**eneralized **A**ddivite **M**odels [![R-CMD-check](https://github.com/nicholasjclark/mvgam/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nicholasjclark/mvgam/actions/) -[![Test status](https://github.com/nicholasjclark/mvgam/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/nicholasjclark/mvgam/actions/workflows/test-coverage.yaml) [![Coverage status](https://codecov.io/gh/nicholasjclark/mvgam/graph/badge.svg?token=RCJ2B7S0BL)](https://app.codecov.io/gh/nicholasjclark/mvgam) -[![Documentation](https://img.shields.io/badge/documentation-mvgam-orange.svg?colorB=E91E63)](https://nicholasjclark.github.io/mvgam/) +[![Documentation](https://img.shields.io/badge/documentation-mvgam-orange.svg?colorB=brightgreen)](https://nicholasjclark.github.io/mvgam/) [![CRAN Version](https://www.r-pkg.org/badges/version/mvgam)](https://cran.r-project.org/package=mvgam) [![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/mvgam?color=brightgreen)](https://cran.r-project.org/package=mvgam) @@ -56,14 +55,11 @@ When using any software please make sure to appropriately acknowledge the hard w When using `mvgam`, please cite the following: -- Clark, N.J. and Wells, K. (2022). Dynamic Generalized Additive Models (DGAMs) for forecasting discrete ecological time series. *Methods in Ecology and Evolution*. DOI: https://doi.org/10.1111/2041-210X.13974 +> Clark, N.J. and Wells, K. (2022). Dynamic Generalized Additive Models (DGAMs) for forecasting discrete ecological time series. *Methods in Ecology and Evolution*. DOI: https://doi.org/10.1111/2041-210X.13974 As `mvgam` acts as an interface to `Stan`, please additionally cite: -- Carpenter B., Gelman A., Hoffman M. D., 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(1). - 10.18637/jss.v076.i01 +> Carpenter B., Gelman A., Hoffman M. D., 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(1). DOI: https://doi.org/10.18637/jss.v076.i01 `mvgam` relies on several other `R` packages and, of course, on `R` itself. To find out how to cite R and its packages, use the `citation` function. There are @@ -102,7 +98,7 @@ plot(stl(ts(lynx_full$population, frequency = 19), s.window = 'periodic'), lynx_full$season <- (lynx_full$year%%19) + 1 ``` -For `mvgam` models, we need an indicator of the series name as a `factor` (if the column `series` is missing, this will be added automatically by assuming that all observations are from a single time series). A `time` column is needed to index time +For most `mvgam` models, we need an indicator of the series name as a `factor`. A `time` column is also needed for most models to index time (but note that these variables are not necessarily needed for other models supported by `mvgam`, such as [Joint Species Distribution Models](https://nicholasjclark.github.io/mvgam/reference/jsdgam.html)) ```{r} lynx_full$time <- 1:NROW(lynx_full) lynx_full$series <- factor('series1') diff --git a/README.md b/README.md index 21db6db4..86c4025d 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,9 @@ > **M**ulti**V**ariate (Dynamic) **G**eneralized **A**ddivite **M**odels [![R-CMD-check](https://github.com/nicholasjclark/mvgam/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nicholasjclark/mvgam/actions/) -[![Test -status](https://github.com/nicholasjclark/mvgam/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/nicholasjclark/mvgam/actions/workflows/test-coverage.yaml) [![Coverage status](https://codecov.io/gh/nicholasjclark/mvgam/graph/badge.svg?token=RCJ2B7S0BL)](https://app.codecov.io/gh/nicholasjclark/mvgam) -[![Documentation](https://img.shields.io/badge/documentation-mvgam-orange.svg?colorB=E91E63)](https://nicholasjclark.github.io/mvgam/) +[![Documentation](https://img.shields.io/badge/documentation-mvgam-orange.svg?colorB=brightgreen)](https://nicholasjclark.github.io/mvgam/) [![CRAN Version](https://www.r-pkg.org/badges/version/mvgam)](https://cran.r-project.org/package=mvgam) [![CRAN @@ -98,16 +96,16 @@ that you rely on for your research. When using `mvgam`, please cite the following: -- Clark, N.J. and Wells, K. (2022). Dynamic Generalized Additive Models - (DGAMs) for forecasting discrete ecological time series. *Methods in - Ecology and Evolution*. DOI: +> Clark, N.J. and Wells, K. (2022). Dynamic Generalized Additive Models +> (DGAMs) for forecasting discrete ecological time series. *Methods in +> Ecology and Evolution*. DOI: As `mvgam` acts as an interface to `Stan`, please additionally cite: -- Carpenter B., Gelman A., Hoffman M. D., 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(1). 10.18637/jss.v076.i01 +> Carpenter B., Gelman A., Hoffman M. D., 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(1). DOI: `mvgam` relies on several other `R` packages and, of course, on `R` itself. To find out how to cite R and its packages, use the `citation` @@ -164,10 +162,11 @@ plot(stl(ts(lynx_full$population, frequency = 19), s.window = 'periodic'), lynx_full$season <- (lynx_full$year%%19) + 1 ``` -For `mvgam` models, we need an indicator of the series name as a -`factor` (if the column `series` is missing, this will be added -automatically by assuming that all observations are from a single time -series). A `time` column is needed to index time +For most `mvgam` models, we need an indicator of the series name as a +`factor`. A `time` column is also needed for most models to index time +(but note that these variables are not necessarily needed for other +models supported by `mvgam`, such as [Joint Species Distribution +Models](https://nicholasjclark.github.io/mvgam/reference/jsdgam.html)) ``` r lynx_full$time <- 1:NROW(lynx_full) @@ -238,28 +237,28 @@ summary(lynx_mvgam) #> #> GAM coefficient (beta) estimates: #> 2.5% 50% 97.5% Rhat n_eff -#> (Intercept) 6.400 6.60 6.900 1.00 821 -#> s(season).1 -0.640 -0.12 0.390 1.00 1356 -#> s(season).2 0.780 1.30 1.900 1.00 1241 -#> s(season).3 1.300 1.90 2.500 1.00 889 -#> s(season).4 -0.062 0.53 1.200 1.00 1119 -#> s(season).5 -1.300 -0.72 -0.099 1.01 1113 -#> s(season).6 -1.300 -0.57 0.092 1.00 1101 -#> s(season).7 0.023 0.70 1.400 1.00 1355 -#> s(season).8 0.640 1.40 2.100 1.01 1111 -#> s(season).9 -0.370 0.21 0.830 1.01 847 -#> s(season).10 -1.400 -0.87 -0.370 1.00 1108 +#> (Intercept) 6.400 6.60 6.900 1 660 +#> s(season).1 -0.640 -0.12 0.390 1 1035 +#> s(season).2 0.690 1.30 1.900 1 893 +#> s(season).3 1.200 1.90 2.500 1 842 +#> s(season).4 -0.079 0.53 1.100 1 830 +#> s(season).5 -1.300 -0.71 -0.058 1 849 +#> s(season).6 -1.200 -0.56 0.110 1 1168 +#> s(season).7 0.058 0.72 1.400 1 997 +#> s(season).8 0.660 1.40 2.100 1 1019 +#> s(season).9 -0.350 0.24 0.840 1 906 +#> s(season).10 -1.400 -0.85 -0.370 1 1124 #> #> Approximate significance of GAM smooths: #> edf Ref.df Chi.sq p-value -#> s(season) 9.97 10 48.8 <2e-16 *** +#> s(season) 9.99 10 45.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.61 0.83 0.99 1.01 666 -#> sigma[1] 0.38 0.48 0.60 1.00 688 +#> ar1[1] 0.59 0.82 0.98 1.00 660 +#> sigma[1] 0.39 0.48 0.61 1.01 628 #> #> Stan MCMC diagnostics: #> n_eff / iter looks reasonable for all parameters @@ -268,7 +267,7 @@ summary(lynx_mvgam) #> 0 of 2000 iterations saturated the maximum tree depth of 12 (0%) #> E-FMI indicated no pathological behavior #> -#> Samples were drawn using NUTS(diag_e) at Thu Oct 24 1:32:39 PM 2024. +#> Samples were drawn using NUTS(diag_e) at Thu Oct 31 9:16:35 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) @@ -405,7 +404,7 @@ series (testing and training) ``` r plot(lynx_mvgam, type = 'forecast', newdata = lynx_test) #> Out of sample DRPS: -#> 2470.51814475 +#> 2380.3470865 ``` Plotting forecast distributions using mvgam in R @@ -566,7 +565,7 @@ summary(mod, include_betas = FALSE) #> 0 of 2000 iterations saturated the maximum tree depth of 12 (0%) #> E-FMI indicated no pathological behavior #> -#> Samples were drawn using NUTS(diag_e) at Thu Oct 24 1:33:28 PM 2024. +#> Samples were drawn using NUTS(diag_e) at Thu Oct 31 9:17:20 AM 2024. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split MCMC chains #> (at convergence, Rhat = 1) diff --git a/man/figures/README-unnamed-chunk-12-1.png b/man/figures/README-unnamed-chunk-12-1.png index ab0a563b..e0eee0be 100644 Binary files a/man/figures/README-unnamed-chunk-12-1.png and b/man/figures/README-unnamed-chunk-12-1.png differ diff --git a/man/figures/README-unnamed-chunk-13-1.png b/man/figures/README-unnamed-chunk-13-1.png index 1dd71f45..1df164e6 100644 Binary files a/man/figures/README-unnamed-chunk-13-1.png and b/man/figures/README-unnamed-chunk-13-1.png differ diff --git a/man/figures/README-unnamed-chunk-14-1.png b/man/figures/README-unnamed-chunk-14-1.png index 10ddf9af..7db3e62e 100644 Binary files a/man/figures/README-unnamed-chunk-14-1.png and b/man/figures/README-unnamed-chunk-14-1.png differ diff --git a/man/figures/README-unnamed-chunk-15-1.png b/man/figures/README-unnamed-chunk-15-1.png index 6bf5afe5..169cd0c0 100644 Binary files a/man/figures/README-unnamed-chunk-15-1.png and b/man/figures/README-unnamed-chunk-15-1.png differ diff --git a/man/figures/README-unnamed-chunk-16-1.png b/man/figures/README-unnamed-chunk-16-1.png index 9929b3e1..990b42ad 100644 Binary files a/man/figures/README-unnamed-chunk-16-1.png and b/man/figures/README-unnamed-chunk-16-1.png differ diff --git a/man/figures/README-unnamed-chunk-17-1.png b/man/figures/README-unnamed-chunk-17-1.png index 513dffbf..28deb72c 100644 Binary files a/man/figures/README-unnamed-chunk-17-1.png and b/man/figures/README-unnamed-chunk-17-1.png differ diff --git a/man/figures/README-unnamed-chunk-18-1.png b/man/figures/README-unnamed-chunk-18-1.png index e46fe4c1..2a08d25f 100644 Binary files a/man/figures/README-unnamed-chunk-18-1.png and b/man/figures/README-unnamed-chunk-18-1.png differ diff --git a/man/figures/README-unnamed-chunk-19-1.png b/man/figures/README-unnamed-chunk-19-1.png index 5698f0da..cd916723 100644 Binary files a/man/figures/README-unnamed-chunk-19-1.png and b/man/figures/README-unnamed-chunk-19-1.png differ diff --git a/man/figures/README-unnamed-chunk-20-1.png b/man/figures/README-unnamed-chunk-20-1.png index 52bef894..d4df7d24 100644 Binary files a/man/figures/README-unnamed-chunk-20-1.png and b/man/figures/README-unnamed-chunk-20-1.png differ diff --git a/man/figures/README-unnamed-chunk-21-1.png b/man/figures/README-unnamed-chunk-21-1.png index 77eb6bcb..6941b175 100644 Binary files a/man/figures/README-unnamed-chunk-21-1.png and b/man/figures/README-unnamed-chunk-21-1.png differ diff --git a/man/figures/README-unnamed-chunk-22-1.png b/man/figures/README-unnamed-chunk-22-1.png index 3ced63da..65bfd5d8 100644 Binary files a/man/figures/README-unnamed-chunk-22-1.png and b/man/figures/README-unnamed-chunk-22-1.png differ diff --git a/man/figures/README-unnamed-chunk-23-1.png b/man/figures/README-unnamed-chunk-23-1.png index 2bc904ef..93bd98c2 100644 Binary files a/man/figures/README-unnamed-chunk-23-1.png and b/man/figures/README-unnamed-chunk-23-1.png differ diff --git a/man/figures/README-unnamed-chunk-24-1.png b/man/figures/README-unnamed-chunk-24-1.png index 08ee5af0..5084c5d1 100644 Binary files a/man/figures/README-unnamed-chunk-24-1.png and b/man/figures/README-unnamed-chunk-24-1.png differ