regmixMH              package:mixtools              R Documentation

_M_e_t_r_o_p_o_l_i_s-_H_a_s_t_i_n_g_s _A_l_g_o_r_i_t_h_m _f_o_r _M_i_x_t_u_r_e_s _o_f _R_e_g_r_e_s_s_i_o_n_s

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

     Return Metropolis-Hastings (M-H) algorithm output for mixtures of
     multiple regressions with arbitrarily many components.

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

     regmixMH(y, x, lambda = NULL, beta = NULL, s = NULL, k = 2,
              addintercept = TRUE, mu = NULL, sig = NULL, 
              sampsize = 1000, omega = .01, thin = 1)

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

       y: An n-vector of response values.

       x: An nxp matrix of predictors.  See 'addintercept' below.

  lambda: Initial value of mixing proportions.  Entries should sum to
          1.  This determines number of components.  If NULL, then
          'lambda' is random from uniform Dirichlet and number of
          components is determined by 'beta'.

    beta: Initial value of 'beta' parameters.  Should be a pxk matrix,
          where p is the number of columns of x and k is number of
          components. If NULL, then 'beta' has uniform standard normal
          entries.  If both 'lambda' and 'beta' are NULL, then number
          of components is determined by 's'.

       s: k-vector of standard deviations.  If NULL, then 1/'s'$^2$ has
          random standard exponential entries.  If 'lambda', 'beta',
          and 's' are NULL, then number of components determined by
          'k'.

       k: Number of components.  Ignored unless all of 'lambda',
          'beta', and 's' are NULL.

addintercept: If TRUE, a column of ones is appended to the x matrix
          before the value of p is calculated.

      mu: The prior hyperparameter of same size as 'beta'; the means of
          'beta' components.  If NULL, these are set to zero.

     sig: The prior hyperparameter of same size as 'beta'; the standard
          deviations of 'beta' components.  If NULL, these are  all set
          to five times the overall standard deviation of y.

sampsize: Size of posterior sample returned.

   omega: Multiplier of step size to control M-H acceptance rate.
          Values closer to zero result in higher acceptance rates,
          generally.

    thin: Lag between parameter vectors that will be kept.

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

     'regmixMH' returns a list of class 'mixMCMC' with items: 

       x: A nxp matrix of the predictors.

       y: A vector of the responses.

   theta: A ('sampsize'/'thin') x q matrix of MCMC-sampled q-vectors,
          where q is the total number of parameters in 'beta', 's', and
          'lambda'.

       k: The number of components.

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

     Hurn, M., Justel, A. and Robert, C. P. (2003) Estimating Mixtures
     of Regressions, _Journal  of Computational and Graphical
     Statistics_ *12(1)*, 55-79.

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

     'regcr'

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

     ## M-H algorithm for NOdata with acceptance rate about 40%.

     data(NOdata)
     attach(NOdata)
     beta<-matrix(c(1.3, -0.1, 0.6, 0.1), 2, 2)
     sigma<-c(.02, .05)
     MH.out<-regmixMH(Equivalence, NO, beta = beta, s = sigma, 
                      sampsize = 2500, omega = .0013)
     MH.out$theta[2400:2499,]

