mchain             package:HiddenMarkov             R Documentation

_M_a_r_k_o_v _C_h_a_i_n _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Creates a Markov chain object with class '"mchain"'. It does not
     simulate data.

_U_s_a_g_e:

     mchain(x, Pi, delta, nonstat = TRUE)

_A_r_g_u_m_e_n_t_s:

       x: is a vector of length n containing the observed process, else
          it is specified as 'NULL'. This is used when there are no
          data and a process is to be simulated.

      Pi: is the m times m transition probability matrix of the Markov
          chain.

   delta: is the marginal probability distribution of the m state
          Markov chain at the first time point.

 nonstat: is logical, 'TRUE' if the homogeneous Markov chain is assumed
          to be non-stationary, default. See "Details" below.

_V_a_l_u_e:

     A 'list' object with class '"mchain"', containing the above
     arguments as named components.

_E_x_a_m_p_l_e_s:

     Pi <- matrix(c(0.8, 0.2,
                    0.3, 0.7),
                  byrow=TRUE, nrow=2)

     #    Create a Markov chain object with no data (NULL)
     x <- mchain(NULL, Pi, c(0,1))

     #    Simulate some data
     x <- simulate(x, nsim=2000)

     #   estimate transition probabilities
     estPi <- table(x$mc[-length(x$mc)], x$mc[-1])
     rowtotal <- estPi %*% matrix(1, nrow=nrow(Pi), ncol=1)
     estPi <- diag(as.vector(1/rowtotal)) %*% estPi
     print(estPi)

