blim: Bayesian Linear Model

Description Usage Arguments Value Author(s) References See Also Examples

Description

Fit a univariate Bayesian linear regression model.

Usage

1
2
3
4
5
6
blim(formula, data, iter = 9999, burnin = 50, inits = NULL, thin = 0
     prior_tau = "dgamma(0.001,0.001)", prior_b = "dnorm(0,10000)",
     method = "cppbr", mtsprior = F, verbose = T, dtuning = F)

## S3 method for class 'blim'
summary(blimfit, ...)

Arguments

formula

a symbolic description of the model to be fit.

data

an optional data frame containing the variables in the model.

iter

amount of iterations for the sampler to perform and return.

burnin

burn-in amount of iterations ignored in the trace.

inits

initial values for variance and betas in a "list" format.

thin

amount of thinning to be performed

prior_tau

prior for the residual variance in the linear model, of the form dgamma(shape, scale). Only dgamma allowed!

prior_b

(vector of) priors for beta coefficients. With method = "rmhs", nonconjugate priors are allowed. Any density function works, as long as it has a d and an r method.

method

cppbr = Bayes Regression in C++, rbr = Bayes Regression in R, rgs = Bayesian Regression under Gibbs Sampling, rmhs = Bayesian Regression under Gibbs Sampling with Metropolis-Hastings step for Nonconjugate Priors

mtsprior

Boolean value indicating whether a Minimum Training Sample prior should be calculated. For use in conjuction with ANOVA & Bayes Factors for informative hypotheses

verbose

print all info in the console or not (in development!)

dtuning

dynamic tuning of the random walk Metropolis-Hastings step

Value

An object of class blimfit, including all necessary information such as summary, trace and original data.

Author(s)

Erik-Jan van Kesteren

References

Beland, S., Klugkist, I., Raiche, G. & Magis, D. (2012). A short introduction into Bayesian evaluation of informative hypotheses as an alternative to exploratory comparisons of multiple group means. Tutorials in Quantitative Methods for Psychology 8(2), p. 122-126.

Raftery, A. E. (1996). Hypothesis testing and model selection. Markov chain Monte Carlo in practice, 163-188.

See Also

cplots, aplots, BF, PPC, ICBF, DIC

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Most simple example with full functionality
fit1 <- blim(dist~speed, data=cars)

summary(fit1)

# More complex example with nonconjugate priors
fit2 <- blim(formula = dist~speed, data = cars, iter = 9999, burnin = 100,
             inits = list(var = 200, b0 = -15, b1 = 3), thin = 0,
             prior_tau = "dgamma(0.001,0.001)",
             prior_b = c("dcauchy(0,2000)", "dunif(3,4.5)"),
             method = "rmhs", dtuning = 1000)

summary(fit2)

# check convergence and autocorrelation
cplots(fit1)
aplots(fit1)

# calculate Bayes Factor of model 2 versus model 1
BF(fit2, fit1)

# perform posterior predictive check for normality of residuals
PPC(fit2)

# evaluate informative hypothesis in model 1
ICBF(fit1, model = "par[1] < par[2]", complement = TRUE)

vankesteren/blim documentation built on May 3, 2019, 4:33 p.m.