MCMCpoissonChangepoint       package:MCMCpack       R Documentation

_M_a_r_k_o_v _C_h_a_i_n _M_o_n_t_e _C_a_r_l_o _f_o_r _a _P_o_i_s_s_o_n _M_u_l_t_i_p_l_e _C_h_a_n_g_e_p_o_i_n_t _M_o_d_e_l

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

     This function generates a sample from the posterior distribution
     of a Poisson model with multiple changepoints. The function uses
     the Markov chain Monte Carlo method of Chib (1998). The user
     supplies data and priors, and a sample from the posterior
     distribution is returned as an mcmc object, which can be
     subsequently analyzed with functions provided in the coda package.

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

     MCMCpoissonChangepoint(data,  m = 1, burnin = 1000, mcmc = 1000,
             thin = 1, verbose = 0, seed = NA, c0, d0, a = NULL, b = NULL,
             marginal.likelihood = c("none", "Chib95"), ...) 

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

    data: The data.

       m: The number of changepoints.

  burnin: The number of burn-in iterations for the sampler.

    mcmc: The number of MCMC iterations after burn-in.

    thin: The thinning interval used in the simulation.  The number of
          MCMC iterations must be divisible by this value.

 verbose: A switch which determines whether or not the progress of the
          sampler is printed to the screen.  If 'verbose' is greater
          than 0, the iteration number and the posterior density
          samples are printed to the screen every 'verbose'th
          iteration.

    seed: The seed for the random number generator.  If NA, current R 
          system seed is used.

      c0: c0 is the shape parameter for Gamma prior on lambda  (the
          mean).

      d0: d0 is the scale parameter for Gamma prior on lambda  (the
          mean).

       a: a is the shape1 beta prior for transition probabilities. By
          default,  the expected duration is computed and corresponding
          a and b values are assigned. The expected duration is the
          sample period divided by the number of states.

       b: b is the shape2 beta prior for transition probabilities. By
          default,  the expected duration is computed and corresponding
          a and b values are assigned. The expected duration is the
          sample period divided by the number of states.

marginal.likelihood: How should the marginal likelihood be calculated?
          Options are: 'none' in which case the marginal likelihood
          will not be calculated, and 'Chib95' in which case the method
          of Chib (1995) is used.

     ...: further arguments to be passed

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

     'MCMCpoissonChangepoint' simulates from the posterior distribution
     of a Poisson model with multiple changepoints.

     The model takes the following form:         

                Y_t ~ Poisson(lambda_i), i = 1,...,k.

     Where k is the number of states.

     We assume Gamma priors for lambda_i and Beta priors for transition
     probabilities:

                       lambda_i ~ Gamma(c0, d0)


                   p_ii ~ Beta(a, b), i = 1,...,k.

     Where k is the number of states.

     Note that no default value is provided for Gamma priors.

     The simulation in this model-fitting is performed in R.

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

     An mcmc object that contains the posterior sample.  This  object
     can be summarized by functions provided by the coda package.  The
     object contains an attribute 'prob.state' storage matrix that
     contains the probability of state_i for each period, and the 
     log-likelihood of the model ('log.like').

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

     Jong Hee Park, jhp@uchicago.edu, <URL:
     http://home.uchicago.edu/~jhp/>.

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

     Siddhartha Chib. 1995. "Marginal Likelihood from the Gibbs
     Output." _Journal of the American Statistical Association_. 90:
     1313-1321.

     Siddhartha Chib. 1998. "Estimation and comparison of multiple
     change-point models." _Journal of Econometrics_. 86: 221-241.

     Martyn Plummer, Nicky Best, Kate Cowles, and Karen Vines. 2002.
     _Output Analysis and Diagnostics for MCMC (CODA)_. <URL:
     http://www-fis.iarc.fr/coda/>.

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

     'plotPostState', 'plotPostChangepoint'

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

         ## Not run: 
         ## generate event count time series data with two breakpoints at 100 and 200
         set.seed(1973)
         n           <-  300
         true.lambda <-  c(3, 2, 4)
         y1          <-  rpois(100, true.lambda[1]) 
         y2          <-  rpois(100, true.lambda[2]) 
         y3          <-  rpois(100, true.lambda[3]) 
         y           <-  c(y1, y2, y3)
        
         ## run the example   
         model1 <-  MCMCpoissonChangepoint(y, m=1, burnin = 100, mcmc = 100, 
                     thin=1,  verbose=5, c0=3, d0=1,  marginal.likelihood =
                     c("Chib95"))  
         model2 <-  MCMCpoissonChangepoint(y, m=2, burnin = 100, mcmc = 100, 
                     thin=1, verbose=5, c0=3, d0=1,  marginal.likelihood =
                     c("Chib95"))
         model3 <-  MCMCpoissonChangepoint(y, m=3, burnin = 100, mcmc = 100,
                     thin=1, verbose=5, c0=3, d0=1,  marginal.likelihood =
                     c("Chib95"))
         model4 <-  MCMCpoissonChangepoint(y, m=4, burnin = 100, mcmc = 100,
                     thin=1, verbose=5, c0=3, d0=1,  marginal.likelihood = 
                     c("Chib95"))
                     
         ## perform model comparison  
         BayesFactor(model1, model2, model3, model4)
            
         ## Draw plots using the "right" model
         plotPostState(model2, y, m=2, legend.control=NULL) 
         plotPostChangepoint(model2, y, m=2)    
         
     ## End(Not run)

