posterior_nig: Bayesian Linear Regression with Normal-Inverse Gamma prior.

Description Usage Arguments Value Author(s) References Examples

View source: R/Bayesian_Linear_Regression.R

Description

Bayesian Linear Regression with Normal-Inverse Gamma prior.

Usage

1
posterior_nig(formula, data, m, M, a, b)

Arguments

formula

A string fromula.

data

A data frame with your data including response.

m

A matrix with the hyperparameter of the mean for the normal distribution.

M

A matrix with the hyperparameter of the covariance for the normal distribution.

a

A number of hyperparameter for the gamma distribution.

b

A number of hyperparameter for the gamma distribution.

Value

A list with the estimated coefficients and standard deviations of the model from the Classical and Bayesian approach

Author(s)

Camilo Gonzalez <cigonzalez2@uc.cl>

References

L. Fahrmeir, T. Kneib, S. Lang, and B. Marx, Regression: Models, Methods and Applications. Springer-Verlag GmbH, 2013.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Noninformative Prior (same results Bayesian and Classical Linear Regression)
m <- matrix(0, nrow = 2, ncol = 1)
M <- diag(10000000000000000000, 2)
a <- 0.000000000000000000000000001
b <- 0.000000000000000000000000001
test <- posterior_nig(
formula = 'dist ~ speed', 
data = cars,
m = m,
M = M,
a = a,
b = b 
)
test$classic_coef
test$classic_sigma
test$bayesian_coef
test$bayesian_sigma

cigonzalez2/BLR documentation built on Oct. 25, 2020, 4:58 p.m.