## Estimate Markov Chain Transition Matrix With Different State Sequence Lengths

### Radhika Malik (view profile)

on 30 May 2013

I'm trying to build the transition matrix for a Markov Chain in MATLAB; I have several different observation sequences (all of varying lengths) and I need to generate the transition matrix using those.

To build a transition matrix with a single observation sequence, I can use--

```    x = [1 6 1 6 4 4 4 3 1 2 2 3 4 5 4 5 2 6 2 6 2 6]; % the Markov chain
tm = full(sparse(x(1:end-1),x(2:end),1)) % the transition matrix.```

How can I construct one using state sequences of different length? One example can be that one sequence is 1,2,3,4 and another is 4,5,6.

Tom Lane

### Tom Lane (view profile)

on 1 Jun 2013

Can you explain more about what you want? If the two sequences are using different sets of states, how to you want to define a transition matrix? Is the issue that there may not be enough data so that all states appear in both sequences, even though they were theoretically possible? Or do you just want a separate transition matrix for each sequence? Or are the states such that you can't escape from certain subsets of states once you get into them? Or ...?

## Products

No products are associated with this question.

#### Join the 15-year community celebration.

Play games and win prizes!

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi