# \donttest{
# EXAMPLE 1. One-sample t test
ttest1 <- t_test(therapeutic, mu = 5)
print(ttest1)
# confirmatory Bayesian one sample t test
BF1 <- BF(ttest1, hypothesis = "mu = 5")
summary(BF1)
# exploratory Bayesian one sample t test
BF(ttest1)
# EXAMPLE 2. ANOVA
aov1 <- aov(price ~ anchor * motivation,data = tvprices)
BF1 <- BF(aov1, hypothesis = "anchorrounded = motivationlow;
anchorrounded < motivationlow")
summary(BF1)
# EXAMPLE 3. linear regression
lm1 <- lm(mpg ~ cyl + hp + wt, data = mtcars)
BF(lm1, hypothesis = "wt < cyl < hp = 0")
# EXAMPLE 4. Logistic regression
fit <- glm(sent ~ ztrust + zfWHR + zAfro + glasses + attract + maturity +
tattoos, family = binomial(), data = wilson)
BF1 <- BF(fit, hypothesis = "ztrust > zfWHR > 0;
ztrust > 0 & zfWHR = 0")
summary(BF1)
# EXAMPLE 5. Correlation analysis
set.seed(123)
cor1 <- cor_test(memory[1:20,c(1,2,6)])
BF1 <- BF(cor1)
summary(BF1)
BF2 <- BF(cor1, hypothesis = "Rat_with_Im > Rat_with_Del > 0;
Rat_with_Im = Rat_with_Del = 0")
summary(BF2)
# correlations can also be computed between continuous/ordinal variables
memory_test <- memory[1:20,c(1,2,6)]
memory_test[,3] <- as.ordered(memory_test[,3])
cor2 <- cor_test(memory_test)
BF(cor2)
# EXAMPLE 6. Bayes factor testing on a named vector
# A Poisson regression model is used to illustrate the computation
# of Bayes factors with a named vector as input
poisson1 <- glm(formula = breaks ~ wool + tension,
data = datasets::warpbreaks, family = poisson)
# extract estimates, error covariance matrix, and sample size:
estimates <- poisson1$coefficients
covmatrix <- vcov(poisson1)
samplesize <- nobs(poisson1)
# compute Bayes factors on equal/order constrained hypotheses on coefficients
BF1 <- BF(estimates, Sigma = covmatrix, n = samplesize, hypothesis =
"woolB > tensionM > tensionH; woolB = tensionM = tensionH")
summary(BF1)
# }
Run the code above in your browser using DataLab