BNormalPop {Baldur}R Documentation

Bayesian Normal Population Model

Description

BNormalPop produces iid draws from the posterior density of a Bayesian Normal Mean model with a normal prior and fixed data variance.

Usage

 BNormalPop(y, mu, Var,Var0,n0,draws, Prec = FALSE,A=FALSE) 

Arguments

y n*1 Matrix with observed data points
mu Prior mean
Var Prior variance
Var0 Prior Point Estimate for variance
n0 Number of prior observations for data variance
draws Number of desired draws from the posterior density
Prec Optional logical argument with default Prec=FALSE. If argument is set to TRUE, Var is treated as the prior precision.
A Optional logical argument with default A=FALSE. If argument is set to TRUE, the function returns not only the simulated draws from the posterior density but also a vector with information related to the acceptance rate for the underlying accept/reject procedure (see below).

Details

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}$.

Value

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.

Author(s)

Kjell Nygren knygren@us.imshealth.com

Examples


 # Example: Bayesian Normal population model for PointSpread Data

     # Step 1: Read in and setup data for BNormalPop Function

     data( PointSpread,package = "Baldur")

     d<-as.matrix(PointSpread[1:672,3]-PointSpread[1:672,4]-PointSpread[1:672,5])
     mu<-0
     Var<-2^2   
     Var0<-10
     n0<-3
     draws<-1000

     # Step 2: Set random number seed and run simulation for Bayesian Poisson Regression

     set.seed(666)

     system.time(sim<-BNormalPop(d, mu, Var,Var0,n0,draws, Prec = FALSE,A=FALSE))

     mean(sim[,1])      
     mean(sim[,2])      


[Package Baldur version 0.0-0 Index]