Skip to content

Commit

Permalink
Add comments, tiny changes, work on replic
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolas Kuschnig committed Sep 4, 2019
1 parent b6609dd commit aad9094
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 79 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
^setup\.R$

^cran-comments\.md$
^README\.md$
78 changes: 48 additions & 30 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
2 changes: 1 addition & 1 deletion R/58_fcast_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion R/91_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down
2 changes: 1 addition & 1 deletion R/95_fitted.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
75 changes: 44 additions & 31 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
5 changes: 3 additions & 2 deletions man/plot.bvar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/plot.bvar_fcast.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 5 additions & 12 deletions scripts/replication_script.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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()


Expand All @@ -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()

Expand Down

0 comments on commit aad9094

Please sign in to comment.