Empirical misclassification matrices to the power of lambda may not exist for small values of lambda. These functions provide methods to estimate the nearest version of the misclassification matrix that satisfies the conditions a misclassification matrix has to fulfill, and to check it (existance for exponents smaller than 1).

build.mc.matrix(mc.matrix, method = "series",
  tuning = sqrt(.Machine$double.eps), diag.cor = FALSE,
  tol = .Machine$double.eps, max.iter = 100)

Arguments

mc.matrix

an empirical misclassification matrix

method

method used to estimate the generator for the misclassification matrix. One of "series", "log" or "jlt" (see Details)

tuning

security parameter for numerical reasons

diag.cor

should corrections be substracted from the diagonal or from all values corresponding to the size?

tol

tolerance level for series method for convegence

max.iter

maximal number of iterations for the series method to converge. Ignored if method is not "series"

Value

build.mc.matrix() returns a misclassification matrix that is the closest estimate for a working misclassification matrix.

check.mc.matrix() returns a vector of logicals.

Details

Method "series" constructs a generator via the series

\((Pi-I) - (Pi-I)^2/2 + (Pi-I)^3/3 - \dots\)

Method "log" constructs the generator via taking the log of the misclassification matrix. Small negative off-diagonal values are corrected and set to (0 + tuning). The amount used to correct for negative values is added to the diagonal element if diag.cor = TRUE and distributed among all values if diag.cor = FALSE.

Method "jlt" uses the method described by Jarrow et al. (see Israel et al.).

References

Israel, R.B., Rosenthal, J.S., Wei, J.Z., Finding generators for Markov Chains via empirical transition matrices, with applications to credit ratings,Mathematical Finance, 11, 245--265

See also

Examples

Pi <- matrix(data = c(0.989, 0.01, 0.001, 0.17, 0.829, 0.001, 0.001, 0.18, 0.819), nrow = 3, byrow = FALSE) check.mc.matrix(list(Pi))
#> [1] FALSE
check.mc.matrix(list(build.mc.matrix(Pi)))
#> [1] TRUE
build.mc.matrix(Pi)
#> [,1] [,2] [,3] #> [1,] 0.9890094 0.1700094 0.0171089 #> [2,] 0.0099950 0.8289950 0.1712169 #> [3,] 0.0009957 0.0009957 0.8116742
Pi3 <- matrix(c(0.8, 0.2, 0, 0, 0, 0.8, 0.1, 0.1, 0, 0.1, 0.8, 0.1, 0, 0, 0.3, 0.7), nrow = 4) check.mc.matrix(list(Pi3))
#> [1] FALSE
build.mc.matrix(Pi3)
#> [,1] [,2] [,3] [,4] #> [1,] 0.7896056 0.0000000 0.0000000 0.0000000 #> [2,] 0.1876515 0.8012965 0.1012965 0.0189650 #> [3,] 0.0109672 0.0992860 0.7992860 0.2892373 #> [4,] 0.0117757 0.0994175 0.0994175 0.6917977
check.mc.matrix(list(build.mc.matrix(Pi3)))
#> [1] TRUE
P1 <- matrix(c(1, 0, 0, 1), nrow = 2) P2 <- matrix(c(0.8, 0.15, 0, 0.2, 0.7, 0.2, 0, 0.15, 0.8), nrow = 3, byrow = TRUE) P3 <- matrix(c(0.4, 0.6, 0.6, 0.4), nrow = 2) mc.matrix <- list(P1, P2, P3) check.mc.matrix(mc.matrix) # TRUE FALSE FALSE
#> [1] TRUE FALSE FALSE