fsvsample | R Documentation |
fsvsample
simulates from the joint posterior distribution and returns
the MCMC draws. It is the main workhorse to conduct inference for factor
stochastic volatility models in this package.
fsvsample(
y,
factors = 1,
draws = 1000,
thin = 1,
burnin = 1000,
restrict = "none",
zeromean = TRUE,
priorfacloadtype = "rowwiseng",
priorfacload = 0.1,
facloadtol = 1e-18,
priorng = c(1, 1),
priormu = c(0, 10),
priorphiidi = c(10, 3),
priorphifac = c(10, 3),
priorsigmaidi = 1,
priorsigmafac = 1,
priorh0idi = "stationary",
priorh0fac = "stationary",
priorbeta = c(0, 10000),
keeptime = "last",
heteroskedastic = TRUE,
priorhomoskedastic = NA,
runningstore = 6,
runningstorethin = 10,
runningstoremoments = 2,
signident = TRUE,
signswitch = FALSE,
interweaving = 4,
quiet = FALSE,
samplefac = TRUE,
startfac,
startpara,
startlogvar,
startlatent,
startlogvar0,
startlatent0,
startfacload,
startfacloadvar,
expert
)
y |
Data matrix. Each of |
factors |
Number of latent factors to be estimated. |
draws |
Number of MCMC draws kept after burn-in. |
thin |
Single number greater or equal to 1, coercible to integer.
Every |
burnin |
Number of initial MCMC draws to be discarded. |
restrict |
Either "upper", "none", or "auto", indicating whether
the factor loadings
matrix should be restricted to have zeros above the diagonal ("upper"),
whether all elements should be estimated from the data ("none"), or
whether the function |
zeromean |
Logical. If |
priorfacloadtype |
Can be
For details please see Kastner (2019). |
priorfacload |
Either a matrix of dimensions |
facloadtol |
Minimum number that the absolute value of a factor loadings draw can take. Prevents numerical issues that can appear when strong shrinkage is enforced if chosen to be greater than zero. |
priorng |
Two-element vector with positive entries indicating the Normal-Gamma
prior's hyperhyperparameters |
priormu |
Vector of length 2 denoting prior mean and standard deviation for unconditional levels of the idiosyncratic log variance processes. |
priorphiidi |
Vector of length 2, indicating the shape parameters for the
Beta prior distributions of the transformed parameters |
priorphifac |
Vector of length 2, indicating the shape parameters for the
Beta prior distributions of the transformed parameters |
priorsigmaidi |
Vector of length |
priorsigmafac |
Vector of length |
priorh0idi |
Vector of length 1 or |
priorh0fac |
Vector of length 1 or |
priorbeta |
numeric vector of length 2, indicating the mean and
standard deviation of the Gaussian prior for the regression parameters. The
default value is |
keeptime |
Either a number coercible to a positive integer, or a string
equal to "all" or "last". If a number different from 1 is provided, only every
|
heteroskedastic |
Vector of length 1, 2, or |
priorhomoskedastic |
Only used if at least one element of
|
runningstore |
Because most machines these days do not have enough memory
to store all draws for all points in time, setting
|
runningstorethin |
How often should the calculation of running moments be conducted? Set to a value > 1 if you want to avoid time consuming calculations at every MCMC iteration. |
runningstoremoments |
Selects how many running moments (up to 4) should be calculated. |
signident |
If set to |
signswitch |
Set to |
interweaving |
The following values for interweaving the factor loadings are accepted:
For details please see Kastner et al. (2017). A value of 4 is the highly recommended default. |
quiet |
Logical value indicating whether the progress bar and other
informative output during sampling should be omitted. The default
value is |
samplefac |
If set to |
startfac |
optional numeric matrix of dimension
|
startpara |
optional numeric matrix of dimension
|
startlogvar |
optional numeric matrix of dimension
|
startlatent |
Deprecated. Please use |
startlogvar0 |
optional numeric vector of length
|
startlatent0 |
Deprecated. Please use |
startfacload |
optional numeric matrix of dimension
|
startfacloadvar |
optional numeric matrix of dimension
|
expert |
optional named list of expert parameters for the
univariate SV models (will be transformed and passed to the
|
For details concerning the factor SV algorithm please see Kastner et al. (2017), details about the univariate SV estimation can be found in Kastner and Frühwirth-Schnatter (2014).
The value returned is a list object of class fsvdraws
holding
facload
: Array containing draws from the posterior distribution of the factor loadings matrix.
fac
: Array containing factor draws from the posterior distribution.
logvar
: Array containing idiosyncratic and factor initial log variance draws.
logvar0
: Array containing idiosyncratic and factor log variance draws.
para
: Array containing parameter draws form the posterior distribution.
y
: Matrix containing the data supplied.
latestauxiliary
: List containing the latest draws of auxiliary quantities used for sampling the factor loadings matrix.
runningstore
: List whose elements contain ergodic moments of certain
variables of interest. See argument
runningstore
for details about what
is being stored here.
config
: List containing information on configuration parameters.
priors
: List containing prior hyperparameter values.
identifier
: Matrix containing the indices of the series used for
ex-post sign-identification along with the corresponding minimum distances to zero.
See signident
for details.
To display the output, use print
, plot
, and in particular specialized
extractors and printing functions.
The print
method prints a high-level overview; specialized extractors such as
covmat
or runningcovmat
are also available.
The plot
method invokes a simple covariance matrix plot; specialized plotting
functions are linked in the documentation of plot.fsvdraws
.
Kastner, G., Frühwirth-Schnatter, S., and Lopes, H.F. (2017). Efficient Bayesian Inference for Multivariate Factor Stochastic Volatility Models. Journal of Computational and Graphical Statistics, 26(4), 905–917, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10618600.2017.1322091")}.
Kastner, G. (2019). Sparse Bayesian Time-Varying Covariance Estimation in Many Dimensions Journal of Econometrics, 210(1), 98–115, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jeconom.2018.11.007")}
Kastner, G. (2016). Dealing with stochastic volatility in time series using the R package stochvol. Journal of Statistical Software, 69(5), 1–30, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v069.i05")}.
Kastner, G. and Frühwirth-Schnatter, S. (2014). Ancillarity-Sufficiency Interweaving Strategy (ASIS) for Boosting MCMC Estimation of Stochastic Volatility Models. Computational Statistics & Data Analysis, 76, 408–423, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.csda.2013.01.002")}.
# Load exchange rate data (ships with stochvol):
data(exrates, package = "stochvol")
exrates$date <- NULL
# Compute the percentage log returns:
dat <- 100 * logret(exrates)
# We are going to fit a one-factor model so the ordering is irrelevant
# NOTE that these are very few draws, you probably want more...
res <- fsvsample(dat, factors = 2, draws = 2000, burnin = 1000,
runningstore = 6, zeromean = FALSE)
voltimeplot(res)
corimageplot(res, nrow(dat), plotCI = 'circle')
oldpar <- par(ask = TRUE)
plot(res)
par(oldpar)
pairs(t(res$beta[1:4, ]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.