Code Monkey home page Code Monkey logo

bayesgarch's Introduction

bayesGARCH

The package bayesGARCH (Ardia and Hoogerheide, 2010) implements in R the Bayesian estimation procedure described in Ardia (2008) for the GARCH(1,1) model with Student-t innovations. The approach consists of a Metropolis-Hastings (MH) algorithm where the proposal distributions are constructed from auxiliary ARMA processes on the squared observations. This methodology avoids the time-consuming and difficult task, especially for non-experts, of choosing and tuning a sampling algorithm.

Please cite the package in publications!

By using bayesGARCH you agree to the following rules:

  1. You must cite Ardia and Hoogerheide (2010) in working papers and published papers that use bayesGARCH.
  2. You must place the following URL in a footnote to help others find bayesGARCH: https://CRAN.R-project.org/package=bayesGARCH.
  3. You assume all risk for the use of bayesGARCH.

Ardia, D., Hoogerheide, L.F. (2010).
Bayesian estimation of the GARCH(1,1) model with Student-t innovations.
R Journal, 2(2), 41-47.
https://doi.org/10.32614/RJ-2010-014

Ardia, D. (2008).
Financial Risk Management with Bayesian Estimation of GARCH Models: Theory and Applications.
volume 612 series Lecture Notes in Economics and Mathematical Systems. Springer-Verlag, Berlin, Germany.
https://doi.org/10.1007/978-3-540-78657-3

bayesgarch's People

Contributors

ardiad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bayesgarch's Issues

Issue with bayesGARCH

Hi, I´m trying to run the following script

library(tidyr)
library(dplyr)
library(bayesGARCH)
library(coda)
library(ggplot2)
library(patchwork)
library(quantmod)

CORN_futures <- getSymbols("ZC=F", auto.assign = FALSE,
from = "2021-08-01", end = Sys.Date()) # Target

log_ret <- diff(log(Cl(CORN_futures)))

log_ret <- log_ret[1:182,] %>% na.exclude()

sum(is.na(log_ret))

log_ret <- log_ret[2:180]

set.seed(1234)

MCMC <- bayesGARCH(log_ret, control = list(l.chain = 5000, n.chain = 2))

Error in uniroot(fn.neg.alpha, interval = c(alpha.min, alpha.max), tol = .Machine$double.eps, : f() values at end points not of
opposite sign Calls: ... bayesGARCH -> fn.bayesGARCH -> fn.block -> fn.nu.full -> unitroot

How can I fix it ?

Error when both `n.chain` and `start.val` are given if `n.chain>1`

Hi @ArdiaD,

thanks for the package. For improved MCMC diagnostics for my case study, I wanted to run multiple chains and also provide starting values. I got into an error that I was able to overcome only by reading the source code of the package.

MWE:

model_control <- list(n.chain = 2,
                      start.val = matrix(c(0.01, 0.1, 0.7, 500,
                                           0.3, 3, 0.01, 500),
                                         2, 4, byrow = TRUE))
fit <- bayesGARCH(rep(0, 10), control = model_control)

The following error is thrown before sampling starts:

Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent

The problem is in this line:

else con$start.val <- matrix(rep(con$start.val, con$n.chain),

It is true that providing n.chain is redundant if start.val is given but I personally found the behavior counterintuitive (I think in JAGS and Stan you have to provide both) and the solution should be simple.
I hope you find this ticket useful.

Cheers,
Darjus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.