#### user366312

Gold Member

- 63

- 2

- Summary
- Finding conditional and joint probabilities from a table of data generated by Markov Chain simulation.

Let,

Suppose the following is the result of a 5-step Markov Chain simulation repeated 10 times:

What would be the values of the following?

Am I correct withe the rest?

Code:

```
alpha <- c(1, 1) / 2
mat <- matrix(c(1 / 2, 0, 1 / 2, 1), nrow = 2, ncol = 2)
chainSim <- function(alpha, mat, n)
{
out <- numeric(n)
out[1] <- sample(1:2, 1, prob = alpha)
for(i in 2:n)
out[i] <- sample(1:2, 1, prob = mat[out[i - 1], ])
out
}
```

Suppose the following is the result of a 5-step Markov Chain simulation repeated 10 times:

Code:

```
> sim
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 2 1 1 2 2 2 1 1 1 2
[2,] 2 1 2 2 2 2 2 1 1 2
[3,] 2 1 2 2 2 2 2 1 2 2
[4,] 2 2 2 2 2 2 2 1 2 2
[5,] 2 2 2 2 2 2 2 2 2 2
[6,] 2 2 2 2 2 2 2 2 2 2
```

- P(X1=1|X0=1)P(X1=1|X0=1)
- P(X2=1|X0=1)P(X2=1|X0=1)
- P(X5=2|X2=1)P(X5=2|X2=1)
- P(X1=1,X3=1)P(X1=1,X3=1)
- P(X5=2|X0=1,X2=1)P(X5=2|X0=1,X2=1)
- E(X2)E(X2)

- mean(sim[2, sim[1, ] == 1] == 1)
- mean(sim[3, sim[1, ] == 1] == 1)
- mean(sim[6, sim[3, ] == 1] == 2)
- mean(sim[4, ] == 1 && sim[2, ]== 1)
- ?
- c(1,2) * mean(sim[2, ])

Am I correct withe the rest?

Last edited: