transprob: Calculate transition matrices of continuous time Markov...

Description Usage Arguments Value Examples

Description

transprob calculates the transition matrix for a continuous time Markov chain. It is an implementation of the transprob MATLAB function. It is more general than the MATLAB function as it allows for the removal of assets that are only observed once, and for only including observed changes. I.e., if the last observation was 3 years ago, you have the choice whether to count those three years in the transition calculation or not.

Usage

1
2
3
transprob(data, labels, date_format = "%d-%b-%Y", end_date = NULL,
  removeSingleton = TRUE, transInterval = 1, ObservedOnly = FALSE,
  Cpp = TRUE, detail = FALSE)

Arguments

data

A data frame consisting of at least three columns. The first column must be the asset ID, the second column is the inspection date, and the third column is the rating. The inspections must be in chronological order for each asset

labels

A vector listing all the different asset ratings that occur. Not every rating in labels must occur in the data, but there can't be ratings in the data that don't occur in labels. Note that the order specified in labels determines the ordering of the rows and columns in the transition matrix.

date_format

A string (i.e. in quotations) giving the format of the date column of data. The format descriptions allowed are described at http://www.r-bloggers.com/date-formats-in-r/

end_date

= If ObservedOnly=FALSE, then the calculation assumes that the asset rating does not change from the last observation time. The total amount of time used in the calculation is determined by end_date. I.e., if the last inspection was 2012 and end_date was 2015, then this would add 3 years tothe total. If not value is specified, then the date of the last observation is used.

removeSingleton

a logical value indicating whether to remove assets that only have a single observation recorded or not. If FALSE, then assets with only a single observation are assumed to stay in that state through to end_date

transInterval

length of transition interval considered in years. Defaults to 1 year.

ObservedOnly

a logical value indicating whether to assume that assets remained in their current condition from the last inspection date until end_date, or whether just to count the time between observations.

Value

The transition matrix, with the rows and columns in the order specified in labels

Examples

1
2
3
4
labels = c('A', 'AA', 'AAA', 'B','BB','BBB','CCC','D')
transprob(FinancialRating, labels, date_format="%d-%b-%Y", end_date = '10-Nov-2015', removeSingleton = TRUE)
transprob(FinancialRating, labels, date_format="%d-%b-%Y", removeSingleton = FALSE)
transprob(FinancialRating, labels, date_format="%d-%b-%Y", removeSingleton = FALSE, ObservedOnly=TRUE)

rich-d-wilkinson/transprob documentation built on May 27, 2019, 7:41 a.m.