sp                package:hmm.discnp                R Documentation

_C_a_l_c_u_l_a_t_e _t_h_e _c_o_n_d_i_t_i_o_n_a_l _s_t_a_t_e _p_r_o_b_a_b_i_l_i_t_i_e_s.

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

     Returns the probabilities that the underlying hidden state is
     equal to each of the possible state values, at each time point,
     given the observation sequence. Also can return the fitted
     conditional means, if requested, given that the observations are
     numeric.

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

     sp(y, object = NULL, tpm, Rho, ispd=NULL, means = FALSE)

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

       y: The observations on the basis of which the probabilities of
          the underlying hidden states are to be calculated.  May be a
          sequence of observations, or a list each component of which
          constitutes a (replicate) sequence of observations.  If 'y'
          is missing it is set equal to the 'y' component of 'object',
          given that that object and that component exist.  Otherwise
          an error is given. 

  object: An object of class 'hmm.discnp' as returned by 'hmm()'. 

     tpm: The transition probability matrix for the underlying hidden
          Markov chain.  Ignored if 'object' is not 'NULL'. Ignored if
          'object' is not 'NULL' (in which case 'tpm' is extracted from
          'object'). 

     Rho: The matrix of probabilities specifying the distribution of
          the observations, given the underlying state.  The rows of
          this matrix correspond to the possible values of the
          observations, the columns to the states.  Ignored if 'object'
          is not 'NULL' (in which case 'Rho' is extracted from
          'object'). 

    ispd: Vector specifying the initial state probability distribution
          of the underlying hidden Markov chain. Ignored if 'object' is
          not 'NULL' (in which case 'ispd' is extracted from 'object').
          If both 'object' and 'ispd' are NULL then 'ispd' is
          calculated to be the stationary distribution of the chain as
          determined by 'tpm'. 

   means: A logical scalar; if 'means' is 'TRUE' then the conditional
          expected value of the observations (given the observation
          sequence) is calculated at each time point. If 'means' is
          'TRUE' and the observation values are not numeric, then an
          error is given. 

_D_e_t_a_i_l_s:

     Then conditional mean value at time t is calculated as 

                        SUM_k gamma_t(k)*mu_k

     where gamma_t(k) is the conditional probability (given the
     observations) that the hidden Markov chain is in state k at time
     t, and mu_k is the expected value of an observation given that the
     chain is in state k.

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

     If 'means' is 'TRUE' then the returned value is a list with
     components 

   probs: The conditional probabilities of the states at each time
          point.

   means: The conditional expectations of the observations at each time
          point.


     Otherwise the returned value consists of 'probs' as described
     above.

     If there is a single vector of observations 'y' then 'probs' is a
     matrix whose rows correspond to the states of the hidden Markov
     chain, and whose columns correspond to the observation times.  If
     the observations consist of a list of observation vectors, then
     'probs' is a list of such matrices, one for each vector of
     observations.

     Likewise for the 'means' component of the list returned when the
     argument 'means' is 'TRUE'.

_A_u_t_h_o_r(_s):

     Rolf Turner r.turner@auckland.ac.nz
      <URL: http://www.math.unb.ca/~rolf>

_S_e_e _A_l_s_o:

     'hmm()', 'mps()', 'viterbi()', 'pr()', 'fitted.hmm.discnp()'

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

     P <- matrix(c(0.7,0.3,0.1,0.9),2,2,byrow=TRUE)
     R <- matrix(c(0.5,0,0.1,0.1,0.3,
                   0.1,0.1,0,0.3,0.5),5,2)
     set.seed(42)
     y.num   <- sim.hmm(rep(300,20),P,R)
     fit.num <- hmm(y.num,K=2,verb=TRUE)
     cpe1    <- sp(object=fit.num,means=TRUE)    # Using the estimated parameters.
     cpe2    <- sp(y.num,tpm=P,Rho=R,means=TRUE) # Using the ``true'' parameters.

