poi.gibbs: Gibbs Sampler for Hierarchical Poisson Model, Practical 11.5

Description Usage Arguments Details Value Author(s) References Examples

Description

This function implements Gibbs sampling for the hierarchical Poisson model described in Example 11.19 and Practical 11.5 of Davison (2003), which should be consulted for more details.

Usage

1
poi.gibbs(d, alpha, gamma, delta, I, S)

Arguments

d

A data frame with vector components y containing the numbers of counts and x the period for which the n Poisson processes are observed.

alpha

A hyperparameter of the prior density

gamma

A hyperparameter of the prior density

delta

A hyperparameter of the prior density

I

Number of iterations for which sampler is run

S

Number of independent replicates of sampler

Details

This is provided simply so that readers spend less time typing. It is not intended to be robust and general code.

Value

An I x S x (n+1) array containing the successive iterations of the samplers, for the I iterations, S independent replicates, and n rate parameters plus the parameter beta of the prior distribution.

Author(s)

Anthony Davison (anthony.davison@epfl.ch)

References

Davison, A. C. (2003) Statistical Models. Cambridge University Press. Practical 11.5.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 ## From Practical 11.5:
data(pumps)
system.time( pumps.sim <- poi.gibbs(pumps, alpha=1.8, delta=0.1, gamma=1, 
             I=1000, S=5) )
par(mfrow=c(2,3))
plot.ts(pumps.sim[,1,1])
acf(pumps.sim[,1,1])
pacf(pumps.sim[,1,1])
plot.ts(pumps.sim[,1,11])
acf(pumps.sim[,1,11])
pacf(pumps.sim[,1,11])

Example output

Loading required package: ellipse
   user  system elapsed 
  0.155   0.004   0.167 

SMPracticals documentation built on May 2, 2019, 11:12 a.m.