A Markov chain for the weather in a particular season of the year has the transition matrix, from one day to the next:
It can be shown, using linear algebra, that in the long run this Markov chain will visit the states according to the stationary distribution:
A result called the ergodic theorem allows us to estimate this distribution by simulating the Markov chain for a long enough time.
(a) Simulate 1000 values, and calculate the proportion of times the chain visits each of the states. Compare the proportions given by the simulation with the above theoretical proportions.
(b) Here is code that calculates rolling averages of the proportions over a number of simulations and plots the result. It uses the function rollmean() from the zoo package.
Try varying the number of simulations and the width of the window. How wide a window is needed to get a good sense of the stationary distribution? This series settles down rather quickly to its stationary distribution (it “burns in” quite quickly). A reasonable width of window is, however, needed to give an accurate indication of the stationary distribution.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here