Title: | Estimating the Parameters of a Continuous-Time Markov Chain from Discrete-Time Data |
---|---|
Description: | Estimation of Markov generator matrices from discrete-time observations. The implemented approaches comprise diagonal and weighted adjustment of matrix logarithm based candidate solutions as in Israel (2001) <doi:10.1111/1467-9965.00114> as well as a quasi-optimization approach. Moreover, the expectation-maximization algorithm and the Gibbs sampling approach of Bladt and Sorensen (2005) <doi:10.1111/j.1467-9868.2005.00508.x> are included. |
Authors: | Marius Pfeuffer [aut, cre], Greig Smith [ctb], Goncalo dos Reis [ctb], Linda Moestel [ctb], Matthias Fischer [ctb] |
Maintainer: | Marius Pfeuffer <[email protected]> |
License: | GPL-3 |
Version: | 1.4.4 |
Built: | 2024-12-06 06:32:19 UTC |
Source: | CRAN |
Functions for estimating Markov generator matrices from discrete-time observations.
Marius Pfeuffer [aut, cre], Greig Smith [ctb], Goncalo dos Reis [ctb], Linda Moestel [ctb], Matthias Fischer [ctb]
Maintainer: Marius Pfeuffer <[email protected]>
M. Pfeuffer: ctmcd: An R Package for Estimating the Parameters of a Continuous-Time Markov Chain from Discrete-Time Data. The R Journal 9(2):127-141, 2017
M. Pfeuffer. Generator Matrix Approximation Based on Discrete-Time Rating Migration Data. Master Thesis, Ludwig Maximilian University of Munich, 2016
R. B. Israel et al.: Finding Generators for Markov Chains via Empirical Transition Matrices, with Applications to Credit Ratings. Mathematical Finance 11(2):245-265, 2001
E. Kreinin and M. Sidelnikova: Regularization Algorithms for Transition Matrices. Algo Research Quarterly 4(1):23-40, 2001
M. Bladt and M. Soerensen: Statistical Inference for Discretely Observed Markov Jump Processes. Journal of the Royal Statistical Society B 67(3):395-410, 2005
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) plot(gmem) ## Confidence Interval ciem=gmci(gmem,alpha=0.05) plot(ciem)
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) plot(gmem) ## Confidence Interval ciem=gmci(gmem,alpha=0.05) plot(ciem)
Function for evaluating the likelihood function of a continuous-time Markov chain given discrete-time data.
ctmcdlogLik(gm, tmabs, te)
ctmcdlogLik(gm, tmabs, te)
gm |
generator matrix of continuous-time Markov chain |
tmabs |
matrix of absolute transition frequencies |
te |
time elapsed in transition process |
log-likelihood value
Marius Pfeuffer
data(tm_abs) ## Initial guess for generator matrix (absorbing default state) gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 ## Log-likelihood of initial guess ctmcdlogLik(gm0,tm_abs,1)
data(tm_abs) ## Initial guess for generator matrix (absorbing default state) gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 ## Log-likelihood of initial guess ctmcdlogLik(gm0,tm_abs,1)
Generic function to estimate the parameters of a continuous Markov chain
gm(tm, te, method, ...)
gm(tm, te, method, ...)
tm |
matrix of either absolute transition frequencies (if method is "EM" or "GS") or relative transition frequencies (if method is "DA", "WA" of "QO") |
te |
time elapsed in transition process |
method |
method to derive generator matrix: "DA" - Diagonal Adjustment, "WA" - Weighted Adjustment, "QO" - Quasi-Optimization, "EM" - Expectation-Maximization Algorithm, "GS" - Gibbs Sampler |
... |
Additional Arguments:
|
The methods "DA", "WA" and "QO" provide adjustments of a matrix logarithm based candidate solution, "EM" gives the maximum likelihood estimate and "GS" a posterior mean estimate in a Bayesian setting with conjugate Gamma priors.
generator matrix estimate
Marius Pfeuffer
G. dos Reis, M. Pfeuffer, G. Smith: Capturing Rating Momentum in the Estimation of Probabilities of Default, With Application to Credit Rating Migrations (In Preparation), 2018
M. Pfeuffer: Generator Matrix Approximation Based on Discrete Time Rating Migration Data. Master Thesis, University of Munich, 2016
Y. Inamura: Estimating Continuous Time Transition Matrices from Discretely Observed Data. Bank of Japan Working Paper Series, 2006
R. B. Israel et al.: Finding Generators for Markov Chains via Empirical Transition Matrices, with Applications to Credit Ratings. Mathematical Finance 11(2):245-265, 2001
E. Kreinin and M. Sidelnikova: Regularization Algorithms for Transition Matrices. Algo Research Quarterly 4(1):23-40, 2001
M. Bladt and M. Soerensen: Statistical Inference for Discretely Observed Markov Jump Processes. Journal of the Royal Statistical Society B 67(3):395-410, 2005
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) gmem ## Quasi Optimization Estimate tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) gmqo=gm(tm_rel,te=1,method="QO") gmqo
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) gmem ## Quasi Optimization Estimate tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) gmqo=gm(tm_rel,te=1,method="QO") gmqo
Default function to estimate the parameters of a continuous Markov chain
## Default S3 method: gm(tm, te, method, gmguess = NULL, prior = NULL, burnin = NULL, eps = 1e-06, conv_pvalue = 0.05, conv_freq = 10, niter = 10000, sampl_func = NULL, combmat = NULL, sampl_method = "Unif", logmethod = "Eigen", expmethod = "PadeRBS", verbose = FALSE, ...)
## Default S3 method: gm(tm, te, method, gmguess = NULL, prior = NULL, burnin = NULL, eps = 1e-06, conv_pvalue = 0.05, conv_freq = 10, niter = 10000, sampl_func = NULL, combmat = NULL, sampl_method = "Unif", logmethod = "Eigen", expmethod = "PadeRBS", verbose = FALSE, ...)
tm |
matrix of either absolute transition frequencies (if method is "EM" or "GS") or relative transition frequencies (if method is "DA", "WA" of "QO") |
te |
time elapsed in transition process |
method |
method to derive generator matrix: "DA" - Diagonal Adjustment, "WA" - Weighted Adjustment, "QO" - Quasi-Optimization, "EM" - Expectation-Maximization Algorithm, "GS" - Gibbs Sampler |
gmguess |
initial guess for generator matrix estimation procedure (if method is "EM") |
prior |
prior parametrization (if method is "GS") |
burnin |
burn-in period (if method is "GS") |
eps |
convergence criterion (if method is "EM" or "GS") |
conv_pvalue |
convergence criterion: stop, if Heidelberger and Welch's diagnostic assumes convergence (see coda package) |
conv_freq |
convergence criterion: absolute frequency of convergence evaluations |
niter |
maximum number of iterations (if method is "EM" or "GS") |
sampl_func |
optional self-written path sampling function for endpoint-conditioned Markov processes (if method is "GS") |
combmat |
matrix stating combined use of modified rejection sampling / uniformization sampling algorithms (if method is "GS") |
sampl_method |
sampling method for deriving endpoint-conditioned Markov process path: "Unif" - Uniformization Sampling, "ModRej" - Modified Rejection Sampling (if method is "GS") |
logmethod |
method to compute matrix logarithm (if method is "DA", "WA" or "QO", see |
expmethod |
method to compute matrix exponential (if method is "EM" or "GS", see |
verbose |
verbose mode (if method is "EM" or "GS") |
... |
additional arguments |
The methods "DA", "WA" and "QO" provide adjustments of a matrix logarithm based candidate solution, "EM" gives the maximum likelihood estimate and "GS" a posterior mean estimate in a Bayesian setting with conjugate Gamma priors.
generator matrix estimate
Marius Pfeuffer
M. Pfeuffer: Generator Matrix Approximation Based on Discrete Time Rating Migration Data. Master Thesis, University of Munich, 2016
Y. Inamura: Estimating Continuous Time Transition Matrices from Discretely Observed Data. Bank of Japan Working Paper Series, 2006
R. B. Israel et al.: Finding Generators for Markov Chains via Empirical Transition Matrices, with Applications to Credit Ratings. Mathematical Finance 11(2):245-265, 2001
E. Kreinin and M. Sidelnikova: Regularization Algorithms for Transition Matrices. Algo Research Quarterly 4(1):23-40, 2001
M. Bladt and M. Soerensen: Statistical Inference for Discretely Observed Markov Jump Processes. Journal of the Royal Statistical Society B 67(3):395-410, 2005
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) gmem ## Quasi Optimization Estimate tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) gmqo=gm(tm_rel,te=1,method="QO") gmqo
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) gmem ## Quasi Optimization Estimate tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) gmqo=gm(tm_rel,te=1,method="QO") gmqo
Generic function to derive confidence / credibility intervals for "EM" or "GS" based generator matrix objects
gmci(gm, alpha, ...)
gmci(gm, alpha, ...)
gm |
a "EM" or "GS" generator matrix object |
alpha |
significance level |
... |
additional arguments:
|
If gm is based on the "EM" method (expectation-maximization algorithm), the function computes a Wald confidence interval based on the method of Oakes, 1999. IF gm is based on the "GS" method (Gibbs sampler), the function computes an equal-tailed credibility interval.
generator matrix confidence bounds
Marius Pfeuffer
M. Bladt and M. Soerensen. Efficient Estimation of Transition Rates Between Credit Ratings from Observations at Discrete Time Points. Quantitative Finance, 9(2):147-160, 2009
D. Oakes. Direct calculation of the information matrix via the EM algorithm. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 61(2):479-482, 1999
G. Smith and G. dos Reis. Robust and Consistent Estimation of Generators in Credit Risk. Quantitative Finance 18(6):983-1001, 2018
G. dos Reis, M. Pfeuffer, G. Smith: Capturing Rating Momentum in the Estimation of Probabilities of Default, With Application to Credit Rating Migrations (In Preparation), 2018
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) ## Oakes Confidence Interval ciem=gmci(gmem,alpha=0.05) ciem
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) ## Oakes Confidence Interval ciem=gmci(gmem,alpha=0.05) ciem
Default function to derive confidence / credibility intervals for "EM" or "GS" based generator matrix objects
## Default S3 method: gmci(gm, alpha, eps = 1e-04, cimethod="Direct", expmethod = "PadeRBS", ...)
## Default S3 method: gmci(gm, alpha, eps = 1e-04, cimethod="Direct", expmethod = "PadeRBS", ...)
gm |
a "EM" or "GS" generator matrix object |
alpha |
significance level |
eps |
threshold for which generator matrix parameters are assumed to be fixed at zero (if "EM" object) |
cimethod |
"Direct" or "SdR" use analytical expressions of the Fisher information matrix, "BS" emloy the numerical expressions of Bladt and Soerensen, 2009 (if "EM" object) |
expmethod |
method to compute matrix exponentials (see |
... |
additional arguments |
If gm is based on the "EM" method (expectation-maximization algorithm), the function computes a Wald confidence interval based on the method of Oakes, 1999. IF gm is based on the "GS" method (Gibbs sampler), the function computes an equal-tailed credibility interval.
generator matrix confidence bounds
Marius Pfeuffer
G. dos Reis, M. Pfeuffer, G. Smith: Capturing Rating Momentum in the Estimation of Probabilities of Default, With Application to Credit Rating Migrations (In Preparation), 2018
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) ## Oakes Confidence Interval ciem=gmci(gmem,alpha=0.05) ciem
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) ## Oakes Confidence Interval ciem=gmci(gmem,alpha=0.05) ciem
Function for deriving a Markov generator matrix estimate based on the diagonal adjustment method of Israel et al., 2001
gmDA(tmrel, te, logmethod = "Eigen")
gmDA(tmrel, te, logmethod = "Eigen")
tmrel |
matrix of relative transition frequencies |
te |
time elapsed in transition process |
logmethod |
method for computation of matrix logarithm, by default eigendecomposition is chosen (see |
A candidate solution is derived by the matrix logarithm and then adjusted in order to fulfil the properties of a Markov generator matrix.
generator matrix estimate
Marius Pfeuffer
R. B. Israel et al.: Finding Generators for Markov Chains via Empirical Transition Matrices, with Applications to Credit Ratings. Mathematical Finance 11(2):245-265, 2001
## Derive matrix of relative transition frequencies data(tm_abs) tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) ## Derive diagonal adjustment generator matrix estimate gmda=gmDA(tm_rel,1) gmda
## Derive matrix of relative transition frequencies data(tm_abs) tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) ## Derive diagonal adjustment generator matrix estimate gmda=gmDA(tm_rel,1) gmda
Function for deriving a Markov generator matrix estimate by an instance of the expectation-maximization algorithm (described by Bladt and Soerensen, 2005)
gmEM(tmabs, te, gmguess, eps = 1e-06, niter = 10000, expmethod = "PadeRBS", verbose = FALSE)
gmEM(tmabs, te, gmguess, eps = 1e-06, niter = 10000, expmethod = "PadeRBS", verbose = FALSE)
tmabs |
matrix of absolute transition frequencies |
te |
time elapsed in transition process |
gmguess |
initial guess (for generator matrix) |
eps |
stop criterion: stop, if relative change in log-likelihood is smaller than eps |
niter |
stop criterion: maximum number of iterations |
expmethod |
method for computation of matrix exponential, by default "PadeRBS" is chosen (see |
verbose |
verbose mode |
A maximum likelihood generator matrix estimate is derived by an instance of the expectation-maximization algorithm.
generator matrix estimate
Marius Pfeuffer
M. Bladt and M. Soerensen: Statistical Inference for Discretely Observed Markov Jump Processes. Journal of the Royal Statistical Society B 67(3):395-410, 2005
data(tm_abs) ## Initial guess for generator matrix (absorbing default state) gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 ## Derive expectation-maximization algorithm generator matrix estimate gmem=gmEM(tmabs=tm_abs,1,gmguess=gm0,verbose=TRUE) gmem
data(tm_abs) ## Initial guess for generator matrix (absorbing default state) gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 ## Derive expectation-maximization algorithm generator matrix estimate gmem=gmEM(tmabs=tm_abs,1,gmguess=gm0,verbose=TRUE) gmem
Function for deriving a Markov generator matrix estimate by Gibbs sampling (described by Bladt and Soerensen, 2005)
gmGS(tmabs, te, prior, burnin, conv_pvalue = 0, conv_freq = 10, niter = 10000, sampl_method = "Unif", expmethod = "PadeRBS", verbose = FALSE, combmat=NULL, sampl_func = NULL)
gmGS(tmabs, te, prior, burnin, conv_pvalue = 0, conv_freq = 10, niter = 10000, sampl_method = "Unif", expmethod = "PadeRBS", verbose = FALSE, combmat=NULL, sampl_func = NULL)
tmabs |
matrix of absolute transition frequencies |
te |
time elapsed in transition process |
prior |
list of prior parameters (Gamma prior) |
burnin |
number of burn-in iterations |
conv_pvalue |
convergence criterion: stop, if Heidelberger and Welch's diagnostic assumes convergence (see coda package), convergence check is only employed if conv_pvalue>0 |
conv_freq |
convergence criterion: absolute frequency of convergence evaluations |
niter |
stop criterion: stop, if maximum number of iterations is exceeded |
sampl_method |
method for sampling paths from endpoint-conditioned Markov processes. options: "Unif" - Uniformization sampling, "ModRej" - Modified Rejection Sampling |
expmethod |
method for computation of matrix exponential, by default "PadeRBS" is chosen (see |
verbose |
verbose mode |
combmat |
matrix specifying the combined use of sampling methods: "U" - uniformization sampling, "M" - modified rejection sampling |
sampl_func |
interface for own endpoint-conditioned Markov process sampling function |
A posterior mean generator matrix estimate is derived by Gibbs Sampling. The gamma distribution is used as prior.
generator matrix estimate
Marius Pfeuffer
M. Bladt and M. Soerensen: Statistical Inference for Discretely Observed Markov Jump Processes. Journal of the Royal Statistical Society B 67(3):395-410, 2005
rNijTRiT_ModRej
, rNijTRiT_Unif
data(tm_abs) ## Example prior parametrization (absorbing default state) pr=list() pr[[1]]=matrix(1,8,8) pr[[1]][8,]=0 pr[[2]]=c(rep(5,7),Inf) ## Derive Gibbs sampling generator matrix estimate gmgs=gmGS(tmabs=tm_abs,te=1,sampl_method="Unif",prior=pr,burnin=10,niter=100,verbose=TRUE) gmgs
data(tm_abs) ## Example prior parametrization (absorbing default state) pr=list() pr[[1]]=matrix(1,8,8) pr[[1]][8,]=0 pr[[2]]=c(rep(5,7),Inf) ## Derive Gibbs sampling generator matrix estimate gmgs=gmGS(tmabs=tm_abs,te=1,sampl_method="Unif",prior=pr,burnin=10,niter=100,verbose=TRUE) gmgs
Function for deriving a Markov generator matrix estimate based on the quasi-optimization procedure of Kreinin and Sidelnikova, 2001
gmQO(tmrel, te, logmethod = "Eigen")
gmQO(tmrel, te, logmethod = "Eigen")
tmrel |
matrix of relative transition frequencies |
te |
time elapsed in transition process |
logmethod |
method for computation of matrix logarithm, by default eigendecomposition is chosen (see |
From the set of possible Markov generator matrices, the one is chosen which is closest to a matrix logarithm based candidate solution in terms of sum of squared deviations.
generator matrix estimate
Marius Pfeuffer
E. Kreinin and M. Sidelnikova: Regularization Algorithms for Transition Matrices. Algo Research Quarterly 4(1):23-40, 2001
data(tm_abs) ## Derive matrix of relative transition frequencies data(tm_abs) tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) ## Derive quasi optimization generator matrix estimate gmqo=gmQO(tm_rel,1) gmqo
data(tm_abs) ## Derive matrix of relative transition frequencies data(tm_abs) tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) ## Derive quasi optimization generator matrix estimate gmqo=gmQO(tm_rel,1) gmqo
Function for deriving a Markov generator matrix estimate based on the weighted adjustment method of Israel et al., 2001
gmWA(tmrel, te, logmethod = "Eigen")
gmWA(tmrel, te, logmethod = "Eigen")
tmrel |
matrix of relative transition frequencies |
te |
time elapsed in transition process |
logmethod |
method for computation of matrix logarithm, by default eigendecomposition is chosen (see |
A candidate solution is derived by the matrix logarithm and then adjusted in order to fulfil the properties of a Markov generator matrix.
generator matrix estimate
Marius Pfeuffer
R. B. Israel et al.: Finding Generators for Markov Chains via Empirical Transition Matrices, with Applications to Credit Ratings. Mathematical Finance 11(2):245-265, 2001
## Derive matrix of relative transition frequencies data(tm_abs) tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) ## Derive weighted adjustment generator matrix estimate gmwa=gmWA(tm_rel,1) gmwa
## Derive matrix of relative transition frequencies data(tm_abs) tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) ## Derive weighted adjustment generator matrix estimate gmwa=gmWA(tm_rel,1) gmwa
Function for visualizing the output of a generator matrix estimation procedure.
## S3 method for class 'gm' plot(x, mattext, col = c("grey", "red"), main = x$method, las = 1, xlab = "To", ylab = "From", xnames, ynames, cex = 1, fig = 3, opacity_factor, ...)
## S3 method for class 'gm' plot(x, mattext, col = c("grey", "red"), main = x$method, las = 1, xlab = "To", ylab = "From", xnames, ynames, cex = 1, fig = 3, opacity_factor, ...)
x |
a generator matrix estimation object |
mattext |
optional: matrix of strings replacing the parameter estimates |
col |
two element vector of basis colors for positive and negative parameter estimate entries |
main |
optional: plot title |
las |
orientation of x and y axis elements |
xlab |
x axis name |
ylab |
y axis name |
xnames |
description of x axis elements |
ynames |
description of y axis elements |
cex |
font size |
fig |
number of significant figure to be plotted |
opacity_factor |
two element vector for specification of opacity for positive and negative parameter entry highlighting (must be greater than zero) |
... |
additional arguments |
no value, plot function
Marius Pfeuffer
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) plot(gmem)
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) plot(gmem)
Function for visualizing the boundaries of generator matrix confidence / credibility intervals
## S3 method for class 'gmci' plot(x, mattext, col = c("grey", "red"), main, las = 1, xlab = "To", ylab = "From", xnames, ynames, cex = 1, fig = 2, opacity_factor, ...)
## S3 method for class 'gmci' plot(x, mattext, col = c("grey", "red"), main, las = 1, xlab = "To", ylab = "From", xnames, ynames, cex = 1, fig = 2, opacity_factor, ...)
x |
a generator matrix confidence / credibility interval object |
mattext |
optional: matrix of strings replacing the parameter estimates |
col |
two element vector of basis colors for positive and negative parameter estimate entries |
main |
optional: plot title |
las |
orientation of x and y axis elements |
xlab |
x axis name |
ylab |
y axis name |
xnames |
description of x axis elements |
ynames |
description of y axis elements |
cex |
font size |
fig |
number of significant figures to be plotted |
opacity_factor |
two element vector for specification of opacity for positive and negative parameter entry highlighting (must be greater than zero) |
... |
additional arguments |
no value, plot function
Marius Pfeuffer
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) plot(gmem) ## Confidence Interval ciem=gmci(gmem,alpha=0.05) plot(ciem)
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) plot(gmem) ## Confidence Interval ciem=gmci(gmem,alpha=0.05) plot(ciem)
Function to visualize matrices
plotM(mat, mattext, col = c("grey", "red"), main, las = 1, xlab = "To", ylab = "From", xnames, ynames, cex = min(1, nrow(mat)/8), fig = 3, opacity_factor)
plotM(mat, mattext, col = c("grey", "red"), main, las = 1, xlab = "To", ylab = "From", xnames, ynames, cex = min(1, nrow(mat)/8), fig = 3, opacity_factor)
mat |
a matrix |
mattext |
optional: matrix of strings replacing the original matrix entries |
col |
two element vector of basis colors for positive and negative matrix entries |
main |
optional: plot title |
las |
orientation of x and y axis elements |
xlab |
x axis name |
ylab |
y axis name |
xnames |
description of x axis elements |
ynames |
description of y axis elements |
cex |
font size |
fig |
number of significant figures to be plotted |
opacity_factor |
two element vector for specification of opacity for positive and negative parameter entry highlighting (must be greater than zero) |
no value, plot function
Marius Pfeuffer
gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 plotM(gm0)
gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 plotM(gm0)
Function for printing the results of a generator matrix estimation
## S3 method for class 'gm' print(x, ...)
## S3 method for class 'gm' print(x, ...)
x |
a generator matrix estimation object |
... |
additional arguments |
generator matrix
Function for printing the boundaries of a generator matrix confidence / credibility interval
## S3 method for class 'gmci' print(x, ...)
## S3 method for class 'gmci' print(x, ...)
x |
a generator matrix confidence / credibility interval |
... |
additional arguments |
generator matrix confidence bounds
Function for generating initial and endpoint-conditioned Markov process sampling paths for a given discrete-time transition matrix
rNijTRiT_ModRej(tmabs, te, gm)
rNijTRiT_ModRej(tmabs, te, gm)
tmabs |
matrix of absolute transition frequencies |
te |
time elapsed in transition process |
gm |
generator matrix |
Function for the simulation of paths from an endpoint-conditioned Markov process. Returns number of transitions NijT and cumulative holding times RiT.
endpoint-conditioned sampling path
Jon Fintzi, Marius Pfeuffer
J. Fintzi: R Package ECctmc, 2016.
A. Hobolth and E. A. Stone: Simulation from Endpoint-Conditioned, Continuous-Time Markov Chains on a Finite State Space, with Applications to Molecular Evolution. Annals of Applied Statistics 3(3):1204-1231, 2009
data(tm_abs) ## Initial guess for generator matrix (absorbing default state) gm=matrix(1,8,8) diag(gm)=0 diag(gm)=-rowSums(gm) gm[8,]=0 rNijTRiT_ModRej(tm_abs,1,gm)
data(tm_abs) ## Initial guess for generator matrix (absorbing default state) gm=matrix(1,8,8) diag(gm)=0 diag(gm)=-rowSums(gm) gm[8,]=0 rNijTRiT_ModRej(tm_abs,1,gm)
Function for generating initial and endpoint-conditioned Markov process sampling paths for a given discrete-time transition matrix
rNijTRiT_Unif(tmabs, te, gm, tpm)
rNijTRiT_Unif(tmabs, te, gm, tpm)
tmabs |
matrix of absolute transition frequencies |
te |
time elapsed in transition process |
gm |
generator matrix |
tpm |
discrete-time transition probability matrix, matrix exponential of gm |
Function for the simulation of paths from an endpoint-conditioned Markov process. Returns number of transitions NijT and cumulative holding times RiT.
endpoint-conditioned sampling path
Jon Fintzi, Marius Pfeuffer
J. Fintzi: R Package ECctmc, 2016.
A. Hobolth and E. A. Stone: Simulation from Endpoint-Conditioned, Continuous-Time Markov Chains on a Finite State Space, with Applications to Molecular Evolution. Annals of Applied Statistics 3(3):1204-1231, 2009
data(tm_abs) ## Generator Matrix gm=matrix(1,8,8) diag(gm)=0 diag(gm)=-rowSums(gm) gm[8,]=0 ## Transition Probability Matrix library(expm) te=1 tpm=expm(gm*te) rNijTRiT_Unif(tm_abs,te,gm,tpm)
data(tm_abs) ## Generator Matrix gm=matrix(1,8,8) diag(gm)=0 diag(gm)=-rowSums(gm) gm[8,]=0 ## Transition Probability Matrix library(expm) te=1 tpm=expm(gm*te) rNijTRiT_Unif(tm_abs,te,gm,tpm)
Function for providing results and extended output of a generator matrix estimation procedure.
## S3 method for class 'gm' summary(object, ...)
## S3 method for class 'gm' summary(object, ...)
object |
a generator matrix estimation object |
... |
additional arguments |
estimation summary
Matrix of Standard and Poor's Global Corporate Rating Transition Frequencies 2000 (NR Removed)
data("tm_abs")
data("tm_abs")
The format is: num [1:8, 1:8] 17 2 0 0 0 0 0 0 1 455 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:8] "AAA" "AA" "A" "BBB" ... ..$ : chr [1:8] "AAA" "AA" "A" "BBB" ...
European Securities and Markets Authority, 2016
https://cerep.esma.europa.eu/cerep-web/statistics/transitionMatrice.xhtml
data(tm_abs) ## Matrix of relative transition frequencies tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) tm_rel
data(tm_abs) ## Matrix of relative transition frequencies tm_rel=rbind((tm_abs/rowSums(tm_abs))[1:7,],c(rep(0,7),1)) tm_rel
Generic function to derive delta method based confidence intervals for matrix exponential transformations of "EM" based generator matrix objects
tmci(gmem, alpha, te, eps = 1e-04, expmethod = "PadeRBS")
tmci(gmem, alpha, te, eps = 1e-04, expmethod = "PadeRBS")
gmem |
an "EM" generator matrix object |
alpha |
significance level |
te |
discrete time horizon for which the interval is supposed to be computed |
eps |
threshold for which generator matrix parameters are assumed to be fixed at zero |
expmethod |
method to compute matrix exponentials (see |
Confidence intervals for discrete-time transition matrix predictions given generator matrix estimates are computed by using the delta method for matrix exponential transformations.
transition matrix confidence bounds
G. dos Reis, M. Pfeuffer, G. Smith: Capturing Rating Momentum in the Estimation of Probabilities of Default, With Application to Credit Rating Migrations (In Preparation), 2018
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) ## 2.5 Year Transition Matrix Confidence Interval citm=tmci(gmem,alpha=0.05,te=2.5) citm
data(tm_abs) ## Maximum Likelihood Generator Matrix Estimate gm0=matrix(1,8,8) diag(gm0)=0 diag(gm0)=-rowSums(gm0) gm0[8,]=0 gmem=gm(tm_abs,te=1,method="EM",gmguess=gm0) ## 2.5 Year Transition Matrix Confidence Interval citm=tmci(gmem,alpha=0.05,te=2.5) citm