summary.bayes
By tholscla on Sat, 11/02/2013 - 20:31
This is like the summary.lm() except Bayesian statistics reports different metrics like probability intervals (PIs) for the coefficients.
### input: lm.bayes object
### output: a table with means and 95% PIs for the parameters b0,b1,...,bp, sigma^2 (one row each). It returns (lower_bound, mean, upper_bound) where lower and upper bound are the 95% PIs.
summary.bayes=function(reg2)
{ N=nrow(reg2)
k=(ncol(reg2))
summ=matrix(0,k,3)
for(i in 1:k)
{ summ[i,]= c(sort(reg2[,i])[.025*N], mean(reg2[,i]), sort(reg2[,i])[.975*N])
}
summ
}
### Example: use lm.bayes to create a regression object: "reg2"
summary.bayes(reg2)