diff --git a/.Rbuildignore b/.Rbuildignore index bf9fc79..dc86975 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -8,3 +8,4 @@ ^setup\.R$ ^cran-comments\.md$ +^README\.md$ diff --git a/NEWS.md b/NEWS.md index b782483..f60619c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,40 +1,58 @@ +# v0.2.0, CRAN Update 2 / JSS Revision 1 + +- Extend methods further + - Add `summary()` methods for `bvar`, `bvar_irf` and `bvar_fcast` + - Add `as.mcmc` method to interface with *coda* + - Support hyperparameters and coefficients in `plot.bvar()` and `density()` + - Add `companion()` method to retrieve the companion matrix + - Improve `ylim` of `plot.bvar()` density plots with multiple chains + - Add `logLik()` method for `bvar` objects +- Fix `bv_psi()` errors for modes other than "auto" +- Change `fcast` and `irf` defaults of `bvar()` to `NULL` +- Move from *MASS* to *mvtnorm* for `dmvnorm()` (used in `logLik()`) +- Be more specific in error messages +- Add *coda* to suggestions for convergence assessment etc. +- Add files *LICENSE*, *CITATION* and *NEWS.md* +- Improve examples for further test coverage + - `R CMD check --run-donttest`: One warning (deprecated functions) + + # v0.1.6, Internal Release 1 -- Prepare for first minor release +- Prepare for minor release 0.2.0 - Provide several standard methods for objects generated with *BVAR* - - `predict()` for ex-post forecasts and generating quantiles - - `irf()` / `fevd()` for ex-post irfs, fevds and generating quantiles + - `predict()` for ex-post forecasts and updating quantiles + - `irf()` / `fevd()` for ex-post irfs, fevds and updating quantiles - `fitted()`, `residuals()`, `coef()` and `vcov()` - `density()` as shorthand for calling `density()` on hyperparameters -- Added `print()` methods for intermediate objects +- Add `print()` methods for intermediate objects - Includes `bv_minnesota`, `bv_metropolis` and method outputs -- Reworked plotting +- Rework plotting - `plot.bvar()` now supports types, subsets and multiple chains - - `bv_plot_trace()` and `bv_plot_density()` are now deprecated - - `density()` offers a plot method - - Both can be replaced by `plot.bvar()`, incl. plotting of multiple chains - - Plots of `bvar_fcast` and `bvar_irf` have been changed - - The preferred way of calling is now: `plot(x$irf)` or `plot(irf(x))` - - The previous `bv_plot_irf(x)` is now deprecated - - Confidence bands are now set in `predict()` / `irf()` instead - - Added plot methods for `bvar_resid` and `bvar_density` -- Added `sign_lim` to set maximum number of sign restriction draws -- Prior construction has been standardised further - - `alpha`, `lambda` and dummy-priors are quite alike, `psi` has been aligned + - Deprecate `bv_plot_trace()` and `bv_plot_density()` + - Add `density()`, including a plot method + - Replace by `plot.bvar()`, incl. plotting of multiple chains + - Change plotting of `bvar_fcast` and `bvar_irf` + - Deprecate `bv_plot_irf(x)` for `plot(x$irf)` or `plot(irf(x))` + - Move `conf_bands` argument to `predict()` / `irf()` + - Add plot methods for `bvar_resid` and `bvar_density` +- Add `sign_lim` to `bv_irf()` to set maximum number of sign restriction draws +- Standardise prior construction further + - Align `alpha` and `lambda`, improve `psi` alignment - `bv_mn()` may be called with a numeric vector for `alpha` and/or `lambda` -- Documentation has been improved - - Related functions are now documented in joint - - Details on priors have been added -- Added less concise aliases for `bv_mh()` and `bv_mn()` +- Improve documentation + - Document related functions in joint + - Add details on priors +- Add less concise aliases for `bv_mh()` and `bv_mn()` - `bv_metropolis()` and `bv_minnesota()` -- Fixed bugs related to single confidence bands at 0.5 -- Saved `fred_qd` with format version 2, lowering R dependency to (>= 3.3.0) -- Added *vars* to suggests for shared methods, import is bypassed +- Fix bugs related to single confidence bands at 0.5 +- Save `fred_qd` with format version 2, lowering R dependency to (>= 3.3.0) +- Add *vars* to suggests for shared methods, import is bypassed # v0.1.5, CRAN Update 1 -- Tried to clarify licensing terms with the Federal Reserve +- Try to clarify licensing terms with the Federal Reserve - Some copyrighted series may have to be removed - Subset the dataset to only include variables in public domain for now @@ -53,15 +71,15 @@ # v0.1.3, CRAN Submission 2 -- Updated DESCRIPTION with linked DOI +- Update DESCRIPTION with linked DOI - Change `\dontrun{}` examples to `\donttest{}` - Improve examples for plotting and printing -- Small fix to bounds in `plot_hyper()` -- R CMD check --as-cran: No errors or warnings, one note (New submission) +- Fix bounds in `plot_hyper()` +- `R CMD check --as-cran`: No errors or warnings, one note (New submission) # v0.1.3, CRAN Submission 1 -- Updated references with links via DOI -- Added examples to `print` and `plot` methods -- R CMD check --as-cran: No errors or warnings, one note (New submission) +- Update references with links via DOI +- Add examples to `print` and `plot` methods +- `R CMD check --as-cran`: No errors or warnings, one note (New submission) diff --git a/R/58_fcast_plot.R b/R/58_fcast_plot.R index 4416f35..173d614 100644 --- a/R/58_fcast_plot.R +++ b/R/58_fcast_plot.R @@ -29,7 +29,7 @@ #' @examples #' \donttest{ #' data <- matrix(rnorm(400), ncol = 4) -#' x <- bvar(data, lags = 2) +#' x <- bvar(data, lags = 2, fcast = bv_fcast()) #' #' # Plot forecasts for all available variables #' plot(predict(x)) diff --git a/R/91_plot.R b/R/91_plot.R index 4e74b84..412429b 100644 --- a/R/91_plot.R +++ b/R/91_plot.R @@ -22,7 +22,8 @@ #' @param mar Numeric vector. Margins for \code{\link[graphics]{par}}. #' @param ... Other graphical parameters for \code{\link[graphics]{par}}. #' -#' @seealso \code{\link{plot.bvar_fcast}}; \code{\link{plot.bvar_irf}}. +#' @seealso \code{\link{bvar}}; \code{\link{plot.bvar_fcast}}; +#' \code{\link{plot.bvar_irf}}. #' #' @keywords VAR BVAR trace density convergence plot #' diff --git a/R/95_fitted.R b/R/95_fitted.R index 85f75a5..1092dfa 100644 --- a/R/95_fitted.R +++ b/R/95_fitted.R @@ -99,7 +99,7 @@ plot.bvar_resid <- function(x, vars = NULL, mar = c(2, 2, 2, 0.5), ...) { op <- par(mfrow = c(length(pos), 1), mar = mar, ...) for(i in pos) { - plot(x[, i], main = paste0("Residuals Variable #", i)) + plot(x[, i], main = paste0("Variable #", i, "Residuals")) abline(h = 0, lty = "dashed", col = "gray") } par(op) diff --git a/cran-comments.md b/cran-comments.md index e154cb0..f60619c 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,45 +1,58 @@ # v0.2.0, CRAN Update 2 / JSS Revision 1 -*Under Construction* +- Extend methods further + - Add `summary()` methods for `bvar`, `bvar_irf` and `bvar_fcast` + - Add `as.mcmc` method to interface with *coda* + - Support hyperparameters and coefficients in `plot.bvar()` and `density()` + - Add `companion()` method to retrieve the companion matrix + - Improve `ylim` of `plot.bvar()` density plots with multiple chains + - Add `logLik()` method for `bvar` objects +- Fix `bv_psi()` errors for modes other than "auto" +- Change `fcast` and `irf` defaults of `bvar()` to `NULL` +- Move from *MASS* to *mvtnorm* for `dmvnorm()` (used in `logLik()`) +- Be more specific in error messages +- Add *coda* to suggestions for convergence assessment etc. +- Add files *LICENSE*, *CITATION* and *NEWS.md* +- Improve examples for further test coverage + - `R CMD check --run-donttest`: One warning (deprecated functions) # v0.1.6, Internal Release 1 -- Prepare for first minor release +- Prepare for minor release 0.2.0 - Provide several standard methods for objects generated with *BVAR* - - `predict()` for ex-post forecasts and generating quantiles - - `irf()` / `fevd()` for ex-post irfs, fevds and generating quantiles + - `predict()` for ex-post forecasts and updating quantiles + - `irf()` / `fevd()` for ex-post irfs, fevds and updating quantiles - `fitted()`, `residuals()`, `coef()` and `vcov()` - `density()` as shorthand for calling `density()` on hyperparameters -- Added `print()` methods for intermediate objects +- Add `print()` methods for intermediate objects - Includes `bv_minnesota`, `bv_metropolis` and method outputs -- Reworked plotting +- Rework plotting - `plot.bvar()` now supports types, subsets and multiple chains - - `bv_plot_trace()` and `bv_plot_density()` are now deprecated - - `density()` offers a plot method - - Both can be replaced by `plot.bvar()`, incl. plotting of multiple chains - - Plots of `bvar_fcast` and `bvar_irf` have been changed - - The preferred way of calling is now: `plot(x$irf)` or `plot(irf(x))` - - The previous `bv_plot_irf(x)` is now deprecated - - Confidence bands are now set in `predict()` / `irf()` instead - - Added plot methods for `bvar_resid` and `bvar_density` -- Added `sign_lim` to set maximum number of sign restriction draws -- Prior construction has been standardised further - - `alpha`, `lambda` and dummy-priors are quite alike, `psi` has been aligned + - Deprecate `bv_plot_trace()` and `bv_plot_density()` + - Add `density()`, including a plot method + - Replace by `plot.bvar()`, incl. plotting of multiple chains + - Change plotting of `bvar_fcast` and `bvar_irf` + - Deprecate `bv_plot_irf(x)` for `plot(x$irf)` or `plot(irf(x))` + - Move `conf_bands` argument to `predict()` / `irf()` + - Add plot methods for `bvar_resid` and `bvar_density` +- Add `sign_lim` to `bv_irf()` to set maximum number of sign restriction draws +- Standardise prior construction further + - Align `alpha` and `lambda`, improve `psi` alignment - `bv_mn()` may be called with a numeric vector for `alpha` and/or `lambda` -- Documentation has been improved - - Related functions are now documented in joint - - Details on priors have been added -- Added less concise aliases for `bv_mh()` and `bv_mn()` +- Improve documentation + - Document related functions in joint + - Add details on priors +- Add less concise aliases for `bv_mh()` and `bv_mn()` - `bv_metropolis()` and `bv_minnesota()` -- Fixed bugs related to single confidence bands at 0.5 -- Saved `fred_qd` with format version 2, lowering R dependency to (>= 3.3.0) -- Added *vars* to suggests for shared methods, import is bypassed +- Fix bugs related to single confidence bands at 0.5 +- Save `fred_qd` with format version 2, lowering R dependency to (>= 3.3.0) +- Add *vars* to suggests for shared methods, import is bypassed # v0.1.5, CRAN Update 1 -- Tried to clarify licensing terms with the Federal Reserve +- Try to clarify licensing terms with the Federal Reserve - Some copyrighted series may have to be removed - Subset the dataset to only include variables in public domain for now @@ -58,15 +71,15 @@ # v0.1.3, CRAN Submission 2 -- Updated DESCRIPTION with linked DOI +- Update DESCRIPTION with linked DOI - Change `\dontrun{}` examples to `\donttest{}` - Improve examples for plotting and printing -- Small fix to bounds in `plot_hyper()` -- R CMD check --as-cran: No errors or warnings, one note (New submission) +- Fix bounds in `plot_hyper()` +- `R CMD check --as-cran`: No errors or warnings, one note (New submission) # v0.1.3, CRAN Submission 1 -- Updated references with links via DOI -- Added examples to `print` and `plot` methods -- R CMD check --as-cran: No errors or warnings, one note (New submission) +- Update references with links via DOI +- Add examples to `print` and `plot` methods +- `R CMD check --as-cran`: No errors or warnings, one note (New submission) diff --git a/man/plot.bvar.Rd b/man/plot.bvar.Rd index d9f045d..3f06aa4 100644 --- a/man/plot.bvar.Rd +++ b/man/plot.bvar.Rd @@ -44,7 +44,7 @@ using the \emph{chains} argument. \examples{ \donttest{ data <- matrix(rnorm(200), ncol = 2) -x <- bvar(data, lags = 2) +x <- bvar(data, lags = 2, irf = bv_irf(), fcast = bv_fcast()) y <- bvar(data, lags = 2) # Plot full traces and densities @@ -62,7 +62,8 @@ plot(x, "fcast", vars = 2) } } \seealso{ -\code{\link{plot.bvar_fcast}}; \code{\link{plot.bvar_irf}}. +\code{\link{bvar}}; \code{\link{plot.bvar_fcast}}; +\code{\link{plot.bvar_irf}}. } \keyword{BVAR} \keyword{VAR} diff --git a/man/plot.bvar_fcast.Rd b/man/plot.bvar_fcast.Rd index b40633e..9927c01 100644 --- a/man/plot.bvar_fcast.Rd +++ b/man/plot.bvar_fcast.Rd @@ -45,7 +45,7 @@ variables can be plotted. \examples{ \donttest{ data <- matrix(rnorm(400), ncol = 4) -x <- bvar(data, lags = 2) +x <- bvar(data, lags = 2, fcast = bv_fcast()) # Plot forecasts for all available variables plot(predict(x)) diff --git a/scripts/replication_script.R b/scripts/replication_script.R index fb8aa03..15b8455 100644 --- a/scripts/replication_script.R +++ b/scripts/replication_script.R @@ -72,11 +72,6 @@ priors <- bv_priors(hyper = "auto", mn = mn, soc = soc, sur = sur) irfs <- bv_irf(horizon = 12, fevd = TRUE, identification = TRUE) -# Turning off forecasts - -fcasts <- NULL - - # Adjust the MH-step mh <- bv_metropolis(scale_hess = 0.005, adjust_acc = TRUE, @@ -86,7 +81,7 @@ mh <- bv_metropolis(scale_hess = 0.005, adjust_acc = TRUE, # Execute the model ------------------------------------------------------- run <- bvar(df, lags = 5, n_draw = 25000, n_burn = 10000, n_thin = 1, - priors = priors, mh = mh, fcast = fcasts, irf = irfs, verbose = TRUE) + priors = priors, mh = mh, fcast = NULL, irf = irfs, verbose = TRUE) # Assessing results @@ -108,7 +103,7 @@ dev.off() # IRF plots pdf("../plots_irf.pdf", width = 10, height = 8) -plot(run$irf, vars_impulse = c("GDPC1", "FEDFUNDS"), +plot(irf(run), vars_impulse = c("GDPC1", "FEDFUNDS"), vars_response = c(1:5)) dev.off() @@ -173,10 +168,10 @@ run_signs <- bvar(df_small, lags = 5, n_draw = 25000, n_burn = 10000, priors = priors, mh = mh, fcast = fcasts, irf = irf_signs) print(run_signs) -print(run_signs$irf) +print(irf(run_signs)) pdf("../irf_signs.pdf", width = 10, height = 10) -plot(run_signs$irf) +plot(irf(run_signs)) dev.off() @@ -198,10 +193,8 @@ runs <- parLapply(cl, list(df, df, df), stopCluster(cl) -plot(run, type = "full", vars = "lambda", chains = runs) - -pdf("../lambda_multiple.pdf", width = 10, height = 4) +pdf("../plots_lambda_multiple.pdf", width = 10, height = 4) plot(run, type = "full", vars = "lambda", chains = runs) dev.off()