The package can be installed via executing the following code in R (Studio)
install.packages("devtools")
devtools::install_github("mausserhofer/MarkovThiele")
library(MarkovThiele)
R will then install the package devtools from cran, with which you can install the package from this site (github.com/manalysis/MarkovThiele)
For a working example, you can run
mtc <- markovThieleChain(trans, cashflowPre, cashflowPost)
and R will create a Markov-Thiele-Chain S3 object for an life risk insurance contract with annual premiums of 4 and payoff 100 in the event of death. Interest rates are set to 0%. You can change this with defining e.g. i=0.01 in the class constructor markovThieleChain().
Once the MTC is constructed, you can run the available evaluation routines.
completeV(mtc)
completeDist(mtc)
forwardDist(mtc, u=50, state="alive", time=50)
This package deals with cashflow processes that are describable with a discrete time markov chain and cashflows that depend on the state of underlying the markov chain. We'll call such a process a Markov-Thiele-chain (MTC).
A Markov-Thiele-chain is described by the following:
1. permissible states
2. transition probabilities
3. cashflows that are triggered if the markov chain is in a specific state at a given time:
, and
4. cashflows that are triggerd if the markov chain changes its state at a given time step
5. interest rate term structures, this is used for discounting in calculating the expected value of cashflows and etc., see below.
6. Terminal values of the MTC, typically a fixed cashflow at the terminal time of the MTC.
Points 1 and 2 form a regular markov chain, points 3 and 4 add the cashflow structure. Point 5 is regarded as part of the Markov-Thiele-chain for practical purposes.
Core of the package is the Thiele-Difference Equation. It allows the stepwise evaluation of the present value of expected cashflows at time t, using the present value of expected cashflows at time t+1, transition probabilities from time t to t+1 and the cashflows occuring at time t+1.
Similar equations for stepwise evaluation exist for higher moments as well as for the distribution of cashflows.
MTCs can represent almost any life and health insurance contract. They can represent financial instruments such as vanilla options or structured notes.
What people want to know about such objects are the following: - what is the present value of the expected cashflows? - what is the variance and higher moments of the present value of expected cashflows? - what is value-at-risk for different levels of alpha? - what is the distribution of the present value of cashflows?
Feel free to provide improvements of the code, extend functionalities or just reach out to me via email
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.