############################################################################################ # # Poisson data with change point and conditionally conjugate Gamma priors: # # Model: yi |lambda,m ~ Poi(lambda) i=1,...,m # yi |phi,m ~ Poi(phi) i=m+1,...,n # # Prior: m ~ U{1,...,n} # lambda ~ Gamma(alpha,beta) # phi ~ Gamma(gamma,delta) # # # Data: Real data application: Counts of coal mining disasters in # Great Britain by year from 1851 to 1962. # # 4 5 4 1 0 4 3 4 0 6 3 3 4 0 2 6 3 3 5 4 5 3 1 4 4 1 5 5 3 # 4 2 5 2 2 3 4 2 1 3 2 2 1 1 1 1 3 0 0 1 0 1 1 0 0 3 1 0 3 # 2 2 0 1 1 1 0 1 0 1 0 0 0 2 1 0 0 0 1 1 0 2 3 3 1 1 2 1 1 # 1 1 2 4 2 0 0 0 1 4 0 0 0 1 0 0 0 0 0 1 0 0 1 0 1 # ############################################################################################ # # HEDIBERT FREITAS LOPES # Associate Professor of Econometrics and Statistics # The University of Chicago Booth School of Business # 5807 South Woodlawn Avenue # Chicago, Illinois, 60637 # Email : hlopes@ChicagoGSB.edu # URL: http://faculty.chicagobooth.edu/hedibert.lopes/research/ # ############################################################################################ # full conditional of m full = function(m,lambda,phi,y,n,alpha,beta,gamma,delta){ lambda^(alpha-1+ifelse(m>1,sum(y[1:m]),0))*exp(-(beta+m)*lambda)*phi^(gamma-1+ifelse(m1,sum(y[1:m]),0)+alpha,m+beta) phi = rgamma(1,ifelse(m1,sum(y[1:m]),0)+alpha b = m+beta c = ifelse(m