runningcovmat: Extract summary statistics for the posterior covariance...

Description Usage Arguments Value See Also Examples

View source: R/utilities_fsvdraws.R

Description

runningcovmat extracts summary statistics from the model-implied covariance matrix from an fsvdraws object for one point in time.

Usage

1
runningcovmat(x, i, statistic = "mean", type = "cov")

Arguments

x

Object of class 'fsvdraws', usually resulting from a call of fsvsample.

i

A single point in time.

statistic

Indicates which statistic should be extracted. Defaults to 'mean'.

type

Indicates whether covariance (cov) or correlation (cor) should be extracted.

Value

Matrix containing the requested covariance matrix summary statistic.

See Also

Other extractors: cormat.fsvdraws, covmat.fsvdraws, runningcormat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
set.seed(1)
sim <- fsvsim(n = 500, series = 3, factors = 1) # simulate 
res <- fsvsample(sim$y, factors = 1) # estimate

cov100mean <- runningcovmat(res, 100) # extract mean at t = 100
cov100sd <- runningcovmat(res, 100, statistic = "sd") # extract sd
lower <- cov100mean - 2*cov100sd
upper <- cov100mean + 2*cov100sd

true <- covmat(sim, 100) # true value

# Visualize mean +/- 2sd and data generating values
par(mfrow = c(3,3), mar = c(2, 2, 2, 2))
for (i in 1:3) {
 for (j in 1:3) {
  plot(cov100mean[i,j], ylim = range(lower, upper), pch = 3,
  main = paste(i, j, sep = ' vs. '), xlab = '', ylab = '')
  lines(c(1,1), c(lower[i,j], upper[i,j]))
  points(true[i,j,1], col = 3, cex = 2)
 }
}

factorstochvol documentation built on Oct. 6, 2019, 5:06 p.m.