Skip to content

Commit

Permalink
update VAR docs and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Clark committed Sep 19, 2024
1 parent d13c767 commit d7df4d8
Show file tree
Hide file tree
Showing 40 changed files with 51 additions and 62 deletions.
2 changes: 1 addition & 1 deletion R/fevd.mvgam.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'@author Nicholas J Clark
#'@references Lütkepohl, H (2006).
#'New Introduction to Multiple Time Series Analysis. Springer, New York.
#'@seealso \code{\link{VAR}}, \code{\link{plot.mvgam_irf}}, \code{\link{stability}}
#'@seealso \code{\link{VAR}}, \code{\link{irf}}, \code{\link{stability}}
#' @examples
#' \donttest{
#' # Simulate some time series that follow a latent VAR(1) process
Expand Down
3 changes: 2 additions & 1 deletion R/irf.mvgam.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#'@references PH Pesaran & Shin Yongcheol (1998).
#'Generalized impulse response analysis in linear multivariate models.
#'Economics Letters 58: 17–29.
#'@seealso \code{\link{VAR}}, \code{\link{plot.mvgam_irf}}, \code{\link{stability}}
#'@seealso \code{\link{VAR}}, \code{\link{plot.mvgam_irf}}, \code{\link{stability}},
#'\code{\link{fevd}}
#' @examples
#' \donttest{
#' # Simulate some time series that follow a latent VAR(1) process
Expand Down
2 changes: 1 addition & 1 deletion R/stability.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#'Estimating community stability and ecological interactions from time-series data.
#'Ecological Monographs. 73, 301-330.
#'@author Nicholas J Clark
#'@seealso \code{\link{VAR}}, \code{\link{irf}}
#'@seealso \code{\link{VAR}}, \code{\link{irf}}, \code{\link{fevd}}
#' @examples
#' \donttest{
#' # Simulate some time series that follow a latent VAR(1) process
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ knitr::opts_chunk$set(
[![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)

The goal of `mvgam` is to fit Bayesian Dynamic Generalized Additive Models to time series data. The motivation for the package is described in [Clark & Wells 2022](https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.13974){target="_blank"} (published in *Methods in Ecology and Evolution*), with additional inspiration on the use of Bayesian probabilistic modelling coming from [Michael Betancourt](https://betanalpha.github.io/writing/){target="_blank"}, [Michael Dietze](https://www.bu.edu/earth/profiles/michael-dietze/){target="_blank"} and [Emily Fox](https://emilybfox.su.domains/){target="_blank"}, among many others.
The goal of `mvgam` is to fit Bayesian Dynamic Generalized Additive Models to time series data. The motivation for the package is described in [Clark & Wells 2022](https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.13974){target="_blank"} (published in *Methods in Ecology and Evolution*), with additional inspiration on the use of Bayesian probabilistic modelling coming from [Michael Betancourt](https://betanalpha.github.io/writing/){target="_blank"}, [Michael Dietze](https://www.bu.edu/earth/profiles/michael-dietze/){target="_blank"} and [Sarah Heaps](https://www.durham.ac.uk/staff/sarah-e-heaps/){target="_blank"}, among many others.

## Resources
A series of [vignettes cover data formatting, forecasting and several extended case studies of DGAMs](https://nicholasjclark.github.io/mvgam/){target="_blank"}. A number of other examples have also been compiled:
Expand Down
73 changes: 36 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Bayesian probabilistic modelling coming from
Betancourt</a>,
<a href="https://www.bu.edu/earth/profiles/michael-dietze/"
target="_blank">Michael Dietze</a> and
<a href="https://emilybfox.su.domains/" target="_blank">Emily Fox</a>,
among many others.
<a href="https://www.durham.ac.uk/staff/sarah-e-heaps/"
target="_blank">Sarah Heaps</a>, among many others.

## Resources

Expand Down Expand Up @@ -235,28 +235,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 961
#> s(season).1 -0.650 -0.14 0.380 1.00 984
#> s(season).2 0.730 1.30 1.900 1.00 1113
#> s(season).3 1.300 1.90 2.500 1.00 727
#> s(season).4 -0.054 0.53 1.100 1.00 727
#> s(season).5 -1.300 -0.70 -0.069 1.00 919
#> s(season).6 -1.200 -0.55 0.170 1.00 1012
#> s(season).7 0.012 0.73 1.400 1.00 1134
#> s(season).8 0.600 1.40 2.100 1.01 756
#> s(season).9 -0.410 0.22 0.810 1.00 710
#> s(season).10 -1.400 -0.87 -0.350 1.00 1164
#> (Intercept) 6.400 6.60 6.900 1 1043
#> s(season).1 -0.610 -0.12 0.380 1 1109
#> s(season).2 0.740 1.30 1.900 1 930
#> s(season).3 1.200 1.90 2.600 1 846
#> s(season).4 -0.017 0.55 1.100 1 845
#> s(season).5 -1.300 -0.69 -0.069 1 1103
#> s(season).6 -1.300 -0.56 0.120 1 1057
#> s(season).7 0.035 0.71 1.400 1 1061
#> s(season).8 0.620 1.40 2.100 1 816
#> s(season).9 -0.410 0.21 0.840 1 736
#> s(season).10 -1.300 -0.86 -0.400 1 1225
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
#> s(season) 9.95 10 53.4 <2e-16 ***
#> s(season) 9.98 10 47 <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.59 0.83 0.99 1.00 519
#> sigma[1] 0.38 0.48 0.60 1.01 485
#> ar1[1] 0.58 0.83 0.98 1.01 583
#> sigma[1] 0.38 0.48 0.61 1.00 646
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
Expand All @@ -265,7 +265,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 Tue Sep 03 1:56:36 PM 2024.
#> Samples were drawn using NUTS(diag_e) at Thu Sep 19 11:37:30 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 @@ -370,7 +370,6 @@ partial effects of smooths on the link scale
``` r
require(gratia)
#> Loading required package: gratia
#> Warning: package 'gratia' was built under R version 4.2.3
#>
#> Attaching package: 'gratia'
#> The following object is masked from 'package:mvgam':
Expand Down Expand Up @@ -403,7 +402,7 @@ series (testing and training)
``` r
plot(lynx_mvgam, type = 'forecast', newdata = lynx_test)
#> Out of sample DRPS:
#> 2356.32008125
#> 2434.43508625
```

<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;" />
Expand Down Expand Up @@ -533,41 +532,41 @@ summary(mod, include_betas = FALSE)
#>
#> Observation precision parameter estimates:
#> 2.5% 50% 97.5% Rhat n_eff
#> phi[1] 5.4 8.3 12 1 2019
#> phi[2] 5.7 8.7 13 1 1795
#> phi[3] 5.5 8.4 12 1 1680
#> phi[1] 5.4 8.3 12 1 1248
#> phi[2] 5.7 8.6 13 1 1312
#> phi[3] 5.6 8.5 12 1 1724
#>
#> GAM coefficient (beta) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
#> (Intercept) -0.18 0.19 0.45 1.01 757
#> 2.5% 50% 97.5% Rhat n_eff
#> (Intercept) -0.2 0.19 0.46 1.01 566
#>
#> Approximate significance of GAM smooths:
#> edf Ref.df Chi.sq p-value
#> s(season) 4.231 5 28.89 2.6e-06 ***
#> s(season):seriesseries_1 0.687 4 0.69 0.98
#> s(season):seriesseries_2 0.664 4 0.60 0.99
#> s(season):seriesseries_3 1.286 4 1.39 0.82
#> s(season) 3.872 5 29.63 1.6e-05 ***
#> s(season):seriesseries_1 0.615 4 0.77 0.98
#> s(season):seriesseries_2 1.012 4 0.30 0.99
#> s(season):seriesseries_3 1.106 4 1.54 0.81
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Latent trend marginal deviation (alpha) and length scale (rho) estimates:
#> 2.5% 50% 97.5% Rhat n_eff
#> alpha_gp[1] 0.06 0.41 0.96 1.00 823
#> alpha_gp[2] 0.38 0.73 1.30 1.00 1073
#> alpha_gp[3] 0.15 0.45 0.98 1.00 903
#> rho_gp[1] 1.10 3.90 14.00 1.01 302
#> rho_gp[2] 1.70 7.00 32.00 1.01 364
#> rho_gp[3] 1.30 4.80 22.00 1.01 373
#> 2.5% 50% 97.5% Rhat n_eff
#> alpha_gp[1] 0.051 0.41 0.92 1.01 525
#> alpha_gp[2] 0.360 0.72 1.20 1.00 946
#> alpha_gp[3] 0.150 0.46 1.00 1.00 659
#> rho_gp[1] 1.100 3.80 15.00 1.01 370
#> rho_gp[2] 1.900 7.80 37.00 1.01 365
#> rho_gp[3] 1.400 5.10 21.00 1.00 645
#>
#> Stan MCMC diagnostics:
#> n_eff / iter looks reasonable for all parameters
#> Rhat looks reasonable for all parameters
#> 18 of 2000 iterations ended with a divergence (0.9%)
#> 12 of 2000 iterations ended with a divergence (0.6%)
#> *Try running with larger adapt_delta to remove the divergences
#> 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 Tue Sep 03 1:57:57 PM 2024.
#> Samples were drawn using NUTS(diag_e) at Thu Sep 19 11:38:16 AM 2024.
#> For each parameter, n_eff is a crude measure of effective sample size,
#> and Rhat is the potential scale reduction factor on split MCMC chains
#> (at convergence, Rhat = 1)
Expand Down
Binary file modified docs/reference/Rplot001.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 docs/reference/Rplot002.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 docs/reference/Rplot003.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 docs/reference/Rplot004.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 docs/reference/Rplot005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/reference/fevd.mvgam.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/reference/irf.mvgam-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 docs/reference/irf.mvgam-2.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 docs/reference/irf.mvgam-3.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 docs/reference/irf.mvgam-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions docs/reference/irf.mvgam.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/reference/stability.mvgam-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 docs/reference/stability.mvgam-2.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 docs/reference/stability.mvgam-3.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 docs/reference/stability.mvgam-4.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 docs/reference/stability.mvgam-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 1 addition & 14 deletions docs/reference/stability.mvgam.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fevd.mvgam.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-beta_fc-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-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
Binary file modified man/figures/README-unnamed-chunk-23-1.png
Binary file modified man/figures/README-unnamed-chunk-24-1.png
3 changes: 2 additions & 1 deletion man/irf.mvgam.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/stability.mvgam.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/mvgam.dll
Binary file not shown.

0 comments on commit d7df4d8

Please sign in to comment.