Learn R Programming

factorstochvol (version 1.1.0)

cormat.fsvdraws: Extract posterior draws of the model-implied correlation matrix

Description

cormat extracts draws from the model-implied correlation matrix from an fsvdraws object for all points in time which have been stored.

Usage

# S3 method for fsvdraws
cormat(x, timepoints = "all", ...)

Value

Array of dimension m times m times draws

times timepoints containing the posterior draws for the model-implied covariance matrix.

Arguments

x

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

timepoints

Vector indicating at which point(s) in time (of those that have been stored during sampling) the correlation matrices should be extracted. Can also be "all" or "last".

...

Ignored.

See Also

Other extractors: covmat.fsvdraws(), runningcormat(), runningcovmat()

Examples

Run this code
# \donttest{
set.seed(1)
sim <- fsvsim(n = 500, series = 3, factors = 1) # simulate
res <- fsvsample(sim$y, factors = 1, keeptime = "all") # estimate
cors <- cormat(res, "last") # extract

# Trace plot of determinant of posterior correlation matrix
# at time t = n = 500:
detdraws <- apply(cors[,,,1], 3, det)
ts.plot(detdraws)
abline(h = mean(detdraws), col = 2)          # posterior mean
abline(h = median(detdraws), col = 4)        # posterior median
abline(h = det(cormat(sim, "last")[,,1]), col = 3) # implied by DGP

# Trace plot of draws from posterior correlation of Sim1 and Sim2 at
# time t = n = 500:
ts.plot(cors[1,2,,1])
abline(h = cormat(sim, "last")[1,2,1], col = 3) # "true" value

# Smoothed kernel density estimate:
plot(density(cors[1,2,,1], adjust = 2))

# Summary statistics:
summary(cors[1,2,,1])
# }

Run the code above in your browser using DataLab