Skip to content

Commit

Permalink
update vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
ygeunkim committed Sep 16, 2024
1 parent 81588bc commit 344b8c7
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request' && "!startsWith(github.ref, 'refs/heads/release/')"
if: "github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/heads/release/')"
uses: JamesIves/[email protected]
with:
token: ${{ secrets.YGEUNKIM_PAGE_PAT }}
Expand Down
18 changes: 7 additions & 11 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ install.packages("bvhar")

<!-- dev badges: start -->
[![dev-r-cmd-check](https://github.com/ygeunkim/bvhar/actions/workflows/R-CMD-check.yaml/badge.svg?branch=develop)](https://github.com/ygeunkim/bvhar/actions/workflows/R-CMD-check.yaml?query=branch%3Adevelop)
[![dev-codecov](https://codecov.io/github/ygeunkim/bvhar/branch/develop/graph/badge.svg)](https://codecov.io/github/ygeunkim/bvhar)
[![dev-codecov](https://codecov.io/github/ygeunkim/bvhar/branch/develop/graph/badge.svg)](https://app.codecov.io/gh/ygeunkim/bvhar/tree/develop)
[![Development version updated](https://img.shields.io/github/last-commit/ygeunkim/bvhar/develop?label=dev%20updated)](https://github.com/ygeunkim/bvhar/tree/develop)
<!-- dev badges: end -->

Expand All @@ -60,6 +60,11 @@ You can install the development version from [develop branch](https://github.com
remotes::install_github("ygeunkim/bvhar@develop")
```

We started to develop a Python version in python directory.

- [bvhar for Python](https://ygeunkim.github.io/package/bvhar/python/)
- [Source code](https://github.com/ygeunkim/bvhar/tree/develop/python)

## Models

```{r example, message=FALSE}
Expand All @@ -80,6 +85,7 @@ Repeatedly, `bvhar` is a research tool to analyze multivariate time series model

This readme document shows forecasting procedure briefly.
Details about each function are in vignettes and help documents.
Note that each `bvar_minnesota()` and `bvhar_minnesota()` will be integrated into `var_bayes()` and `vhar_bayes()` and removed in the next version.

h-step ahead forecasting:

Expand Down Expand Up @@ -186,16 +192,6 @@ forecast_bvhar_v2 <- predict(mod_bvhar_v2, h)
(msebvhar_v2 <- mse(forecast_bvhar_v2, etf_te))
```

## Plots

```{r predfig}
autoplot(forecast_var, x_cut = 870, ci_alpha = .7, type = "wrap") +
autolayer(forecast_vhar, ci_alpha = .6) +
autolayer(forecast_bvar, ci_alpha = .4) +
autolayer(forecast_bvhar_v1, ci_alpha = .2) +
autolayer(forecast_bvhar_v2, ci_alpha = .1)
```

## Citation

Please cite this package with following BibTeX:
Expand Down
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install.packages("bvhar")
<!-- dev badges: start -->

[![dev-r-cmd-check](https://github.com/ygeunkim/bvhar/actions/workflows/R-CMD-check.yaml/badge.svg?branch=develop)](https://github.com/ygeunkim/bvhar/actions/workflows/R-CMD-check.yaml?query=branch%3Adevelop)
[![dev-codecov](https://codecov.io/github/ygeunkim/bvhar/branch/develop/graph/badge.svg)](https://codecov.io/github/ygeunkim/bvhar)
[![dev-codecov](https://codecov.io/github/ygeunkim/bvhar/branch/develop/graph/badge.svg)](https://app.codecov.io/gh/ygeunkim/bvhar/tree/develop)
[![Development version
updated](https://img.shields.io/github/last-commit/ygeunkim/bvhar/develop?label=dev%20updated)](https://github.com/ygeunkim/bvhar/tree/develop)
<!-- dev badges: end -->
Expand All @@ -52,6 +52,11 @@ branch](https://github.com/ygeunkim/bvhar/tree/develop).
remotes::install_github("ygeunkim/bvhar@develop")
```

We started to develop a Python version in python directory.

- [bvhar for Python](https://ygeunkim.github.io/package/bvhar/python/)
- [Source code](https://github.com/ygeunkim/bvhar/tree/develop/python)

## Models

``` r
Expand All @@ -72,7 +77,9 @@ series model above
| BVHAR | `vhar_bayes()` | SSVS, Horseshoe, Minnesota, NG, DL |

This readme document shows forecasting procedure briefly. Details about
each function are in vignettes and help documents.
each function are in vignettes and help documents. Note that each
`bvar_minnesota()` and `bvhar_minnesota()` will be integrated into
`var_bayes()` and `vhar_bayes()` and removed in the next version.

h-step ahead forecasting:

Expand Down Expand Up @@ -274,18 +281,6 @@ forecast_bvhar_v2 <- predict(mod_bvhar_v2, h)
#> 5.54
```

## Plots

``` r
autoplot(forecast_var, x_cut = 870, ci_alpha = .7, type = "wrap") +
autolayer(forecast_vhar, ci_alpha = .6) +
autolayer(forecast_bvar, ci_alpha = .4) +
autolayer(forecast_bvhar_v1, ci_alpha = .2) +
autolayer(forecast_bvhar_v2, ci_alpha = .1)
```

<img src="man/figures/README-predfig-1.png" width="70%" style="display: block; margin: auto;" />

## Citation

Please cite this package with following BibTeX:
Expand All @@ -294,15 +289,19 @@ Please cite this package with following BibTeX:
title = {{bvhar}: Bayesian Vector Heterogeneous Autoregressive Modeling},
author = {Young Geun Kim and Changryong Baek},
year = {2023},
note = {R package version 2.0.1.9014},
doi = {10.32614/CRAN.package.bvhar},
note = {R package version 2.1.0},
url = {https://cran.r-project.org/package=bvhar},
}

@Article{,
title = {Bayesian Vector Heterogeneous Autoregressive Modeling},
author = {Young Geun Kim and Changryong Baek},
journal = {Journal of Statistical Computation and Simulation},
year = {2023},
year = {2024},
volume = {94},
number = {6},
pages = {1139--1157},
doi = {10.1080/00949655.2023.2281644},
}

Expand Down
39 changes: 22 additions & 17 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ home:
# see the configuration in .github/workflows/pkgdown.yaml
- text: VERSION_TEXT
href: VERSION_REF
- text: bvhar in Python
- text: bvhar for Python
href: https://ygeunkim.github.io/package/bvhar/python/

development:
Expand Down Expand Up @@ -46,7 +46,6 @@ reference:
Prior settings for Bayesian models.
contents:
- set_bvar
- init_ssvs
- set_ssvs
- set_lambda
- set_horseshoe
Expand All @@ -70,14 +69,18 @@ reference:

- title: Deprecated
desc: >
Deprecated modeling functions that will be removed soon
Deprecated functions that will be removed soon
contents:
- bvar_sv
- bvar_ssvs
- bvar_horseshoe
- bvhar_sv
- bvhar_ssvs
- bvhar_horseshoe
- init_ssvs
- choose_ssvs
- sim_ssvs_var
- sim_horseshoe_var

- title: Forecasting
desc: ~
Expand Down Expand Up @@ -125,7 +128,6 @@ reference:
- choose_bvhar
- bound_bvhar
- choose_bayes
- choose_ssvs

- title: Information criteria
desc: ~
Expand Down Expand Up @@ -161,8 +163,6 @@ reference:
- sim_mniw
- sim_mvt
- sim_gig
- sim_ssvs_var
- sim_horseshoe_var

- title: Data
desc: ~
Expand All @@ -178,13 +178,16 @@ reference:
- residuals
- fitted

# destination: '../../myprofile/young-blogdown/static/package/bvhar'

navbar:
structure:
left: [intro, reference, articles, tutorials, news, research, accepted]
left: [intro, reference, articles, tutorials, news, publication, research, accepted]
right: [github, goback]
components:
publication:
icon: fa-newspaper
href: https://www.tandfonline.com/eprint/ZIRSC2CDJ9JM9FK2E3WD/full?target=10.1080/00949655.2023.2281644
aria-label: Published
text: Published
research:
icon: fa-laptop-code
href: https://github.com/ygeunkim/paper-bvhar
Expand All @@ -204,15 +207,17 @@ news:
href: https://github.com/ygeunkim/bvhar/releases/tag/v0.12.0
# - text: "Version 1.0.0"
# href: https://github.com/ygeunkim/bvhar/releases/tag/v1.0.0
# - text: "Version 1.0.1"
# href: https://github.com/ygeunkim/bvhar/releases/tag/v1.0.1
# - text: "Version 1.0.2"
# href: https://github.com/ygeunkim/bvhar/releases/tag/v1.0.2
# - text: "Version 1.1.0"
# href: https://github.com/ygeunkim/bvhar/releases/tag/v1.1.0
- text: "Version 1.0.1"
href: https://github.com/ygeunkim/bvhar/releases/tag/v1.0.1
- text: "Version 1.0.2"
href: https://github.com/ygeunkim/bvhar/releases/tag/v1.0.2
- text: "Version 1.1.0"
href: https://github.com/ygeunkim/bvhar/releases/tag/v1.1.0
- text: "Version 1.2.0"
href: https://github.com/ygeunkim/bvhar/releases/tag/v1.2.0
# - text: "Version 2.0.0"
# href: https://github.com/ygeunkim/bvhar/releases/tag/v2.0.0
- text: "Version 2.0.0"
href: https://github.com/ygeunkim/bvhar/releases/tag/v2.0.0
- text: "Version 2.0.1"
href: https://github.com/ygeunkim/bvhar/releases/tag/v2.0.1
- text: "Version 2.1.0"
href: https://github.com/ygeunkim/bvhar/releases/tag/v2.1.0
Binary file removed man/figures/README-predfig-1.png
Binary file not shown.
48 changes: 33 additions & 15 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
# Platform

|field |value |
|:--------|:---------------------------------------------|
|version |R version 4.3.2 (2023-10-31) |
|os |macOS Ventura 13.6.4 |
|system |aarch64, darwin20 |
|ui |X11 |
|language |(EN) |
|collate |en_US.UTF-8 |
|ctype |UTF-8 |
|tz |Asia/Seoul |
|date |2024-03-01 |
|pandoc |3.1.12.1 @ /opt/homebrew/bin/ (via rmarkdown) |
|field |value |
|:--------|:----------------------------|
|version |R version 4.3.3 (2024-02-29) |
|os |macOS Big Sur ... 10.16 |
|system |x86_64, darwin20 |
|ui |X11 |
|language |(EN) |
|collate |en_US.UTF-8 |
|ctype |en_US.UTF-8 |
|tz |Asia/Seoul |
|date |2024-09-16 |
|pandoc |3.3 @ /usr/local/bin/pandoc |

# Dependencies

|package |old |new |Δ |
|:-------|:-----|:-----|:--|
|bvhar |2.0.0 |2.0.1 |* |
|package |old |new |Δ |
|:-----------|:-----|:---------|:--|
|bvhar |2.0.1 |2.1.0 |* |
|abind |NA |1.4-8 |* |
|backports |NA |1.5.0 |* |
|checkmate |NA |2.3.2 |* |
|cli |NA |3.6.3 |* |
|colorspace |NA |2.1-1 |* |
|cpp11 |NA |0.4.7 |* |
|farver |NA |2.1.2 |* |
|ggplot2 |NA |3.5.1 |* |
|gtable |NA |0.3.5 |* |
|matrixStats |NA |1.4.1 |* |
|munsell |NA |0.5.1 |* |
|posterior |NA |1.5.0 |* |
|Rcpp |NA |1.0.13 |* |
|RcppEigen |NA |0.3.4.0.2 |* |
|rlang |NA |1.1.4 |* |
|stringi |NA |1.8.4 |* |
|tidyselect |NA |1.2.1 |* |
|withr |NA |3.0.1 |* |

# Revdeps

4 changes: 3 additions & 1 deletion vignettes/bvhar.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ names(fit_har)

## BVAR

`bvhar` package provides two prior framework - Minnesota prior and flat prior.
This page provides deprecated two functions examples.
Both `bvar_minnesota()` and `bvar_flat()` will be integrated into `var_bayes()` and removed in the next version.

### Minnesota prior

Expand Down Expand Up @@ -348,6 +349,7 @@ We call this VAR-type Minnesota prior or BVHAR-S.

`bvhar_minnesota(y, har = c(5, 22), bayes_spec, include_mean = TRUE)` can fit BVHAR with this prior.
This is the default prior setting.
Similar to above functions, this function will be also integrated into `vhar_bayes()` and removed in the next version.

```{r}
(fit_bvhar_v1 <- bvhar_minnesota(etf_train, num_iter = 10, bayes_spec = bvhar_spec_v1))
Expand Down
45 changes: 35 additions & 10 deletions vignettes/shrinkage.Rmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Shrinkage Priors"
title: "Bayesian VAR and VHAR Models"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Shrinkage Priors}
%\VignetteIndexEntry{Bayesian VAR and VHAR Models}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand All @@ -26,36 +26,44 @@ library(bvhar)
```

```{r etfdat}
etf <- etf_vix[1:100, 1:3]
etf <- etf_vix[1:55, 1:3]
# Split-------------------------------
h <- 5
etf_eval <- divide_ts(etf, h)
etf_train <- etf_eval$train
etf_test <- etf_eval$test
```

# Bayesian VAR and VHAR

# Stochastic Search Variable Selection (SSVS) Prior
`var_bayes()` and `vhar_bayes()` fit BVAR and BVHAR each with various priors.

- `y`: Multivariate time series data. It should be data frame or matrix, which means that every column is numeric. Each column indicates variable, i.e. it sould be wide format.
- `har`: Order of VHAR
- `p` or `har`: VAR lag, or order of VHAR
- `num_chains`: Number of chains
- If OpenMP is enabled, parallel loop will be run.
- `num_iter`: Total number of iterations
- `num_burn`: Number of burn-in
- `thinning`: Thinning
- `bayes_spec`: Output of `set_ssvs()`
- By default, use a default semi-automatic approach using `choose_ssvs()`.
<!-- - `init_spec`: Gibbs sampler initialization by `init_ssvs()`. -->
<!-- - By default, `init_ssvs(type = "auto")` uses OLS. -->
- Minneosta prior
- BVAR: `set_bvar()`
- BVHAR: `set_bvhar()` and `set_weight_bvhar()`
- Can induce prior on $\lambda$ using `lambda = set_lambda()`
- SSVS prior: `set_ssvs()`
- Horseshoe prior: `set_horseshoe()`
- NG prior: `set_ng()`
- DL prior: `set_dl()`
- `cov_spec`: Covariance prior specification. Use `set_ldlt()` for homoskedastic model.
- `include_mean = TRUE`: By default, you include the constant term in the model.
- `minnesota = c("no", "short", "longrun")`: Minnesota-type shrinkage.
- `verbose = FALSE`: Progress bar
- `num_thread`: Number of thread for OpenMP
- Used in both Eigen computation and parallel multi-chain loop
- Used in parallel multi-chain loop
- This option is valid only when OpenMP in user's machine.

## Stochastic Search Variable Selection (SSVS) Prior

```{r fitssvs}
(fit_ssvs <- vhar_bayes(etf_train, num_chains = 1, num_iter = 20, bayes_spec = set_ssvs(), cov_spec = set_ldlt(), include_mean = FALSE, minnesota = "longrun"))
```
Expand All @@ -68,7 +76,7 @@ autoplot(fit_ssvs)
```


# Horseshoe Prior
## Horseshoe Prior

`bayes_spec` is the initial specification by `set_horseshoe()`. Others are the same.

Expand All @@ -80,6 +88,23 @@ autoplot(fit_ssvs)
autoplot(fit_hs)
```

## Minnesota Prior

```{r fitmn}
(fit_mn <- vhar_bayes(etf_train, num_chains = 2, num_iter = 20, bayes_spec = set_bvhar(lambda = set_lambda()), cov_spec = set_ldlt(), include_mean = FALSE, minnesota = "longrun"))
```

## Normal-Gamma prior

```{r fitng}
(fit_ng <- vhar_bayes(etf_train, num_chains = 2, num_iter = 20, bayes_spec = set_ng(), cov_spec = set_ldlt(), include_mean = FALSE, minnesota = "longrun"))
```

## Dirichlet-Laplace prior

```{r fitdl}
(fit_dl <- vhar_bayes(etf_train, num_chains = 2, num_iter = 20, bayes_spec = set_dl(), cov_spec = set_ldlt(), include_mean = FALSE, minnesota = "longrun"))
```

# Bayesian visualization

Expand Down
Loading

0 comments on commit 344b8c7

Please sign in to comment.