1
$\begingroup$

I'm trying to understand Fisher's exact test and the $\chi^2$ test of independence.

Suppose I've got a Markov Chain of first order with the following TPM:

$M = \begin{pmatrix} 0.3 & 0.7 \\ 0.99 & 0.01 \end{pmatrix}$.

I create a path with $N$ observations using the inverse CDF method. I can reproduce almost the same TPM with MLE from the path:

$N=1000: \hat{M} = \begin{pmatrix} 0.27& 0.73\\0.98 & 0.02\end{pmatrix}$

By the way, is there a rule of thumb about what the minimum sample size $N$ is?

Anyway, I know, for a first order Markov process the $X_t \in X$ and $X_{t+1} \in X$ are dependent, but $X_t$ and $X_{t+2}\in X$ are not (how do I write that formally?). If I create the contingency table via:

    [tab,~,p]=crosstab(X(1:end-1),X(2:end)) 
    tab = 
       158   417
       417     8

    p =  1.5748e-110 

    tab2 = full(sparse(X(1:end-1),X(2:end),1))
    tab2 =

       158   417
       417     8

Which should give me the one step contingency table, correct? p is the p-value of the $\chi^2$ test. That is ok so far. But if I use

    [tab,~,p]=crosstab(X(1:end-2),X(3:end)) 
    tab = 
       455   119
       119   106

    p =  4.968e-59 

Shouldn't be that independent?

And if I reduce the sample size to $N=100$ the $p=2.2e-11$ for the two step table. The same occurs with Fisher's test from http://www.mathworks.com/matlabcentral/fileexchange/26883-myfisher

Would anybody please be so kind and explain to me what I'm doing wrong here? Especially why my assumption don't work, or whether my code is wrong?

The background of the whole story is: I have a quite long time series with 4 states, and I need to estimate the minimal Markov chain order.

Thank you very much!

$\endgroup$

1 Answer 1

2
$\begingroup$

You're simply mistaken.

Unconditionally, $X_t$ and $X_{t-2}$ from a Markov chain aren't independent.

As a result, you'd expect, with sufficiently large samples, to reject a test of independence.

(Conditionally on $X_{t-1}$, $X_t$ doesn't depend on $X_{t-2}$, because all the dependence comes through $X_{t-1}$.)

$\endgroup$
2
  • $\begingroup$ Okay, then i dont't get it anymore ;) Condintionally independence means: P(A|B,C)=P(A|B)P(A|C). Stochastical (unconditional?) independence means P(A,B)=P(A)P(B) What did I "test", can I see X(t) as A and X(t-1) as B? Then I tested the unconditional dependence? I'll look into how to test for conditional dependence. $\endgroup$
    – Jan
    Commented Oct 7, 2014 at 10:13
  • $\begingroup$ You tested the unconditional correlation between $X_t$ and $X_{t-2}$. $\endgroup$
    – Glen_b
    Commented Oct 7, 2014 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.