MCEstimation: A function to estimate the transition matrix for a discrete...

Description Usage Arguments Details Value References See Also Examples

View source: R/MCEstimation.R

Description

This function estimates the transition matrix for a discrete time Markov chain with state space 0,1,..,n given a realisation. The chain has n+1 states.

Usage

1
MCEstimation(statehist,n)

Arguments

statehist

the realisation of the chain.

n

the highest numbered state.

Details

We assume that the state space is 0,1,2...,n. n is assumed known as it cannot be reliably infered from the realisation.

Value

Returns the empirical transition matrix obtained by calculating the observed frequencies of actual transitions in the realisation.\

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

MCSimulation

Examples

1
2
3
4
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)
statehist<-MCSimulation(P, 0, 3000)
MCEstimation(statehist, 3)

Example output

Loading required package: MASS
Loading required package: lattice
          [,1]       [,2]       [,3]      [,4]
[1,] 0.4774306 0.52256944 0.00000000 0.0000000
[2,] 0.7177033 0.08133971 0.20095694 0.0000000
[3,] 0.0000000 0.08963283 0.09827214 0.8120950
[4,] 0.0000000 0.00000000 0.69601483 0.3039852

spuRs documentation built on May 2, 2019, 12:44 p.m.

Related to MCEstimation in spuRs...