HMMFit                 package:RHmm                 R Documentation

_F_i_t _a _H_i_d_d_e_n _M_a_r_k_o_v _M_o_d_e_l

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

     This function returns an HMMFitClass object which contains the
     results of the Baum-Welch algorithm for the user's data

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

         HMMFit(obs, dis="NORMAL", nStates=,  ...)
         HMMFit(obs, dis="DISCRETE", nStates=,  ...)
         HMMFit(obs, dis="MIXTURE", nStates=, nMixt=, ...)

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

     obs: A vector, a matrix, a data frame, a list of vectors or a list
          of matrices of observations. See section *obs parameter*.

     dis: Distribution name = 'NORMAL', 'DISCRETE' or 'MIXTURE'.
          Default 'NORMAL'.

 nStates: Number of hidden states. Default 2.

   nMixt: Number of mixtures of normal distributions if dis ='MIXTURE'

     ...: optional parameter:

     _c_o_n_t_r_o_l A list of control parameters for the Baum-Welch algorithm.
          See *control parameter* 

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

     a HMMFitClass object: 

     HMM: A HMMClass object with the fitted values of the model

     LLH: log-likelihood

     BIC: BIC criterium

   nIter: Number of iterations of the Baum-Welch algorithm

relVariation: last relative variation of the LLH function

asymptVar: an HMMClass object with asymtotic variance of the
          parameters. See *asymptotic variance*

    call: The call object of the function call

_o_b_s _p_a_r_a_m_e_t_e_r:

     If you fit the model with only one sample, obs is either a vector
     (for univariate distributions) or a matrix (for multivariate
     distributions) or a data frame. In the two last cases, the number
     of columns of obs defines the dimension of observations.

     If you fit the model with more than one sample, obs is a list of
     samples. Each element of obs is then a vector (for univariate
     distributions) or a matrix (for multivariate distributions). The
     samples do not need to have the same length.

     For discrete distributions, obs can be a vector (or a list of
     vectors) of any type of R factor objects.

_c_o_n_t_r_o_l _p_a_r_a_m_e_t_e_r:

_i_n_i_t Kind of initialisation ='KMEANS' (for univariate or multivariate
     normal distributions), 'RANDOM' or 'USER'. Default 'RANDOM', see
     *Random Initialization*

_i_t_e_r Maximum number of iterations for the Baum-Welch algorithm. Default
     500

_t_o_l Tolerance of the relative log-likehood augmentation. Default 1e-6

_v_e_r_b_o_s_e =0, no details, =1 iterations are displayed. Default 0

_n_I_n_i_t Number of random initialisations. Default 5

_n_I_t_e_r_I_n_i_t Number of maximum iterations of the Baum-Welch algorithm in
     the random initialisation phase. Default 5

_i_n_i_t_P_o_i_n_t An HMMClass object used to initialize the parameters of the
     Baum-Welch algorithm. Default NULL.
      if initPoint != NULL, init is set to "USER"

_R_a_n_d_o_m _i_n_i_t_i_a_l_i_z_a_t_i_o_n:

     'initProb' and 'transMat' parameters are uniformly drawn.

      For univariate normal distributions, empirical mean m and
     variance s^2 of all the samples are computed. Then for every
     states, an initial value of the 'mean' parameter is uniformly
     drawn between m - 3s and m + 3s and an initial value of the 'var'
     parameter is uniformly drawn between 0.5 s^2 and 3 s^2. 
      For multivariate normal distributions, the same procedure is
     applied for each component of the mean vectors. The initial
     covariance matrix is diagonal, and each initial variance is
     computed as for univariate models. 
      For mixtures of univariate normal distributions, initial values
     for 'mean' and 'var' parameters are computed the same way than for
     normal distributions. The initial value of 'proportion' parameter
     is uniformly drawn. 
      For mixtures of multivariate normal distributions, the same
     procedure is applied for each component of the mean vectors,  all
     the covariance matrices are diagonal and each initial variance is
     computed as for univariate models. The initial value  of
     'proportion' parameter is also uniformly drawn.  
      For discrete distributions, the initial values of 'proba'
     parameters are uniformly drawn. 
      Of course, the initial values of the parameters 'initProba',
     'proba', 'proportion' and 'transMat' are standardized to ensure
     that they can represent probabilities vectors or transition
     matrices.

_a_s_y_m_p_t_o_t_i_c _v_a_r_i_a_n_c_e:

     The asymptotic variance of estimates is computed using finite
     difference approximation.
      The summary and print.summary methods display the results.

_R_e_f_e_r_e_n_c_e_s:

     Jeff A. Bilmes (1997) _ A Gentle Tutorial of the EM Algorithm and
     its Application to Parameter Estimation for Gaussian Mixture and
     Hidden Markov Models_ <URL:
     http://ssli.ee.washington.edu/people/bilmes/mypapers/em.ps.gz>

     Ingmar Visser, Maartje E. J. Raijmakers and Peter C. M. Molenaar
     (2000) _Confidence intervals for hidden Markov model parameters_,
     British Journal of Mathematical and Statistical Psychology, 53,
     317-327.

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

         data(geyser)
         obs <- geyser$duration
         #Fits an 2 states gaussian model for geyser duration
         ResGeyser1 <- HMMFit(obs)
         # fit a 3 states gaussian HMM for geyser duration
         # with iterations printing and kmeans initialization
         ResGeyser2 <- HMMFit(obs, nStates=3, paramBW=list(verbose=1, init="KMEANS"))
         # fit a 2 states of a mixture of 3 normal distributions
         # for data_mixture
         data(data_mixture)
         ResMixture <- HMMFit(data_mixture, nStates=2, nMixt=3, dis="MIXTURE")
         summary(ResMixture)
         # geyser data - 3 states HMM with bivariate normal distribution
         ResGeyser<-HMMFit(obs=as.matrix(geyser), nStates=3)
         # multiple samples discrete observations
         data(weather)
         ResDiscrete <- HMMFit(obs=weather, nStates=3, dis="DISCRETE")

