MCSimulation function

A function to simulate a discrete time Markov chain.

A function to simulate a discrete time Markov chain.

This function simulates a discrete time Markov chain with transition matrix P, state space 0,1,..,n and and initial state i for nsteps transitions.

MCSimulation(P,i,nsteps)

Arguments

  • P: the transition matrix.
  • i: the initial state.
  • nsteps: the number of transitions to be simulated.

Details

We assume that P is well defined transition matrix with rows summing to 1.

Returns

Returns the vector statehist containing the realisation of the chain for nsteps transitions.\

References

Jones, O.D., R. Maillardet, and A.P. Robinson. 2009. An Introduction to Scientific Programming and Simulation, Using R. Chapman And Hall/CRC.

See Also

MCEstimation, CMCSimulation

Examples

P <- matrix(c(0.5,0.5,0,0,0.7,0.1,0.2,0,0,0.1,0.1,0.8,0,0,0.7,0.3), nrow = 4, ncol = 4, byrow = TRUE) MCSimulation(P, 0, 250)
  • Maintainer: Andrew Robinson
  • License: GPL-3
  • Last published: 2018-05-21

Useful links