| Title: | Extended Vasicek Credit Loss Model with Macroeconomic Factors |
| Version: | 0.1.0 |
| Description: | Fits the extended Vasicek single-factor credit loss model where the probability of default depends on macroeconomic covariates. Maximum likelihood estimates of all parameters, including asset value correlation, are obtained via closed-form probit-transformed OLS regression; see Mayorov (2026) <doi:10.2139/ssrn.6506378> for derivation. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| Depends: | R (≥ 3.5.0) |
| Imports: | stats |
| Suggests: | testthat (≥ 3.0.0), vasicek |
| Config/testthat/edition: | 3 |
| URL: | https://github.com/externalmemory/vasicekfit-cran-package |
| BugReports: | https://github.com/externalmemory/vasicekfit-cran-package/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-04-23 22:22:06 UTC; default |
| Author: | Dmitriy Mayorov [aut, cre] |
| Maintainer: | Dmitriy Mayorov <cran@dimview.org> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-28 18:50:02 UTC |
Extended Vasicek Credit Loss Model with Macroeconomic Factors
Description
Fits the extended Vasicek single-factor credit loss model where the probability of default depends on macroeconomic covariates. Maximum likelihood estimates of all parameters, including asset value correlation, are obtained via closed-form probit-transformed OLS regression. Also provides density, distribution, quantile, and random generation functions for the Vasicek loss distribution.
Author(s)
Dmitriy Mayorov
References
Vasicek, O. A. (2002). The distribution of loan portfolio value. Risk, 15(12), 160–162.
Yang, B. H. (2014). Estimating Long-Run PD, Asset Correlation, and Portfolio Level PD by Vasicek Models. MPRA Paper No. 57244.
See Also
vasicekfit, predict.vasicekfit,
dvasicek
The Vasicek Loss Distribution
Description
Density, distribution function, quantile function, and random generation for the Vasicek credit loss distribution.
Usage
dvasicek(x, p, rho, kappa = NULL, u = NULL, log = FALSE)
pvasicek(q, p, rho, kappa = NULL, u = NULL, lower.tail = TRUE, log.p = FALSE)
qvasicek(prob, p, rho, kappa = NULL, u = NULL, lower.tail = TRUE, log.p = FALSE)
rvasicek(n, p, rho, kappa = NULL, u = NULL)
Arguments
x, q |
vector of quantiles (loss rates in (0, 1)). |
prob |
vector of probabilities. |
n |
number of observations to generate. |
p |
probability of default, in (0, 1). |
rho |
asset value correlation, in (0, 1). |
kappa |
optional numeric vector of macro-factor sensitivities. |
u |
optional numeric vector of macro-factor values, same length as
|
log, log.p |
logical; if |
lower.tail |
logical; if |
Details
The Vasicek loss distribution arises from the single-factor Gaussian copula model. Its probability density function is
f(x) = \sqrt{\frac{1-\rho}{\rho}} \exp\left\{\frac{1}{2}\left(\Phi^{-1}(x)^2 - \left[\frac{\sqrt{1-\rho}\,\Phi^{-1}(x) - \sum \kappa_j u_j - \Phi^{-1}(p)}{\sqrt{\rho}}\right]^2\right)\right\}
When kappa and u are NULL, this reduces to the standard
two-parameter Vasicek distribution.
Value
dvasicek gives the density, pvasicek gives the distribution
function, qvasicek gives the quantile function, and rvasicek
generates random deviates.
References
Vasicek, O. A. (2002). The distribution of loan portfolio value. Risk, 15(12), 160–162.
See Also
Examples
# Standard Vasicek density
curve(dvasicek(x, p = 0.03, rho = 0.10), from = 0.001, to = 0.20,
ylab = "Density", main = "Vasicek loss distribution")
# 99th percentile (Basel-style)
qvasicek(0.99, p = 0.03, rho = 0.10)
# Check CDF and quantile are inverses
qvasicek(pvasicek(0.05, p = 0.03, rho = 0.10), p = 0.03, rho = 0.10)
# Random sample
set.seed(1)
hist(rvasicek(10000, p = 0.03, rho = 0.10), breaks = 100,
main = "Vasicek loss distribution samples")
Predict Method for vasicekfit Objects
Description
Obtain predictions from a fitted Vasicek model, optionally at specified confidence levels.
Usage
## S3 method for class 'vasicekfit'
predict(object, newdata = NULL,
type = c("link", "response"), alpha = NULL, ...)
Arguments
object |
a |
newdata |
an optional data frame of new predictor values. If omitted, the training data are used. |
type |
character; |
alpha |
optional numeric vector of confidence levels in (0, 1). When supplied, predictions are conditional quantiles of the loss distribution at each confidence level. |
... |
additional arguments (currently unused). |
Value
If alpha is NULL, a numeric vector of predictions.
If alpha is supplied, a matrix with rows corresponding to observations
and columns to confidence levels. When alpha is a scalar, the result
is a vector.
See Also
Examples
set.seed(42)
n <- 100
u <- rnorm(n)
x <- pnorm((qnorm(0.03) + 0.1 * u + sqrt(0.02) * rnorm(n)) / sqrt(1 - 0.02))
d <- data.frame(default_rate = x, macro = u)
fit <- vasicekfit(default_rate ~ macro, data = d)
# Conditional mean PD
predict(fit, type = "response")
# 99th percentile loss rate under stress
predict(fit, newdata = data.frame(macro = 2), alpha = 0.99,
type = "response")
# Multiple confidence levels
predict(fit, newdata = data.frame(macro = c(0, 1, 2)),
alpha = c(0.95, 0.99, 0.999), type = "response")
Fit an Extended Vasicek Credit Loss Model
Description
Fits the extended Vasicek single-factor credit loss model where the probability of default depends on macroeconomic covariates. All parameters, including asset value correlation, are estimated via closed-form probit-transformed OLS.
Usage
vasicekfit(formula, data, bias_correct = FALSE, portfolio_size = NULL)
Arguments
formula |
a formula of the form |
data |
a data frame containing the variables in |
bias_correct |
logical; if |
portfolio_size |
optional positive integer. If supplied, a finite-portfolio variance correction is applied to the response before fitting (see Yang, 2014, section 4.3). |
Value
An object of class "vasicekfit", which is a list containing:
- p
estimated probability of default (baseline PD).
- rho
estimated asset value correlation.
- kappa
named numeric vector of macro-factor sensitivities.
- sigma2
MLE variance estimate in probit space.
- lm_fit
the underlying
lmobject.- fitted.values
fitted values in probit (Y) space.
- residuals
residuals in probit (Y) space.
- formula
the model formula.
- call
the matched call.
- terms
the
termsobject.- model
the model frame.
- bias_correct
logical flag used.
- portfolio_size
portfolio size used, or
NULL.
References
Vasicek, O. A. (2002). The distribution of loan portfolio value. Risk, 15(12), 160–162.
Yang, B. H. (2014). Estimating Long-Run PD, Asset Correlation, and Portfolio Level PD by Vasicek Models. MPRA Paper No. 57244.
See Also
Examples
set.seed(42)
n <- 100
u1 <- rnorm(n)
u2 <- rnorm(n)
p_true <- 0.03; rho_true <- 0.02
kappa_true <- c(0.13, -0.07)
z <- rnorm(n)
x <- pnorm((qnorm(p_true) + kappa_true[1] * u1 + kappa_true[2] * u2 +
sqrt(rho_true) * z) / sqrt(1 - rho_true))
d <- data.frame(default_rate = x, unemp = u1, hpi = u2)
fit <- vasicekfit(default_rate ~ unemp + hpi, data = d)
fit
Methods for vasicekfit Objects
Description
Print, summary, coefficient extraction, covariance, confidence interval,
and accessor methods for "vasicekfit" objects.
Usage
## S3 method for class 'vasicekfit'
print(x, ...)
## S3 method for class 'vasicekfit'
summary(object, ...)
## S3 method for class 'vasicekfit'
coef(object, ...)
## S3 method for class 'vasicekfit'
fitted(object, ...)
## S3 method for class 'vasicekfit'
residuals(object, ...)
## S3 method for class 'vasicekfit'
vcov(object, ...)
## S3 method for class 'vasicekfit'
confint(object, parm, level = 0.95, ...)
Arguments
x, object |
a |
parm |
a specification of which parameters to compute confidence intervals for, either a vector of names or indices. If missing, all parameters are considered. |
level |
the confidence level required. |
... |
additional arguments (currently unused). |
Details
coef returns the recovered Vasicek parameters (p, rho, and kappas)
in the original parameter space.
fitted and residuals return values in probit (Y) space,
consistent with the underlying OLS regression.
vcov returns the delta-method covariance matrix for the
original-space parameters (p, \rho, \kappa_1, \ldots, \kappa_m),
obtained by propagating the joint covariance of (\hat\beta, \hat\sigma^2)
through the closed-form recovery transform. The (\hat\beta, \hat\sigma^2)
block is treated as block-diagonal by the independence of sample mean and
variance under normality. The variance of \hat\sigma^2 uses
2 \sigma^4 (N - m - 1)/N^2 for the MLE and 2 \sigma^4 / (N - m - 1)
when bias_correct = TRUE.
confint returns Wald intervals based on vcov.
Value
print and summary return object invisibly.
coef returns a named numeric vector.
fitted and residuals return numeric vectors.
vcov returns a (m+2) \times (m+2) covariance matrix.
confint returns a two-column matrix of lower and upper bounds.