continuous_ss_sdf {BayesianFactorZoo} | R Documentation |
SDF model selection with continuous spike-and-slab prior
Description
This function provides the SDF model selection procedure using the continuous spike-and-slab prior. See Propositions 3 and 4 in Bryzgalova et al. (2023).
Usage
continuous_ss_sdf(
f,
R,
sim_length,
psi0 = 1,
r = 0.001,
aw = 1,
bw = 1,
type = "OLS"
)
Arguments
f |
A matrix of factors with dimension |
R |
A matrix of test assets with dimension |
sim_length |
The length of monte-carlo simulations; |
psi0 |
The hyper-parameter in the prior distribution of risk prices (see Details); |
r |
The hyper-parameter related to the prior of risk prices (see Details); |
aw |
The hyper-parameter related to the prior of |
bw |
The hyper-parameter related to the prior of |
type |
If |
Details
To model the variable selection procedure, we introduce a vector of binary latent variables ,
where
. When
, factor
(with associated loadings
) should be included
in the model and vice verse.
The continuous spike-and-slab prior of risk prices is
When the factor is included, we have
.
When the factor is excluded from the model,
.
Hence, the Dirac "spike" is replaced by a Gaussian spike, which is extremely concentrated at zero
(the default value for
is 0.001).
We choose
,
where
is the cross-sectionally demeaned vector of factor
's correlations with asset returns.
In the codes,
is equal to the value of
psi0
.
The prior encoded the belief about the sparsity of the true model using the prior distribution
. Following the literature on the variable selection, we set
Different hyperparameters and
determine whether one a priori favors more parsimonious models or not.
We choose
(
aw
) and (
bw
) as the default values.
For each posterior draw of factors' risk prices , we can define the SDF as
.The Bayesian model averaging of the SDF (BMA-SDF)
over
draws is
Value
The return of continuous_ss_sdf
is a list of the following elements:
-
gamma_path
: Asim_length
matrix of the posterior draws of
. Each row represents a draw. If
in one draw, factor
is included in the model in this draw and vice verse.
-
lambda_path
: Asim_length
matrix of the risk prices
. Each row represents a draw. Note that the first column is
corresponding to the constant term. The next
columns (i.e., the 2-th –
-th columns) are the risk prices of the
factors.
-
sdf_path
: Asim_length
matrix of posterior draws of SDFs. Each row represents a draw.
-
bma_sdf
: BMA-SDF.
References
Bryzgalova S, Huang J, Julliard C (2023). “Bayesian solutions for the factor zoo: We just ran two quadrillion models <https://doi.org/10.1111/jofi.13197>.” Journal of Finance, 78(1), 487–557.
Examples
## Load the example data
data("BFactor_zoo_example")
HML <- BFactor_zoo_example$HML
lambda_ols <- BFactor_zoo_example$lambda_ols
R2.ols.true <- BFactor_zoo_example$R2.ols.true
sim_f <- BFactor_zoo_example$sim_f
sim_R <- BFactor_zoo_example$sim_R
uf <- BFactor_zoo_example$uf
## sim_f: simulated strong factor
## uf: simulated useless factor
psi_hat <- psi_to_priorSR(sim_R, cbind(sim_f,uf), priorSR=0.1)
shrinkage <- continuous_ss_sdf(cbind(sim_f,uf), sim_R, 5000, psi0=psi_hat, r=0.001, aw=1, bw=1)
cat("Null hypothesis: lambda =", 0, "for each factor", "\n")
cat("Posterior probabilities of rejecting the above null hypotheses are:",
colMeans(shrinkage$gamma_path), "\n")
## We also have the posterior draws of SDF: m(t) = 1 - lambda_g %*% (f(t) - mu_f)
sdf_path <- shrinkage$sdf_path
## We also provide the Bayesian model averaging of the SDF (BMA-SDF)
bma_sdf <- shrinkage$bma_sdf