gregorkastner / stochvol

Partial re-write of the R package stochvol to allow for asymmetry (leverage).
15 stars 9 forks source link

sv_inverse_gamma parameters #21

Closed alexslavco closed 1 year ago

alexslavco commented 1 year ago

Hello, i am trying to use sv_inverse_gamma as prior for sigma^2. When I use specify_priors() function and choose scale parameter to be smaller than 2, it types: "Error in sv_stop(what = x, name = name, should = paste("be greater than", : scale of sv_invgamma = c(1.5) should be greater than c(2); not smaller or equal"

I believe this is a mistake and only shape should be restricted to >2 to ensure existence of 2nd moment. Scale paramater should be restricted to >0, not >2. I hope I am correct about this, if not please ignore this message. Thank you very much,

A.Slavik

hdarjus commented 1 year ago

Hi @alexslavco,

thanks for the bug report. I agree with you and I am working on the bugfix. Any fix will not make it to CRAN in the coming days; submission takes some time. In the meantime, you can circumvent validation using the following code snippet as a starting point:

sv_inverse_gamma <- function (shape, scale) {
    structure(list(shape = shape, scale = scale),
              class = c("sv_inverse_gamma", "sv_distribution"))
}

prior_spec <- specify_priors(sigma2 = sv_inverse_gamma(3, 1.5))

svsample(rnorm(100), priorspec = prior_spec)

Best, Darjus

hdarjus commented 1 year ago

https://github.com/gregorkastner/stochvol/pull/22