A bit of background - I am an actuary who is trying to learn Julia. In doing so, I am trying to move some of the models that I would usually make in Excel to Julia.
I am stuck on one particular problem which Excel makes quite easy for me. I am looking for ways to do the same in Julia. The problem is as follows:
I know the probabilities of default for various ratings (AAA to CCC) at various maturities (year 1 to 30 - discrete). I don’t know the underlying transition matrix that produced this table and the task is to fit a transition matrix.
It is basically a discrete Markov model.
In excel I would do the following:
-
I know the probability of default at various maturities which looks something like this:
-
Define a matrix T which gives transition rates for various states: AAA, AA, A, BBB, BB, B, CCC and default. Where AAA to CCC are various ratings and final column is default state.
The default column is known now and is equal to the probability of default in year 1.
The diagonal entries of the matrix is set equal to “1 - sum of other entries” in the row.
-
Initialize this matrix, say by setting zero everywhere except diagonal entries (formula) and default column (known)
-
Do multiple matrix multiplications to get the probability of default at various years. For example, last column T^2 = probability of default at year 2.
-
Calculate squared distance between actual probability of default (given by 1) and calculated in 4 at all years.
-
Run excel solver to minimize sum of squared difference.
I am not sure if there is an easy way to set this up in Julia. I can experiment if someone can point me to a package that I should be looking at.