Learn R Programming

SMPracticals (version 1.4-3.1)

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

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

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

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.

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

Author

Anthony Davison (anthony.davison@epfl.ch)

Details

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

References

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

Examples

Run this code
 ## 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])

Run the code above in your browser using DataLab