| bayes.lm.ref {spBayes} | R Documentation |
Given an lm object, the bayes.lm.ref function fits a
simple Bayesian linear model with reference (non-informative) priors.
bayes.lm.ref(lm.obj, n.samples)
lm.obj |
an object returned by lm. |
n.samples |
the number of posterior samples to collect. |
See page 355 in Gelman et al. (2004).
A CODA mcmc matrix object with columns corresponding to each
parameter and posterior samples held in the rows.
Sudipto Banerjee sudiptob@biostat.umn.edu,
Andrew O. Finley afinley@stat.umn.edu,
Bradley P. Carlin brad@biostat.umn.edu.
Gelman, A., Carlin, J.B., Stern, H.S., and Rubin, D.B. (2004). Bayesian Data Analysis. 2nd ed. Boca Raton, FL: Chapman and Hall/CRC Press.
## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
## Page 9: Plant Weight Data.
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
summary(lm.D90 <- lm(weight ~ group - 1))
##Now with bayes.lm.ref
fit <- bayes.lm.ref(lm.D90, 1000)
summary(fit)
plot(fit)