BLogit {Baldur}R Documentation

Bayesian logit model

Description

BLogit produces iid draws from the posterior density of a Bayesian Logit model with a multivariate normal prior.

Usage

BLogit(y,X,alpha,mu,P,draws,Prec=FALSE,A=FALSE)

Arguments

y n*2 Matrix with counts for the two categories.
X n*k Matrix with the values for the independent variables.
alpha constant vector added to X*beta.
mu k*1 Prior mean vector.
P k*k Prior variance-covariance matrix (must be Positive Definite). If Prec=TRUE, this is instead treated as the prior precision matrix (inverse variance-covariance matrix).
draws Numeric variable containing number of desired draws from the posterior density. Non-integer values are rounded to the nearest integer.
Prec Optional logical argument with default Prec=FALSE. If argument is set to TRUE, the matrix P is treated as a prior precision matrix.
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 Bayesian Logit 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

References

Nygren and Nygren (2006) Likelihood Subgradient Densities. Upcoming textit{Journal of American Statistical Association}

Examples

              

# Bayesian Logit Model for Crowders Seed Data 

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

data( Seeds,package = "Baldur")

y<-as.matrix(Seeds[,2:3])

X<-as.matrix(Seeds[,4:7])

mu<-matrix(0,nrow=4,ncol=1)
alpha<-matrix(0,nrow=21,ncol=1)
P<-100*diag(4)
draws<-1000

# Step 2: Set random number seed and run simulation for Bayesian Logit Model

set.seed(666)
system.time(sim<-BLogit(y,X,alpha,mu,P,draws))


[Package Baldur version 0.0-0 Index]