Last data update: 2014.03.03

R: Bayesian Logistic Regression
BayesLogisticR Documentation

Bayesian Logistic Regression

Description

Performas Metropolis Hastings on the logistic regression model to draw sample from posterior. Uses a matched curvature Student's t candidate generating distribution with 4 degrees of freedom to give heavy tails.

Usage

BayesLogistic(y, x, steps = 1000,
                     priorMean = NULL, priorVar = NULL,
                     mleMean = NULL, mleVar,
                     startValue = NULL, randomSeed = NULL,
                     plots = FALSE)

Arguments

y

the binary response vector

x

matrix of covariates

steps

the number of steps to use in the Metropolis-Hastings updating

priorMean

the mean of the prior

priorVar

the variance of the prior

mleMean

the mean of the matched curvature likelihood

mleVar

the covariance matrix of the matched curvature likelihood

startValue

a vector of starting values for all of the regression coefficients including the intercept

randomSeed

a random seed to use for different chains

plots

Plot the time series and auto correlation functions for each of the model coefficients

Value

A list containing the following components:

beta

a data frame containing the sample of the model coefficients from the posterior distribution

mleMean

the mean of the matched curvature likelihood. This is useful if you've used a training set to estimate the value and wish to use it with another data set

mleVar

the covariance matrix of the matched curvature likelihood. See mleMean for why you'd want this

Examples

data(logisticTest.df)
BayesLogistic(logisticTest.df$y, logisticTest.df$x)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Bolstad2)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Bolstad2/BayesLogistic.Rd_%03d_medium.png", width=480, height=480)
> ### Name: BayesLogistic
> ### Title: Bayesian Logistic Regression
> ### Aliases: BayesLogistic
> 
> ### ** Examples
> 
> data(logisticTest.df)
> BayesLogistic(logisticTest.df$y, logisticTest.df$x)
      N     mean     stdev      sterr      min       q1      med       q3
b0 1000 2.401014 0.5335640 0.01687277 1.247608 2.028711 2.364800 2.733974
b1 1000 3.341709 0.6917129 0.02187388 1.712188 2.838021 3.284647 3.790258
        max
b0 4.302085
b1 5.281043
   Mean.beta StdDev.beta   Z.beta
b0  2.401014   0.5335640 4.499955
b1  3.341709   0.6917129 4.831063
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>