Learn R Programming

Bolstad (version 0.2-41)

poisdp: Poisson sampling with a discrete prior

Description

Evaluates and plots the posterior density for \(\mu\), the mean rate of occurance in a Poisson process and a discrete prior on \(\mu\)

Usage

poisdp(y.obs, mu, mu.prior, ...)

Arguments

y.obs

a random sample from a Poisson distribution.

mu

a vector of possibilities for the mean rate of occurance of an event over a finite period of space or time.

mu.prior

the associated prior probability mass.

additional arguments that are passed to Bolstad.control

Value

A list will be returned with the following components:

likelihood

the scaled likelihood function for \(\mu\) given \(y_{obs}\)

posterior

the posterior probability of \(\mu\) given \(y_{obs}\)

mu

the vector of possible \(\mu\) values used in the prior

mu.prior

the associated probability mass for the values in \(\mu\)

See Also

poisgamp poisgcp

Examples

Run this code
# NOT RUN {
## simplest call with an observation of 4 and a uniform prior on the
## values mu = 1,2,3
poisdp(4,1:3,c(1,1,1)/3)

##  Same as the previous example but a non-uniform discrete prior
mu = 1:3
mu.prior = c(0.3,0.4,0.3)
poisdp(4,mu=mu,mu.prior=mu.prior)

##  Same as the previous example but a non-uniform discrete prior
mu = seq(0.5,9.5,by=0.05)
mu.prior = runif(length(mu))
mu.prior = sort(mu.prior/sum(mu.prior))
poisdp(4,mu=mu,mu.prior=mu.prior)

## A random sample of 50 observations from a Poisson distribution with
## parameter mu = 3 and  non-uniform prior
y.obs = rpois(50,3)
mu = c(1:5)
mu.prior = c(0.1,0.1,0.05,0.25,0.5)
results = poisdp(y.obs, mu, mu.prior)

##  Same as the previous example but a non-uniform discrete prior
mu = seq(0.5,5.5,by=0.05)
mu.prior = runif(length(mu))
mu.prior = sort(mu.prior/sum(mu.prior))
y.obs = rpois(50,3)
poisdp(y.obs,mu=mu,mu.prior=mu.prior)


# }

Run the code above in your browser using DataLab