Skip to content

Commit

Permalink
ready for CRAN submission
Browse files Browse the repository at this point in the history
  • Loading branch information
hdarjus committed Jul 12, 2021
1 parent 69caac5 commit f25c2b2
Show file tree
Hide file tree
Showing 20 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ speedtest_sessioninfo.txt
.undodir
pre-commit.sh

.gdbinit

^.*\.Rproj$
^\.Rproj\.user$

Session.vim
dic-example.R
speedtest_output.txt

debug.Rprofile

.lintr
compile_flags.txt

Expand Down
2 changes: 1 addition & 1 deletion .Rinstignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bib$
RData$
predlik
Figures2
jss3813
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Encoding: UTF-8
Package: stochvol
Type: Package
Title: Efficient Bayesian Inference for Stochastic Volatility (SV) Models
Version: 3.0.10
Version: 3.1.0
Authors@R: c(
person("Darjus", "Hosszejni", role = c("aut", "cre"), email = "darjus.hosszejni@wu.ac.at", comment = c(ORCID = "0000-0002-3803-691X")),
person("Gregor", "Kastner", role = c("aut"), email = "gregor.kastner@aau.at", comment = c(ORCID = "0000-0002-8237-8271")))
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# stochvol 3.0.10
# stochvol 3.1.0

- NEW FUNCTION 'svlm', which has a formula interface;
it is a wrapper around 'svsample'; many thanks
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cpp.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("C++")
test_that("Catch unit tests pass", {
skip_on_cran()
expect_cpp_tests_pass("stochvol")
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-samplers.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ test_that("vanilla SV passes Geweke test", {
})

test_that("general SV passes Geweke test", {
skip_on_cran()
skip_on_ci()

set.seed(60)
result <- .Call(`_stochvol_geweke_general_cpp`, PACKAGE = "stochvol")
draws <- result$draws / result$thin
Expand Down Expand Up @@ -106,6 +109,9 @@ test_that("general SV passes Geweke test", {
})

test_that("default fast SV is efficient", {
skip_on_cran()
skip_on_ci()

set.seed(61)
n <- 150L
# Pro-centered
Expand Down Expand Up @@ -147,6 +153,9 @@ test_that("default fast SV is efficient", {
})

test_that("default general SV is efficient", {
skip_on_cran()
skip_on_ci()

set.seed(61)
n <- 150L
# Pro-centered
Expand Down
2 changes: 1 addition & 1 deletion vignettes/.install_extras
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
predlik
bib$
RData$
Figures2/jss3813-.*\.pdf$
jss3813
12 changes: 5 additions & 7 deletions vignettes/article2.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@
\def\svpars{\bm{\vartheta}}
\def\svlpars{\bm{\zeta}}

\graphicspath{{Figures2/}}

\author{Darjus Hosszejni\\[.3em]WU Vienna University\\[-.1em]of Economics and Business
\And Gregor Kastner\\[.3em]University of Klagenfurt}
\Plainauthor{Darjus Hosszejni, Gregor Kastner}
Expand Down Expand Up @@ -180,7 +178,7 @@ knitr::opts_chunk$set(prompt = TRUE,
message = FALSE,
echo = FALSE,
#cache = TRUE,
fig.path = "Figures2/jss3813-",
fig.path = "jss3813-",
tidy = FALSE)
base::options(continue = "+ ", prompt = "R> ", width = 70,
useFancyQuotes = FALSE)
Expand Down Expand Up @@ -926,7 +924,7 @@ Using \fct{covmat}, one can extract the MCMC draws of the implied covariance mat
<<covn, echo = TRUE, eval=FALSE>>=
dim(cov_n <- covmat(res))
@
shows that we have stored $\Sexpr{res$config$draws/res$config$thin}$ posterior draws of a $\Sexpr{m}\times\Sexpr{m}$ covariance matrix at one point in time, $t = n = \Sexpr{n}$. To check convergence, one can take a look at the trace plot and the autocorrelation function of the log determinant, i.e.,
shows that we have stored $300$ posterior draws of a $6\times6$ covariance matrix at one point in time, $t = n = 200$. To check convergence, one can take a look at the trace plot and the autocorrelation function of the log determinant, i.e.,
<<logdetcovn, echo = 2:5, fig.width = 10, fig.height=3.5, results='hide', eval=FALSE>>=
par(mfrow = c(1, 2), mgp = c(1.7, 0.5, 0), mar = c(3, 3, 1, 1))
logdet <- function (x) log(det(x))
Expand All @@ -943,21 +941,21 @@ The results are visualized in Figure~\ref{fig:logdetcovn}; decent mixing for thi
\label{fig:logdetcovn}
\end{figure}

To assess the mixing speed of each individual covariance matrix element, one can check, e.g., the estimated effective sample size (out of $\Sexpr{res$config$draws/res$config$thin}$ draws kept) which is implemented in \pkg{coda}.
To assess the mixing speed of each individual covariance matrix element, one can check, e.g., the estimated effective sample size (out of $300$ draws kept) which is implemented in \pkg{coda}.
Again, no major convergence problems are apparent.
<<covess, echo = TRUE>>=
round(apply(cov_n, 1:2, coda::effectiveSize))
@

Assuming that \code{runningstore} was set sufficiently high when sampling, several convenience functions can be used for quick visualizations without having to post-process the MCMC draws. For example, to visualize the time-varying correlation matrices, consider
<<corimageplot, echo=2, eval=FALSE, results='hide'>>=
<<corimageplot, echo=2:3, eval=FALSE, results='hide'>>=
par(mfrow = c(1, 3), xpd = TRUE)
corimageplot(res, these = seq(1, n, length.out = 3), plotCI = "circle",
plotdatedist = 2, date.cex = 1.1)
@
\begin{figure}[tp]
\centering
\includegraphics[width=\textwidth, clip, trim=22 185 0 174]{jss3813-corimageplot-1}
\includegraphics[width=\textwidth, clip, trim=0 167 0 159]{jss3813-corimageplot-1}
\caption{Three estimated correlation matrices and their posterior uncertainty depicted using circles.
Inner (outer) radii of the circles illustrate to the posterior mean minus (plus) two standard deviations.
Colors blue and red represent negative and positive values, respectively.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f25c2b2

Please sign in to comment.