| Title: | Statistical Methods for Quantitative Finance |
|---|---|
| Description: | Provides data and functions used in the book "Statistical Methods for Quantitative Finance" by David Ardia (2026). |
| Authors: | David Ardia [aut, cre] (ORCID: <https://orcid.org/0000-0003-2823-782X>), Marius Hofert [ctb, cph] (Original author of qrmdata, from which 15 market datasets were ported under GPL-2 | GPL-3), Kurt Hornik [ctb, cph] (Original author of qrmdata, from which 15 market datasets were ported under GPL-2 | GPL-3), Alexander J. McNeil [ctb, cph] (Original author of qrmdata, from which 15 market datasets were ported under GPL-2 | GPL-3) |
| Maintainer: | David Ardia <[email protected]> |
| License: | GPL-3 |
| Version: | 1.1-3 |
| Built: | 2026-06-02 13:05:53 UTC |
| Source: | https://github.com/ardiad/smqf-package |
Daily adjusted close prices of the Cotation Assistée en Continu (CAC 40)
stock index (ticker symbol ^FCHI), from its first date of
availability on Yahoo Finance to 2015-12-31.
data("CAC")data("CAC")
An xts object with 6549 daily observations and a single
column ^FCHI containing adjusted close prices in index points.
The time index spans from 1990-03-01 to 2015-12-31.
Originally distributed as CAC in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as
qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("CAC") class(CAC) # "xts" "zoo" dim(CAC) head(CAC)data("CAC") class(CAC) # "xts" "zoo" dim(CAC) head(CAC)
Daily adjusted close prices of the Deutscher Aktienindex (DAX) stock
index (ticker symbol ^GDAXI), from its first date of
availability on Yahoo Finance to 2015-12-30.
data("DAX")data("DAX")
An xts object with 6355 daily observations and a single
column ^GDAXI containing adjusted close prices in index points.
The time index spans from 1990-11-26 to 2015-12-30.
Originally distributed as DAX in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("DAX") class(DAX) # "xts" "zoo" dim(DAX) head(DAX)data("DAX") class(DAX) # "xts" "zoo" dim(DAX) head(DAX)
Daily adjusted close prices of the Dow Jones Industrial Average
(ticker symbol ^DJI), from its first date of availability on
Yahoo Finance to 2015-12-31.
data("DJ")data("DJ")
An xts object with 7797 daily observations and a single
column ^DJI containing adjusted close prices in index points.
The time index spans from 1985-01-29 to 2015-12-31.
Originally distributed as DJ in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("DJ") class(DJ) # "xts" "zoo" dim(DJ) head(DJ)data("DJ") class(DJ) # "xts" "zoo" dim(DJ) head(DJ)
Daily adjusted close prices for the 30 constituents of the Dow Jones Industrial Average as of 2016-01-03.
data("DJ_const")data("DJ_const")
An xts object with 13595 daily observations and 30
columns, one per constituent (e.g., AAPL, IBM,
JPM, XOM). Missing values appear before the first date
at which a given constituent was available. The time index spans
from 1962-01-02 to 2015-12-31.
Originally distributed as DJ_const in the qrmdata
package (Hofert, Hornik, & McNeil), ported into smqf so that
the book's examples remain reproducible without an extra dependency. The
data is redistributed here under the same GPL () license as
qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("DJ_const") class(DJ_const) # "xts" "zoo" dim(DJ_const) head(colnames(DJ_const))data("DJ_const") class(DJ_const) # "xts" "zoo" dim(DJ_const) head(colnames(DJ_const))
Daily adjusted close prices of the Euro Stoxx 50 stock index
(ticker symbol ^STOXX50E), from its first date of availability
on Yahoo Finance to 2015-12-23.
data("EURSTOXX")data("EURSTOXX")
An xts object with 7445 daily observations and a single
column ^STOXX50E containing adjusted close prices in index
points. The time index spans from 1986-12-31 to 2015-12-23.
Originally distributed as EURSTOXX in the qrmdata
package (Hofert, Hornik, & McNeil), ported into smqf so that
the book's examples remain reproducible without an extra dependency. The
data is redistributed here under the same GPL () license as
qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("EURSTOXX") class(EURSTOXX) # "xts" "zoo" dim(EURSTOXX) head(EURSTOXX)data("EURSTOXX") class(EURSTOXX) # "xts" "zoo" dim(EURSTOXX) head(EURSTOXX)
Daily adjusted close prices for the 50 constituents of the Euro Stoxx 50 stock index as of 2016-01-03.
data("EURSTX_const")data("EURSTX_const")
An xts object with 4174 daily observations and 50
columns, one per constituent (e.g., SAP.DE, BNP.PA,
SAN.MC). Missing values appear before the first date at which
a given constituent was available. The time index spans from
2000-01-03 to 2015-12-31.
Originally distributed as EURSTX_const in the qrmdata
package (Hofert, Hornik, & McNeil), ported into smqf so that
the book's examples remain reproducible without an extra dependency. The
data is redistributed here under the same GPL () license as
qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("EURSTX_const") class(EURSTX_const) # "xts" "zoo" dim(EURSTX_const) head(colnames(EURSTX_const))data("EURSTX_const") class(EURSTX_const) # "xts" "zoo" dim(EURSTX_const) head(colnames(EURSTX_const))
Computes the value of the bivariate Clayton copula probability density
function (PDF) at a specified point for a given dependence
parameter .
f_clayton_copula_2d_pdf(u, theta)f_clayton_copula_2d_pdf(u, theta)
u |
Numeric vector of length 2, containing values in the interval
|
theta |
Numeric scalar giving the dependence parameter
( |
The Clayton copula is an Archimedean copula with lower-tail dependence
and no upper-tail dependence ().
When , the copula reduces to the independence copula,
whose PDF equals 1 for all .
The PDF is given by:
Numerical computation may lose precision for large (typically
above about 34).
A numeric value corresponding to the Clayton copula PDF evaluated at the specified point.
- Joe, H. (1997). Multivariate Models and Dependence Concepts. Chapman & Hall. - Patton, A. (2006). Modelling Asymmetric Exchange Rate Dependence. International Economic Review, 47(2), 527–556.
f_gumbel_copula_2d_pdf, f_normal_copula_pdf,
f_student_copula_pdf
# Example: Evaluate Clayton copula PDF at (u1, u2) = (0.5, 0.5) f_clayton_copula_2d_pdf(c(0.5, 0.5), theta = 2)# Example: Evaluate Clayton copula PDF at (u1, u2) = (0.5, 0.5) f_clayton_copula_2d_pdf(c(0.5, 0.5), theta = 2)
Evaluates and displays a bivariate copula function (typically a PDF or CDF)
on a 2D grid, producing a static 3D surface via base R's persp().
f_display_copula(my_copula, grid_1, grid_2, plot = TRUE)f_display_copula(my_copula, grid_1, grid_2, plot = TRUE)
my_copula |
A function that takes a numeric vector |
grid_1, grid_2
|
Numeric vectors defining the evaluation grid for
|
plot |
Logical; if |
This function provides a simple way to visualize the surface of a bivariate
copula (e.g., Clayton, Gumbel, Gaussian). The copula function should accept a
vector of two uniform values and return its density or CDF
value.
Invisibly returns the matrix of evaluated copula values
f_U, with rows corresponding to grid_1 and columns to grid_2.
# Example: Display the Clayton copula PDF surface grid <- seq(0.05, 0.95, length.out = 25) f_display_copula( my_copula = function(u) f_clayton_copula_2d_pdf(u, theta = 2), grid_1 = grid, grid_2 = grid )# Example: Display the Clayton copula PDF surface grid <- seq(0.05, 0.95, length.out = 25) f_display_copula( my_copula = function(u) f_clayton_copula_2d_pdf(u, theta = 2), grid_1 = grid, grid_2 = grid )
Solves a sequence of quadratic programs to trace the long-only, fully-invested Markowitz efficient frontier between the minimum-variance portfolio and the maximum-return (corner) portfolio.
f_efficient_frontier(mu, Sigma, n_ptf)f_efficient_frontier(mu, Sigma, n_ptf)
mu |
Numeric vector of length |
Sigma |
Numeric |
n_ptf |
Integer |
Portfolios are obtained by minimizing variance for a grid of target returns
under the constraints and .
Each QP solves
and, for interior points on the frontier, additionally
where spans a linear grid between the min-variance portfolio
return and the single-asset maximum-return portfolio.
Requires pracma for quadprog. Numerical issues can arise if
Sigma is not positive semidefinite or if target returns are infeasible
under the long-only constraint.
A list with components:
Numeric matrix : portfolio weights.
Numeric length-: portfolio standard deviations.
Numeric length-: portfolio expected returns.
Data frame with columns point (integer index),
expected_return, and volatility for each frontier portfolio.
Numeric vector of length : the target-return grid
used to trace the frontier.
Markowitz, H. (1952). Portfolio Selection. Journal of Finance, 7(1), 77–91.
set.seed(1) N <- 4 mu <- c(0.08, 0.10, 0.12, 0.09) M <- matrix(rnorm(N*N), N); Sigma <- crossprod(M) / N # PSD covariance ef <- f_efficient_frontier(mu, Sigma, n_ptf = 20) # Inspect end points ef$expected_returns[c(1, 20)] ef$volatility[c(1, 20)]set.seed(1) N <- 4 mu <- c(0.08, 0.10, 0.12, 0.09) M <- matrix(rnorm(N*N), N); Sigma <- crossprod(M) / N # PSD covariance ef <- f_efficient_frontier(mu, Sigma, n_ptf = 20) # Inspect end points ef$expected_returns[c(1, 20)] ef$volatility[c(1, 20)]
Computes the bivariate Gumbel copula cumulative distribution function (CDF)
at for dependence parameter .
f_gumbel_copula_2d_cdf(u, theta)f_gumbel_copula_2d_cdf(u, theta)
u |
Numeric vector of length 2 with entries in |
theta |
Numeric scalar, the Gumbel dependence parameter |
The Gumbel copula exhibits upper-tail dependence
and no lower-tail dependence
(). When , it reduces to the independence
copula with .
The CDF is
A numeric scalar: .
Joe, H. (1997). Multivariate Models and Dependence Concepts. Chapman & Hall. Nelsen, R. B. (2006). An Introduction to Copulas (2nd ed.). Springer.
f_gumbel_copula_2d_pdf, f_clayton_copula_2d_pdf,
f_normal_copula_pdf, f_student_copula_pdf
f_gumbel_copula_2d_cdf(c(0.5, 0.8), theta = 2) f_gumbel_copula_2d_cdf(c(0.7, 0.7), theta = 1) # independence: ~0.49f_gumbel_copula_2d_cdf(c(0.5, 0.8), theta = 2) f_gumbel_copula_2d_cdf(c(0.7, 0.7), theta = 1) # independence: ~0.49
Computes the bivariate Gumbel copula probability density function (PDF)
at for dependence parameter .
f_gumbel_copula_2d_pdf(u, theta)f_gumbel_copula_2d_pdf(u, theta)
u |
Numeric vector of length 2 with entries in |
theta |
Numeric scalar, the Gumbel dependence parameter |
The PDF can be written as
When , (independence).
A numeric scalar: .
Numerical stability may degrade as (large ).
Joe, H. (1997). Multivariate Models and Dependence Concepts. Chapman & Hall. Nelsen, R. B. (2006). An Introduction to Copulas (2nd ed.). Springer.
f_gumbel_copula_2d_cdf, f_clayton_copula_2d_pdf,
f_normal_copula_pdf, f_student_copula_pdf
f_gumbel_copula_2d_pdf(c(0.5, 0.8), theta = 2) f_gumbel_copula_2d_pdf(c(0.7, 0.7), theta = 1) # independence: 1f_gumbel_copula_2d_pdf(c(0.5, 0.8), theta = 2) f_gumbel_copula_2d_pdf(c(0.7, 0.7), theta = 1) # independence: 1
Computes the probability density function (PDF) of the Gaussian (normal)
copula at a specified point , given mean vector
and covariance matrix of the underlying multivariate
normal distribution.
f_normal_copula_pdf(u, mu, Sigma)f_normal_copula_pdf(u, mu, Sigma)
u |
Numeric vector of length |
mu |
Numeric vector of length |
Sigma |
Numeric positive-definite |
The Gaussian copula density is
where and are multivariate and univariate normal
densities respectively, and denotes the inverse normal CDF
applied componentwise. The resulting function is a valid copula density on
the unit hypercube .
Typically, the copula is defined for and correlation matrix
, but the implementation here generalizes to arbitrary mean and
covariance.
A numeric scalar: the value of the Gaussian copula density
at the point u. The value is returned
as a plain numeric scalar (not a matrix).
Joe, H. (1997). *Multivariate Models and Dependence Concepts.* Chapman & Hall. Nelsen, R. B. (2006). *An Introduction to Copulas* (2nd ed.). Springer. McNeil, A. J., Frey, R., & Embrechts, P. (2015). *Quantitative Risk Management.* Princeton University Press.
f_student_copula_pdf, f_clayton_copula_2d_pdf,
f_gumbel_copula_2d_pdf
# Example: 2D Gaussian copula Sigma <- matrix(c(1, 0.7, 0.7, 1), 2, 2) mu <- c(0, 0) f_normal_copula_pdf(c(0.5, 0.8), mu, Sigma) # Compare with independence (Sigma = I) f_normal_copula_pdf(c(0.5, 0.8), mu, diag(2))# Example: 2D Gaussian copula Sigma <- matrix(c(1, 0.7, 0.7, 1), 2, 2) mu <- c(0, 0) f_normal_copula_pdf(c(0.5, 0.8), mu, Sigma) # Compare with independence (Sigma = I) f_normal_copula_pdf(c(0.5, 0.8), mu, diag(2))
Compute the portfolio's centred 2nd, 3rd and 4th moments (variance, co-skewness, co-kurtosis) from the asset-level co-moment matrices and a weight vector.
f_portfolio_moments(w, M2 = NULL, M3 = NULL, M4 = NULL)f_portfolio_moments(w, M2 = NULL, M3 = NULL, M4 = NULL)
w |
Numeric vector of length |
M2 |
Optional |
M3 |
Optional |
M4 |
Optional |
The three quantities are defined as
where denotes the Kronecker product. These are the
building blocks of the mean-variance-skewness-kurtosis (MVSK)
framework of Jondeau, Poon and Rockinger (2007).
The function is a thin, exported wrapper around the package's
internal helpers .portm2, .portm3, .portm4
(which themselves replace the unexported
PerformanceAnalytics:::portm* family). It exists so the
textbook can demonstrate co-moment computation without reaching
into non-exported symbols of the package via :::.
A named list with components m2, m3, m4
(NULL for any component whose corresponding co-moment matrix
was not supplied).
Jondeau, E., Poon, S.-H., & Rockinger, M. (2007). Financial Modeling Under Non-Gaussian Distributions. Springer.
set.seed(1) R <- matrix(rnorm(200 * 4), 200, 4) d <- ncol(R) M2 <- cov(R) w <- rep(1 / d, d) # Variance of the equal-weighted portfolio: f_portfolio_moments(w, M2 = M2)$m2 # Co-skewness / co-kurtosis matrices in d x d^2 / d x d^3 form (e.g. from # PerformanceAnalytics::M3.MM() / M4.MM()) can be passed as M3, M4.set.seed(1) R <- matrix(rnorm(200 * 4), 200, 4) d <- ncol(R) M2 <- cov(R) w <- rep(1 / d, d) # Variance of the equal-weighted portfolio: f_portfolio_moments(w, M2 = M2)$m2 # Co-skewness / co-kurtosis matrices in d x d^2 / d x d^3 form (e.g. from # PerformanceAnalytics::M3.MM() / M4.MM()) can be passed as M3, M4.
Solves for portfolio weights that (approximately) maximize expected utility
using a fourth-order moment expansion in mean–variance–skewness–kurtosis
(MVSK). The problem is solved via SLSQP with the constraints
and .
f_ptf_max_U(gamma, w_max, M1, M2, M3, M4)f_ptf_max_U(gamma, w_max, M1, M2, M3, M4)
gamma |
Non-negative numeric scalar risk-aversion parameter. |
w_max |
Numeric scalar in |
M1 |
Numeric vector of expected returns (length |
M2 |
Numeric |
M3 |
Numeric |
M4 |
Numeric |
The objective implemented is the negative of the truncated MVSK utility series, so minimizing it is equivalent to maximizing the utility:
where are the portfolio's first four
centralized moments and is a risk-aversion parameter.
The equality constraint is enforced via eval_g_eq and box constraints
via lb/ub. Gradients are supplied analytically using
internal helper functions '.derportm2', '.derportm3', and '.derportm4' defined
in 'portfolio-moments.R'.
A list with:
wNumeric vector of optimal portfolio weights (length ).
EUScalar: value of the (approximate) expected utility at w (sign-corrected).
Portfolio moment calculations (portm2/3/4 and their gradients) are
performed by internal helpers in ‘R/portfolio-moments.R’, vendored
from the standard kronecker-product formulas (Jondeau et al., 2007).
M3 and M4 must be co-moment matrices (
and ), not higher-dimensional arrays.
Jondeau, E., Poon, S.-H., & Rockinger, M. (2007). Financial Modeling Under Non-Gaussian Distributions. Harvey, C. R., Liechty, J. C., Liechty, M. W., & Müller, P. (2010). Portfolio selection with higher moments.
set.seed(1) d <- 3 M1 <- c(0.06, 0.08, 0.07) A <- matrix(rnorm(d*d), d); M2 <- crossprod(A)/d M3 <- matrix(0, d, d^2) M4 <- matrix(0, d, d^3) res <- f_ptf_max_U(gamma = 5, w_max = 0.8, M1, M2, M3, M4) res$w; res$EUset.seed(1) d <- 3 M1 <- c(0.06, 0.08, 0.07) A <- matrix(rnorm(d*d), d); M2 <- crossprod(A)/d M3 <- matrix(0, d, d^2) M4 <- matrix(0, d, d^3) res <- f_ptf_max_U(gamma = 5, w_max = 0.8, M1, M2, M3, M4) res$w; res$EU
Computes the probability density function (PDF) of the multivariate
Student- copula at a specified point , given
location vector , scatter matrix , and degrees of freedom
.
f_student_copula_pdf(u, mu, Sigma, nu)f_student_copula_pdf(u, mu, Sigma, nu)
u |
Numeric vector of length |
mu |
Numeric vector of length |
Sigma |
Numeric |
nu |
Positive numeric scalar: degrees of freedom of the Student- |
The multivariate Student- copula density is given by
where and denote the multivariate and univariate Student-
densities, respectively, and is the quantile function of
the univariate Student- with degrees of freedom.
For , this copula converges to the Gaussian copula.
A numeric scalar: the value of the Student- copula density
at u. The value is returned as a
plain numeric scalar (not a matrix).
Demarta, S., & McNeil, A. J. (2005). The t Copula and Related Copulas. *International Statistical Review*, 73(1), 111–129. Joe, H. (1997). *Multivariate Models and Dependence Concepts*. Chapman & Hall. Nelsen, R. B. (2006). *An Introduction to Copulas* (2nd ed.). Springer.
f_normal_copula_pdf, f_clayton_copula_2d_pdf,
f_gumbel_copula_2d_pdf
# Example: 2D t-copula density mu <- c(0, 0) Sigma <- matrix(c(1, 0.7, 0.7, 1), 2, 2) f_student_copula_pdf(c(0.6, 0.8), mu, Sigma, nu = 5) # Compare to Gaussian copula (nu large) f_student_copula_pdf(c(0.6, 0.8), mu, Sigma, nu = 100)# Example: 2D t-copula density mu <- c(0, 0) Sigma <- matrix(c(1, 0.7, 0.7, 1), 2, 2) f_student_copula_pdf(c(0.6, 0.8), mu, Sigma, nu = 5) # Compare to Gaussian copula (nu large) f_student_copula_pdf(c(0.6, 0.8), mu, Sigma, nu = 100)
Estimates the empirical tail‐dependence coefficient and the
exceedance correlation between two series at a given quantile threshold
for either the lower or upper tail.
f_tail_dependence(x, y, alpha, side = c("lower", "upper"))f_tail_dependence(x, y, alpha, side = c("lower", "upper"))
x |
Numeric vector of length |
y |
Numeric vector of length |
alpha |
Numeric scalar in |
side |
Character string, either |
The function classifies observations in the ‐quantile tail of
each margin and computes:
the standard empirical tail‐dependence coefficient: the
proportion of joint tail events conditional on x
being in its tail (lambda), and
the sample correlation between the values of x and y
for which both lie in their respective tails (excorr).
If no joint tail events are found, lambda = 0 and
excorr = NA. If fewer than two joint-tail observations are available,
excorr is also NA (the sample correlation is undefined).
When the joint-tail subset is degenerate (e.g., x and y are
identical so that the subset has zero variance), cor
returns NA with a warning.
A list with components:
lambdaEmpirical tail‐dependence coefficient.
For side = "lower":
For side = "upper":
excorrExceedance correlation between x and y
in the joint tail (computed only if there are joint exceedances).
Joe, H. (1997). Multivariate Models and Dependence Concepts. Chapman & Hall. Embrechts, P., McNeil, A. J., & Straumann, D. (2002). Correlation and dependence in risk management. Risk Management: Value at Risk and Beyond. Cambridge University Press.
set.seed(1) x <- rnorm(1000) y <- 0.7 * x + sqrt(1 - 0.7^2) * rnorm(1000) f_tail_dependence(x, y, alpha = 0.05) f_tail_dependence(x, y, alpha = 0.05, side = "upper")set.seed(1) x <- rnorm(1000) y <- 0.7 * x + sqrt(1 - 0.7^2) * rnorm(1000) f_tail_dependence(x, y, alpha = 0.05) f_tail_dependence(x, y, alpha = 0.05, side = "upper")
Weekly time series of the three Fama–French equity risk factors and the
risk-free rate, as provided by Kenneth French's data library.
Values are expressed in percentage points (e.g., 1.60 means
a return of 1.60%).
data("FamaFrench")data("FamaFrench")
An xts object with 4\,834 weekly observations
(from 1926-07-02 to 2019-02-22) and 4 columns:
Excess return on the market (market return minus risk-free rate), in %.
Small-Minus-Big size factor return, in %.
High-Minus-Low value factor return, in %.
Risk-free rate (weekly), in %.
The time index is a weekly Date. Divide by 100 to convert to decimal
returns before use in calculations. To work at monthly frequency, downsample
with, for example, FamaFrench[xts::endpoints(FamaFrench, "months"), ].
Kenneth R. French Data Library, https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html.
Fama, E. F., & French, K. R. (1993). Common Risk Factors in the Returns on Stocks and Bonds. Journal of Financial Economics, 33(1), 3–56.
data("FamaFrench") class(FamaFrench) # "xts" "zoo" dim(FamaFrench) # 4834 x 4 head(FamaFrench) # Convert to decimal and extract the three equity factors ff <- FamaFrench[, c("mkt_rf", "smb", "hml")] / 100 rf <- FamaFrench[, "rf"] / 100data("FamaFrench") class(FamaFrench) # "xts" "zoo" dim(FamaFrench) # 4834 x 4 head(FamaFrench) # Convert to decimal and extract the three equity factors ff <- FamaFrench[, c("mkt_rf", "smb", "hml")] / 100 rf <- FamaFrench[, "rf"] / 100
An xts object holding 128 FRED-MD macroeconomic predictors and the
monthly Dow Jones Industrial Average log-returns, aligned over the period
2015-01 to 2019-12. Used to illustrate high-dimensional regularised
regression (Lasso, Ridge) in a return-prediction context.
data("Fred")data("Fred")
An xts object with 60 monthly observations (index Jan 2015
to Dec 2019, class zoo::yearmon) and 129 columns:
Standardised FRED-MD macro variables, transformed
(differenced or log-differenced) to achieve stationarity following the
FRED-MD transformation codes. Column names are FRED-MD series codes
(e.g., "INDPRO", "CPIAUCSL", "GS10").
DJI.Adjusted (final column)One-month-ahead Dow Jones
Industrial Average log-returns, aligned so that row of the
predictors corresponds to row of the response.
The 128 macro predictors (columns 1 to 128) were downloaded from the
McCracken–Ng FRED-MD database and transformed according to the recommended
stationarity codes. The target column DJI.Adjusted was obtained from
Yahoo Finance via quantmod::getSymbols("^DJI") and converted to
monthly log-returns. All series are restricted to the 60-month window
2015-01 to 2019-12 and temporally aligned so that the predictor columns in
row can be used to predict DJI.Adjusted in row .
McCracken, M. W., & Ng, S. FRED-MD database, https://www.stlouisfed.org/research/economists/mccracken/fred-databases.
Dow Jones daily prices via quantmod::getSymbols("^DJI"),
Yahoo Finance.
McCracken, M. W., & Ng, S. (2016). FRED-MD: A Monthly Database for Macroeconomic Research. Journal of Business & Economic Statistics, 34(4), 574–589.
The book chapter on Dimension Reduction (Chapter 4 of
Statistical Methods for Quantitative Finance) introduces Lasso and
Ridge regression on the lower-dimensional GoyalWelch dataset;
Fred provides a complementary high-dimensional () test
bed for the same regularised-regression workflow.
data("Fred") class(Fred) # "xts" "zoo" y <- Fred[, "DJI.Adjusted"] # response (60 x 1) X <- Fred[, colnames(Fred) != "DJI.Adjusted"] # 128 macro predictors dim(X) # Lasso with cross-validation (requires glmnet, which expects matrices) if (requireNamespace("glmnet", quietly = TRUE)) { set.seed(1234) fit <- glmnet::cv.glmnet(as.matrix(X), as.numeric(y), alpha = 1) coef(fit, s = "lambda.min")[coef(fit, s = "lambda.min")[,1] != 0, , drop = FALSE] }data("Fred") class(Fred) # "xts" "zoo" y <- Fred[, "DJI.Adjusted"] # response (60 x 1) X <- Fred[, colnames(Fred) != "DJI.Adjusted"] # 128 macro predictors dim(X) # Lasso with cross-validation (requires glmnet, which expects matrices) if (requireNamespace("glmnet", quietly = TRUE)) { set.seed(1234) fit <- glmnet::cv.glmnet(as.matrix(X), as.numeric(y), alpha = 1) coef(fit, s = "lambda.min")[coef(fit, s = "lambda.min")[,1] != 0, , drop = FALSE] }
Daily adjusted close prices of the FTSE 100 stock index
(ticker symbol ^FTSE), from its first date of availability on
Yahoo Finance to 2015-12-31.
data("FTSE")data("FTSE")
An xts object with 8333 daily observations and a single
column ^FTSE containing adjusted close prices in index points.
The time index spans from 1984-01-03 to 2015-12-31.
Originally distributed as FTSE in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("FTSE") class(FTSE) # "xts" "zoo" dim(FTSE) head(FTSE)data("FTSE") class(FTSE) # "xts" "zoo" dim(FTSE) head(FTSE)
Daily adjusted close prices for 98 constituents of the FTSE 100 stock index as of 2016-01-03.
data("FTSE_const")data("FTSE_const")
An xts object with 7198 daily observations and 98
columns, one per constituent (e.g., HSBA.L, BP.L,
VOD.L). Missing values appear before the first date at which
a given constituent was available. The time index spans from
1988-05-03 to 2015-12-31.
Originally distributed as FTSE_const in the qrmdata
package (Hofert, Hornik, & McNeil), ported into smqf so that
the book's examples remain reproducible without an extra dependency. The
data is redistributed here under the same GPL () license as
qrmdata.
Only 98 of the 100 constituents were available at the time of the
download.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("FTSE_const") class(FTSE_const) # "xts" "zoo" dim(FTSE_const) head(colnames(FTSE_const))data("FTSE_const") class(FTSE_const) # "xts" "zoo" dim(FTSE_const) head(colnames(FTSE_const))
Monthly time series of commonly used Fung–Hsieh style and macro factors.
The object is an xts matrix indexed by month (class
zoo::yearmon) with the columns listed below. Typical use cases
include hedge-fund replication and factor attribution.
data("FungHsieh")data("FungHsieh")
An xts object with 276 monthly observations
(Jan 1994 to Dec 2016), indexed by zoo::yearmon, and 8 columns:
Equity market factor (broad market return / excess return).
Risk-free rate (monthly).
Size or related equity style spread (e.g., small–minus–big).
Change in the 10-year U.S. Treasury constant-maturity yield.
Change in a BAA credit spread / yield (credit conditions).
Fung–Hsieh trend-following factor: bond.
Fung–Hsieh trend-following factor: commodity.
Fung–Hsieh trend-following factor: currency (FX).
Columns are provided as in the original Fung–Hsieh factor construction.
Units may appear as percentage points or basis points depending on source/
vintage; treat the series consistently within your analysis. The time index
is of class zoo::yearmon (a calendar month with no day-of-month), so
the series aligns with other monthly data by month, irrespective of any
day-of-month convention.
Compiled from public factor sources commonly used in the Fung–Hsieh
literature
(e.g., Hsieh’s data library, FRED/H.15, and Fama–French style factors).
If you distribute the data, include a data-raw/ script that reproduces
this object from original sources.
Fung, W., & Hsieh, D. A. (2004). Hedge Fund Benchmarks: A Risk-Based Approach. Financial Analysts Journal, 60(5), 65–80. Fung, W., & Hsieh, D. A. (2001). The Risk in Hedge Fund Strategies: Theory and Evidence from Trend Followers. Review of Financial Studies, 14(2), 313–341.
data("FungHsieh") class(FungHsieh) # "xts" "zoo" head(FungHsieh) colnames(FungHsieh) # Quick plot of the three PTFS factors if (requireNamespace("zoo", quietly = TRUE)) { zoo::plot.zoo(FungHsieh[, c("PTFSBD", "PTFSCOM", "PTFSFX")], screens = 1, col = 1:3) }data("FungHsieh") class(FungHsieh) # "xts" "zoo" head(FungHsieh) colnames(FungHsieh) # Quick plot of the three PTFS factors if (requireNamespace("zoo", quietly = TRUE)) { zoo::plot.zoo(FungHsieh[, c("PTFSBD", "PTFSCOM", "PTFSFX")], screens = 1, col = 1:3) }
Daily World Gold Council gold price in USD per troy ounce, from 1970-01-01 to 2015-12-31.
data("GOLD")data("GOLD")
An xts object with 9691 daily observations and a single
column GOLD containing USD prices per troy ounce.
Originally distributed as GOLD in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as qrmdata.
Federal Reserve Economic Data (FRED) via Quandl, downloaded on
2016-01-03 with qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("GOLD") class(GOLD) # "xts" "zoo" dim(GOLD) head(GOLD)data("GOLD") class(GOLD) # "xts" "zoo" dim(GOLD) head(GOLD)
Monthly time series of equity predictors and bond/credit variables commonly
used in return predictability studies following Goyal & Welch (2008).
Stored as an xts object indexed by month (class zoo::yearmon).
data("GoyalWelch")data("GoyalWelch")
An xts object with monthly observations (Dec 1979 to Dec 2018
in this snapshot), indexed by zoo::yearmon, and 15 variables:
Broad U.S. equity price index level (e.g., S&P 500).
Trailing 12-month cash dividends on the index (level).
Trailing 12-month earnings on the index (level).
Aggregate book-to-market ratio.
3-month Treasury bill rate (monthly).
Moody’s AAA corporate bond yield.
Moody’s BAA corporate bond yield.
Long-term government bond yield.
Net equity expansion: shares issued less repurchases scaled by total equity (a supply measure).
Risk-free rate (monthly).
Inflation (monthly change in price level).
Long-term government bond total return (monthly).
Corporate bond total return (monthly).
Stock market variance proxy (e.g., rolling sum of daily squared returns).
Corporate bond return spread: corpr - ltr.
This object mirrors the variables used in
Goyal & Welch (2008) and subsequent updates. From these levels you can form
the standard ratios used in the literature, for example
dp = log(D12/Index), ep = log(E12/Index),
dfy = BAA - AAA, and tms = lty - tbl.
Compiled from the public Goyal–Welch data library (predictable stock returns)
and standard fixed-income sources (e.g., FRED). If you distribute this data,
include a data-raw/ script that reproduces the object from originals.
Goyal, A., & Welch, I. (2008). A Comprehensive Look at The Empirical Performance of Equity Premium Prediction. Review of Financial Studies, 21(4), 1455–1508.
data("GoyalWelch") class(GoyalWelch) # "xts" "zoo" head(GoyalWelch) # Construct common predictors: dp <- log(GoyalWelch[,"D12"] / GoyalWelch[,"Index"]) # dividend–price ep <- log(GoyalWelch[,"E12"] / GoyalWelch[,"Index"]) # earnings–price dfy <- GoyalWelch[,"BAA"] - GoyalWelch[,"AAA"] # default yield spread tms <- GoyalWelch[,"lty"] - GoyalWelch[,"tbl"] # term spreaddata("GoyalWelch") class(GoyalWelch) # "xts" "zoo" head(GoyalWelch) # Construct common predictors: dp <- log(GoyalWelch[,"D12"] / GoyalWelch[,"Index"]) # dividend–price ep <- log(GoyalWelch[,"E12"] / GoyalWelch[,"Index"]) # earnings–price dfy <- GoyalWelch[,"BAA"] - GoyalWelch[,"AAA"] # default yield spread tms <- GoyalWelch[,"lty"] - GoyalWelch[,"tbl"] # term spread
Daily adjusted close prices of the Hang Seng stock index (ticker
symbol ^HSI), from its first date of availability on Yahoo
Finance to 2015-12-31.
data("HSI")data("HSI")
An xts object with 7214 daily observations and a single
column ^HSI containing adjusted close prices in index points.
The time index spans from 1986-12-31 to 2015-12-31.
Originally distributed as HSI in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as
qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("HSI") class(HSI) # "xts" "zoo" dim(HSI) head(HSI)data("HSI") class(HSI) # "xts" "zoo" dim(HSI) head(HSI)
Daily adjusted close prices of the NIKKEI 225 stock index
(ticker symbol ^N225), from its first date of availability on
Yahoo Finance to 2015-12-30.
data("NIKKEI")data("NIKKEI")
An xts object with 7880 daily observations and a single
column ^N225 containing adjusted close prices in index points.
The time index spans from 1984-01-04 to 2015-12-30.
Originally distributed as NIKKEI in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("NIKKEI") class(NIKKEI) # "xts" "zoo" dim(NIKKEI) head(NIKKEI)data("NIKKEI") class(NIKKEI) # "xts" "zoo" dim(NIKKEI) head(NIKKEI)
Daily adjusted close prices of the Swiss Market Index (SMI) stock
index (ticker symbol ^SSMI), from its first date of
availability on Yahoo Finance to 2015-12-30.
data("SMI")data("SMI")
An xts object with 6350 daily observations and a single
column ^SSMI containing adjusted close prices in index points.
The time index spans from 1990-11-09 to 2015-12-30.
Originally distributed as SMI in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as
qrmdata. Note: the MSGARCH package ships a different
dataset also named SMI (SMI log-returns); to use that one, load
it explicitly with data("SMI", package = "MSGARCH").
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("SMI") class(SMI) # "xts" "zoo" dim(SMI) head(SMI)data("SMI") class(SMI) # "xts" "zoo" dim(SMI) head(SMI)
Daily adjusted close prices of the Standard & Poor's 500 stock index
(ticker symbol ^GSPC), from its first date of availability on
Yahoo Finance to 2015-12-31.
data("SP500")data("SP500")
An xts object with 16607 daily observations and a single
column ^GSPC containing adjusted close prices in index points.
The time index spans from 1950-01-03 to 2015-12-31.
Originally distributed as SP500 in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as qrmdata.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("SP500") class(SP500) # "xts" "zoo" dim(SP500) head(SP500)data("SP500") class(SP500) # "xts" "zoo" dim(SP500) head(SP500)
Weekly adjusted close prices for the 505 constituents of the S&P 500 index (membership as of the 2016-01-03 snapshot).
data("SP500_const")data("SP500_const")
An xts object with 2818 weekly observations (the last
available trading day of each week) and 505 columns, one per
constituent (e.g., AAPL, MSFT, XOM). Missing
values are common, especially in the early part of the sample, since a
given name only has data once it became available. The time index
spans from 1962-01-05 to 2015-12-31.
Unlike the DJ_const, FTSE_const and
EURSTX_const panels (which are daily), this dataset is
stored at weekly frequency to keep the package within the
CRAN size limit. Weekly data is sufficient for the high-dimensional
covariance and factor-model examples in the book, where a three-year
window already has more constituents than observations.
Originally distributed as SP500_const in the qrmdata
package (Hofert, Hornik, & McNeil), thinned to weekly frequency and
ported into smqf so that the book's examples remain reproducible
without an extra dependency. The data is redistributed here under the
same GPL () license as qrmdata. The panel reflects
index membership at the snapshot date and is therefore subject to
survivorship bias.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("SP500_const") class(SP500_const) # "xts" "zoo" dim(SP500_const) head(colnames(SP500_const))data("SP500_const") class(SP500_const) # "xts" "zoo" dim(SP500_const) head(colnames(SP500_const))
A compact term-structure object holding daily yield curves across 11 standard
maturities from mid-2006 to late-2008. The object is an xts matrix of
annualized yields (rows = dates, columns = maturities); the maturity grid in
years is attached as the "tau" entry of xts::xtsAttributes().
data("TermStructure")data("TermStructure")
An xts object of annualized yields (percent, not decimals)
with dimension . The index runs daily from
2006-05-12 to 2008-10-31; columns are the 11 maturities:
X1mo, X3mo, X6mo, X1yr, X2yr, X3yr,
X5yr, X7yr, X10yr, X20yr, X30yr.
The maturity grid in years,
c(1/12, 1/4, 1/2, 1, 2, 3, 5, 7, 10, 20, 30), is stored as a user
attribute and retrieved with xts::xtsAttributes(TermStructure)$tau.
Dates run from 2006-05-12 to 2008-10-31 (about 622 business
days in this snapshot). Yields are curve levels for each maturity on each
date and can be used directly for fitting/parsing term-structure models
(e.g., Nelson–Siegel or Svensson), computing spreads (term, slope,
butterfly),
or building zero curves.
data("TermStructure") class(TermStructure) # "xts" "zoo" dts <- index(TermStructure) # observation dates colnames(TermStructure) # Example: 10Y vs 2Y term spread (in percentage points) sprd_10y2y <- TermStructure[, "X10yr"] - TermStructure[, "X2yr"] head(sprd_10y2y) # Maturity grid (years), stored as a user attribute xts::xtsAttributes(TermStructure)$taudata("TermStructure") class(TermStructure) # "xts" "zoo" dts <- index(TermStructure) # observation dates colnames(TermStructure) # Example: 10Y vs 2Y term spread (in percentage points) sprd_10y2y <- TermStructure[, "X10yr"] - TermStructure[, "X2yr"] head(sprd_10y2y) # Maturity grid (years), stored as a user attribute xts::xtsAttributes(TermStructure)$tau
Daily close values of the Chicago Board Options Exchange (CBOE)
volatility index VIX (ticker symbol ^VIX), from its first date
of availability on Yahoo Finance to 2015-12-31.
data("VIX")data("VIX")
An xts object with 6553 daily observations and a single
column ^VIX containing the VIX level in percent
(annualized implied volatility). The time index spans from
1990-01-02 to 2015-12-31.
Originally distributed as VIX in the qrmdata package
(Hofert, Hornik, & McNeil), ported into smqf so that the book's
examples remain reproducible without an extra dependency. The data is
redistributed here under the same GPL () license as qrmdata. The VIX is
typically used as a market-based measure of volatility, expressed in
percent.
Yahoo Finance, downloaded on 2016-01-03 via qrmtools::get_data().
Hofert, M., Hornik, K., & McNeil, A. J. qrmdata: Data Sets for Quantitative Risk Management Practice, https://CRAN.R-project.org/package=qrmdata.
data("VIX") class(VIX) # "xts" "zoo" dim(VIX) head(VIX)data("VIX") class(VIX) # "xts" "zoo" dim(VIX) head(VIX)