BayesReg: Bayesian linear regression output

Description Usage Arguments Value Examples

View source: R/BayesReg.R

Description

This function contains the R code for the implementation of Zellner's G-prior analysis of the regression model as described in Chapter 3. The purpose of BayesRef is dual: first, this R function shows how easily automated this approach can be. Second, it also illustrates how it is possible to get exactly the same type of output as the standard R function summary(lm(y~X)). In particular, it calculates the Bayes factors for variable selection, more precisely single variable exclusion.

Usage

1
BayesReg(y, X, g = length(y), betatilde = rep(0, dim(X)[2]), prt = TRUE)

Arguments

y

response variable

X

matrix of regressors

g

constant g for the G-prior

betatilde

prior mean on beta

prt

boolean variable for printing out the standard output

Value

postmeancoeff

posterior mean of the regression coefficients

postsqrtcoeff

posterior standard deviation of the regression coefficients

log10bf

log-Bayes factors against the full model

postmeansigma2

posterior mean of the variance of the model

postvarsigma2

posterior variance of the variance of the model

Examples

1
2

Example output

Loading required package: MASS
Loading required package: mnormt
Loading required package: gplots

Attaching package: 'gplots'

The following object is masked from 'package:stats':

    lowess

Loading required package: combinat

Attaching package: 'combinat'

The following object is masked from 'package:utils':

    combn


          PostMean PostStError Log10bf EvidAgaH0
Intercept   3.4878      0.0304                  
x1          1.0225      0.0303     Inf    (****)


Posterior Mean of Sigma2: 0.2513
Posterior StError of Sigma2: 0.3561

$postmeancoeff
[1] 3.487783 1.022509

$postsqrtcoeff
[1] 0.03039825 0.03034252

$log10bf
     [,1]
[1,]  Inf

$postmeansigma2
[1] 0.2513425

$postvarsigma2
[1] 0.1268176

bayess documentation built on May 29, 2017, 9:39 p.m.

Related to BayesReg in bayess...