| BNormalVar {Baldur} | R Documentation |
BNormalVar produces iid draws from the posterior density of a Bayesian Normal Variance model with a known mean and a inverse gamma prior for the data
variance.
BNormalVar(y, mu, Var0, n0, draws)
y |
n*1 Matrix with observed data points |
mu |
prior mean |
Var0 |
Prior point estimate for data variance |
n0 |
n0 number of prior observations for data variance |
draws |
Number of desired draws from the posterior density |
Makes use of the likelihood subgradient density accept/reject procedure of Nygren and Nygren (2006) in order to generate iid samples from the posterior density of a Poisson regression model with a multivariate normal prior. If the posterior density is close to multivariate normal, then the expected number of draws should be approximately equal to $(2/sqrt{pi})^{k}$.
If A=FALSE, a matrix beta. If A=TRUE, a list containing the matrix beta and a matrix Accept.:
beta |
draws*k matrix with the iid draws for the model parameters. |
Accept |
draws*1 matrix with the number of candidates for each draw that were required before acceptance in the accept/reject procedure. |
Kjell Nygren knygren@us.imshealth.com
# Example: Bayesian Poisson regression model for Seizure Data # Step 1: Read in and setup data for BPoisson Function data( Seizure,package = "Baldur") y<-as.matrix(Seizure[,1]) X<-as.matrix(Seizure[,2:7]) mu<-matrix(0,nrow=6,ncol=1) alpha<-matrix(0,nrow=236,ncol=1) P<-100*diag(6) draws<-1000 # Step 2: Set random number seed and run simulation for Bayesian Poisson Regression set.seed(666) system.time(sim<-BPoisson(y,X,alpha,mu,P,draws))