markov: Classic Markov Probability Matrix

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/markov.R

Description

A function to estimate probability or transition matrices.

Usage

1
2
3
4
5
6
7
markov(data, stateVars, n.states, stateNames=NULL,
discretized=FALSE, pool=FALSE, std=FALSE,
balanced=TRUE)

initState(data, stateVars, n.states, stateNames=NULL,
discretized=FALSE, pool=FALSE, std=FALSE,
balanced=TRUE)

Arguments

data

A data frame arranged in such a way that there is one row per observation, and one column recording the state of each observation, with as many columns as time periods.

stateVars

The columns in the data frame which describe the temporal evolution of the variable of interest (one column per year).

n.states

The number of states to be assumed for the Markov process (equals the number of rows and columns of the estimated transition matrix).

stateNames

The names to be given to the states of the Markov process.

discretized

Is the data already discretized? (Default: discretized=FALSE). If the user has a data set which registers a finite number of states through time, discretized should be set as TRUE. If the data set comprises a continous variable, data should be discretized, whereby discretized should be set as FALSE.

pool

If pool=TRUE, the data is pooled, so that a unique set of time-invariant breaks is determined. If pool=FALSE (the default), each variable is discretized using time-variant breaks (i.e. a different set of breaks for each time period). If pool=TRUE, it is recommended to set std=TRUE.

std

Should the data be standardized? If std=TRUE, the data is standardized by each period by the mean.

balanced

Is the panel data set balanced? If the panel is unbalanced, then set balanced=FALSE to handle missing values.

Details

The function 'markov' returns a classic transition markov matrix. The function 'initStates' retrieves the initial states of the markov process

Value

An object of class 'markov' containing the following items:

t

A matrix of transition counts.

p

A probability matrix. The rows of this matrix sum to one.

Note

If pool=TRUE, it is recommended to set std=TRUE.

Author(s)

Osmar Leandro Loaiza Quintero

References

Restrepo, Patricia; Franco, Rosa and Munoz, Luz (2010). Algebra Lineal con Aplicaciones, Universidad Nacional de Colombia, Medellin.

See Also

steadyState, mfpt, spMarkov

Examples

1
2
3
4
5
6
data(usinc)
stateVars<-names(usinc@data[,7:87])
stateNames<-c('Poor','Lower','Middle','Upper','Rich')

M<-markov(usinc@data, stateVars=stateVars,n.states=5,stateNames=stateNames)
M$t;M$p

spdyn documentation built on Feb. 6, 2021, 3 a.m.