https://github.com/cran/RcppDist
Tip revision: 284f8657fb9540fadcc77f069db6a626bebf89b0 authored by JB Duck-Mayr on 28 October 2018, 21:50:09 UTC
version 0.1.1
version 0.1.1
Tip revision: 284f865
test_bayeslm.R
context("bayeslm")
test_that('Example estimates are as expected', {
set.seed(123)
n <- 30
x <- cbind(1, matrix(rnorm(n*3), ncol = 3))
beta <- matrix(c(10, 2, -1, 3), nrow = 4)
y <- x %*% beta + rnorm(n)
freqmod <- lm(y ~ x[ , -1])
bayesmod <- bayeslm(y, x, 10000)
beta_means <- apply(bayesmod$beta_draws, 2, mean)
sigma_mean <- mean(bayesmod$sigma_draws)
expect_equivalent(beta_means, coef(freqmod), tolerance = 0.01)
expect_equivalent(sigma_mean, sigma(freqmod), tolerance = 0.04)
})
