| poi.beta.laplace {SMPracticals} | R Documentation | 
Laplace Approximation for Posterior Density, Practical 11.2
Description
This function computes the Laplace approximation to the posterior density of the parameter beta in a Poisson regression model. For more details see Practical 11.2 of Davison (2003).
Usage
poi.beta.laplace(data, alpha = get.alpha(data), phi = 1, nu = 0.1, 
                 beta = seq(from = 0, to = 7, length = 1000))
Arguments
| data | A data frame with vector components  | 
| alpha | Prior value of a parameter, estimated from the data by default. | 
| phi | Prior value of a parameter. | 
| nu | Prior value of a parameter. | 
| beta | Values for which posterior density of beta should be provided. | 
Details
This is provided simply so that readers spend less time typing. It is not intended to be robust and general code.
Value
| int | Estimated integral of posterior density. | 
| conv | Did the routine for the Laplace optimization converge? | 
| x | Values of beta | 
| y | Values of posterior density | 
Author(s)
Anthony Davison (anthony.davison@epfl.ch)
References
Davison, A. C. (2003) Statistical Models. Cambridge University Press. Practical 11.2.
Examples
## From Practical 11.2:
get.alpha <- function(d)
{  # estimate alpha from data
  rho <- d$y/d$x
  n <- length(d$y)
  mean(rho)^2/( (n-1)*var(rho)/n - mean(rho)*mean(1/d$x) )
}
data(cloth)
attach(cloth)
plot(x,y)
beta <- seq(from=0,to=10,length=1000)
beta.post <- poi.beta.laplace(cloth,beta=beta,nu=1)
plot(beta.post,type="l",xlab="beta",ylab="Posterior density")
beta.post <- poi.beta.laplace(cloth,beta=beta,nu=5)
lines(beta.post,lty=2)