-
Notifications
You must be signed in to change notification settings - Fork 1
/
print-bvarmn.R
69 lines (68 loc) · 1.88 KB
/
print-bvarmn.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#' @rdname bvar_minnesota
#' @param x `bvarmn` object
#' @param digits digit option to print
#' @param ... not used
#' @order 2
#' @export
print.bvarmn <- function(x, digits = max(3L, getOption("digits") - 3L), ...) {
cat(
"Call:\n",
paste(deparse(x$call), sep="\n", collapse = "\n"), "\n\n", sep = ""
)
# split the matrix for the print: B1, ..., Bp
bhat_mat <- split_coef(x)
cat(sprintf("BVAR(%i) with Minnesota Prior\n", x$p))
cat("====================================================\n\n")
cat("A ~ Matrix Normal (Mean, Precision, Scale = Sigma)\n")
cat("====================================================\n")
for (i in 1:(x$p)) {
cat(sprintf("Matrix Normal Mean for A%i part:\n", i))
# B1, ..., Bp--------------------
print.default(
bhat_mat[[i]],
digits = digits,
print.gap = 2L,
quote = FALSE
)
cat("\n\n")
}
# const term----------------------
if (x$type == "const") {
intercept <- x$coefficients[x$df,]
cat("Matrix Normal Mean for constant part:\n")
print.default(
intercept,
digits = digits,
print.gap = 2L,
quote = FALSE
)
cat("\n\n")
}
# precision matrix---------------0
cat("dim(Matrix Normal precision matrix):\n")
print.default(
dim(x$mn_prec),
digits = digits,
print.gap = 2L,
quote = FALSE
)
cat("\n\nSigma ~ Inverse-Wishart\n")
cat("====================================================\n")
cat("IW scale matrix:\n")
print.default(
x$iw_scale,
digits = digits,
print.gap = 2L,
quote = FALSE
)
cat("\nIW degrees of freedom:\n")
print.default(x$iw_shape)
cat("\n\n--------------------------------------------------\n")
cat("*_j of the Coefficient matrix: corresponding to the j-th BVAR lag\n\n")
invisible(x)
}
#' @rdname bvar_minnesota
#' @exportS3Method knitr::knit_print
knit_print.bvarmn <- function(x, ...) {
print(x)
}