# Calculating Life Expectancy with time variant probabilities

In this example, we will show how to utilize the Markov Chain to calculate the life expectancy of a cohort.

Say, a cohort of 10,000 people has a probability of death from year 0 years to 100 years as shown in the following table.

Let's start with the Rational Will or Decision Tree Software, and choose "Markov Chance Node" from this start screen. Please note that I am showing how Markov modeling works in its most basic form.

Please note that we are choosing a Markov node as the root node of the Decision Tree because, in this example, we will focus on the Markov Chain only, and not any other decision analysis. But, once the model is created, you can add other decision nodes later for performing more analysis. Anyway, you will see your diagram starts like this.

### Step 1: Creating the Markov States

Click that fly-over menu button two times to create two Markov states. You will see the decision tree software will create the diagram like this. Then select a state and mouse double click to enter the node into edit text mode. Then change the text.

Then. edit the first State as "Well" and edit the second state as "Dead", as shown below.

### Strep 2: Setting up Cohort Simulation Parameters

Once you open the Markov Setting, set up as shown below. Cohort Size 10,000. The maximum number of state transitions is 21, Markov state transition duration is 5 years, and apply the half-cycle correction. Also check the box "Cycle Name" and use the name "Age" as we want to display the Time axis on the charts as Age.

Click Ok.

### Step 3: Setting initial state

Now, select the node "Well" and right-mouse click to bring the context menu. You will see an option "Set as Initial State". Choose that option to set the Well state as the initial state.

Then, you will notice that the initial probability of the "Well" state has been set to 1 and the initial probability of the "Dead" state has been set to 0.

### Step 4: Setting transition probabilities (importing from Excel)

Now, click on the transition probability marker as shown as "?" marks on the edges. The "?" mark means, the probability is not set. So, according to the principle of indifference, equal probability will be used. But we want to specify the probability. So click on this "?" as shown here.

Then click the button for "Lookup table". You will see a view like this.

Then, open your Excel file and select the columns where the first column contains the Cycle number and the second column contains the probability. After selection, Copy the data in your clipboard.

Now, get back to the Decision Tree software and click this button to import the table from your clipboard. Please make sure that your data format is correct as shown in the above screenshot.

Once you click that import button, you will see the data is imported as shown below.

Here, every cycle represents a 5-year duration. Click the Ok button to accept. Now, you will see f(t) is shown in place of transition probability. The f(t) means the transition probability is a function of time, rather than a constant value.

Now, you can set the transition probability of Dead to Well = 0 and Dead to Dead = 1. "Dead" state is called Absorbing state. That means, once someone enters this state, he or she always stays in that state. There is a quick way to set a state as an absorbing state. Just select the state "Dead" and right-mouse click to bring the context menu. You will see an option "Set as absorbing state". Click that option.

Once you set the state as an absorbing state, you will see the state color becomes "Black" to indicate that it is now an absorbing state.

### Step 5: Setting Payoff / Reward

We want to calculate the Life Expectancy, so, let's give the "Well" state credit for the year lived in that state. As our cycle duration is 5 years, so, let's set the payoff as 5-year for Well State. For Dead state, we do not need to give any credit, so we do not need to set a payoff for the "Dead" state.

Select the state "Well" and click the following fly-over menu button to set Payoff.

Now, you will be presented with a screen where you will be asked to choose either Cost-Effectiveness analysis or regular single/multiple criteria analysis. Let's choose "Cost-Effectiveness Analysis", which is more suited for healthcare analysis.

Then, the cost-effectiveness setup window will appear.

Once you check that radial box for a custom variable, you can define your variable as shown below.

For this analysis, we do not need to configure Cost. So, just click Proceed after that. Then, you will be taken to the payoff editor in the decision tree. Set the Life year "5" for the state "Well".

### Step 6: Analyzing Result

In the diagram, notice that the expected value is displayed over the node. We can see the expected life year is shown as 76.87. So, 76.87 is the life expectancy of this cohort.

Once you click on the pop-out button, you will see the charts shown as a grid.

If you want to see the data table behind any chart, you can right-click on that chart and see the data table, which you can also export in Excel.

But, you can get the organized Cohort simulation traces from this panel.

Last updated on Feb 19, 2022