Gives the stationary probabilities for a 1st-order Markov chain (R.P. Littlejohn).
Option
PRINT = string token |
What to print (transitions, pstationary); default psta |
|---|
Parameters
| DATA = matrices or factors | Specifies the Markov chain as a factor, or matrix of transitions |
|---|---|
STATES = texts |
Labels for the states |
PSTATIONARY = variates |
Saves the stationary probabilities |
TRANSITIONS = matrices |
Saves the transition matrices |
Description
MC1PSTATIONARY prints and/or saves the stationary probabilities for a first-order Markov chain. The data are input using the DATA parameter, as either a matrix of transition counts or a factor of states from which the transition matrix is calculated. The probabilities and transition matrix can be saved using the TRANSITIONS and PSTATIONARY parameters, respectively.
Option: PRINT.
Parameters: DATA, STATES, PSTATIONARY, TRANSITIONS.
Method
The procedure uses LSVECTORS to obtain the required eigenvector.
Action with RESTRICT
If the DATA parameter is set to a list of factors, these must not be restricted.
See also
Commands for: Time series.
Example
CAPTION 'MC1PSTATIONARY examples'; STYLE=meta
"Input as transition probability matrix"
MATRIX [ROWS=2; COLUMNS=2; VALUES=.95,.05,.10,.90] m
MC1PSTATIONARY m
"Input as factor of states"
CALCULATE u=1+INT(5*URAND(855438; 1000))
GROUP u; FACTOR=fu
MC1PSTATIONARY [PRINT=transitions,pstationary] fu
"Input as transition count matrix"
VARIATE [VALUES=(1...5)] vmact; DECIMALS=0
MATRIX [ROWS=vmact; COLUMNS=vmact] mact[1,2]
READ mact[1]
1362 26 2 62 1
33 31 9 64 7
7 13 7 35 4
31 74 49 355 16
0 11 3 12 6 :
READ mact[2]
1048 19 7 56 4
21 27 17 77 17
10 17 21 53 25
41 69 64 467 52
4 30 15 43 29 :
TEXT [VALUES=sit,stand,walk,graze,pace] aname
MC1PSTATIONARY [PRINT=transitions,pstationary] mact[1,2]; STATES=aname;\
PSTATIONARY=pact[1,2]
PRINT pact[]