Markov chain

Stationary Markov chain with two states/ Asthma attacks

This loads the package.

<<StatisticalInference`

The following table shows the asthma attacks suffered by a child during 110 winter days (Pawitan 2001, p. 301). Here 0 denotes a day without attack and 1 a day during which the child had attacks.

dataFile = ToFileName[
{$InstallationDirectory,
"\\AddOns\\Applications\\StatisticalInference\\Datasets"},
"AsthmaAttacks.dat"];
dataOnAsthmaAttacks = Import[dataFile,"List"]

Response consists of indicators of asthma attacks.

resp=dataOnAsthmaAttacks;
n        =  
        Length[resp];

Assume that the sequence of 0's and 1's can be modelled with a stationary Markov chain.

ℳ=MarkovChainModel[{0, 1},n,Stationary -> True]
ShowParameter[ℳ]

This gives the observed likelihood function of the model

LikelihoodFunction[ℳ, 
      resp, {{p00, 1 - p00}, {p10, 1 - p10}}]

This calculates the fitted model.

ℱ = MLEFit[ℳ, resp]

MLParameterEstimate[ℱ] // MatrixForm

We can calculate a profile likelihood based confidence interval for the transition probabilities. The (approximate) 95%-level confidence interval for the probability of having a day without asthma attack given that during the previous day there was no attack is

ℐ = 
      ProfileInterval[ℱ, 
        p00, {{p00, 1 - p00}, {p10, 1 - p10}}]

ConfidenceLimits[ℐ]

Similarly the (approximate) 95%-level profile likelihood based confidence interval for the probability of having a day without asthma attack given that during the previous day there was attacks is

ℐ = 
      ProfileInterval[ℱ, 
        p10, {{p00, 1 - p00}, {p10, 1 - p10}}]

ConfidenceLimits[ℐ]

This calculates (approximate) 95%-level profile likelihood based confidence interval for the difference of the transition probabilities.

ℐ = 
      ProfileInterval[ℱ, 
        p00 - p10, 
        {{p00, 1 - p00}, {p10, 
            1 - p10}}]

ConfidenceLimits[ℐ]

We can test the hypothesis that the probability of asthma attack is independent of the situation on the previous day.

𝒯 = 
      LRTest[ℳ, resp, 
        p00, {{p00, 1 - p00}, {p00, 1 - p00}}]

Observed significance level of the test is

ObservedSignificanceLevel[𝒯]