MyNixOS website logo
Description

Bayesian Nonlinear Ornstein-Uhlenbeck Models with Stochastic Volatility.

Fits Bayesian nonlinear Ornstein-Uhlenbeck models with cubic drift, stochastic volatility, and Student-t innovations. The package implements hierarchical priors for sector-specific parameters and supports parallel MCMC sampling via 'Stan'. Model comparison is performed using Pareto Smoothed Importance Sampling Leave-One-Out (PSIS-LOO) cross-validation following Vehtari, Gelman, and Gabry (2017) <doi:10.1007/s11222-016-9696-4>. Prior specifications follow recommendations from Gelman (2006) <doi:10.1214/06-BA117A> for scale parameters.

bayesianOU

Bayesian Nonlinear Ornstein-Uhlenbeck Models with Stochastic Volatility

Overview

The bayesianOU package fits Bayesian nonlinear Ornstein-Uhlenbeck models with cubic drift, stochastic volatility (SV), and Student-t innovations. It implements hierarchical priors for sector-specific parameters and supports parallel MCMC sampling via Stan.

Installation

# Install from GitHub (development version)
# install.packages("remotes")
remotes::install_github("author/bayesianOU")

# For Stan backend, you need either cmdstanr or rstan
# cmdstanr (recommended):
install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
cmdstanr::install_cmdstan()

# Or rstan:
install.packages("rstan")

Quick Start

library(bayesianOU)

# Prepare data
Y <- as.matrix(your_prices_data)
X <- as.matrix(your_production_prices_data)
TMG <- your_tmg_series
COM <- as.matrix(your_com_data)
K <- as.matrix(your_capital_data)

# Fit model
results <- fit_ou_nonlinear_tmg(
  results_robust = list(),
  Y = Y, X = X, TMG = TMG, COM = COM, CAPITAL_TOTAL = K,
  chains = 4, iter = 8000, warmup = 4000,
  verbose = TRUE
)

# Validate fit
validate_ou_fit(results)

# Extract convergence evidence
conv <- extract_convergence_evidence(results)

# Plot results
plot_beta_tmg(results)
plot_drift_curves(results)

Model Specification

The model implements a nonlinear OU process with cubic drift:

$$dY_t = \kappa(\theta - Y_t + a_3 (Y_t - \theta)^3) dt + \sigma_t dW_t$$

where:

  • $\kappa_s$ is the sector-specific mean reversion speed
  • $\theta_s$ is the sector-specific equilibrium level
  • $a_3$ is the cubic nonlinearity coefficient
  • $\sigma_t$ follows an AR(1) stochastic volatility process
  • Innovations are Student-t distributed with estimated degrees of freedom

Features

  • Hierarchical priors for sector-specific parameters
  • Stochastic volatility with AR(1) log-variance
  • Student-t innovations for fat tails
  • Parallel likelihood computation via Stan's reduce_sum
  • PSIS-LOO cross-validation for model comparison
  • Out-of-sample forecast evaluation

Citation

If you use this package, please cite:

@software{bayesianOU,
  author = {Author Name},
  title = {bayesianOU: Bayesian Nonlinear Ornstein-Uhlenbeck Models},
  year = {2024},
  url = {https://github.com/author/bayesianOU}
}

References

  • Stan User's Guide (SV, HMM, parallelization)
  • Vehtari, Gelman, Gabry (2017). Practical Bayesian model evaluation using leave-one-out cross-validation. Statistics and Computing.
  • Gelman (2006). Prior distributions for variance parameters in hierarchical models. Bayesian Analysis.

License

MIT License.

Metadata

Version

0.1.3

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows