This function contains the R code for the implementation of Zellner's 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.
BayesReg(y, X, g = length(y), betatilde = rep(0, dim(X)[2]), prt = TRUE)
posterior mean of the regression coefficients
posterior standard deviation of the regression coefficients
log-Bayes factors against the full model
posterior mean of the variance of the model
posterior variance of the variance of the model
response variable
matrix of regressors
constant g for the
prior mean on
boolean variable for printing out the standard output
data(faithful)
BayesReg(faithful[,1],faithful[,2])
Run the code above in your browser using DataLab