library(knitr)
opts_chunk$set(message=F)
opts_chunk$set(warning=F)
library(ggplot2)
library(dplyr)
theme_set(theme_bw())

For this example, we'll be comparing the weights of chicks on different diets.

data("chickwts")

chickwts %>% 
    ggplot(aes(x=feed, y=weight)) +
    stat_summary(fun.data="mean_cl_boot", col="skyblue", size=1) +
    geom_point(shape=1)

# Focus on comparing casein and linseed
casein <- chickwts %>% 
    filter(feed=="casein") %>%
    select(weight)
linseed <- chickwts %>% 
    filter(feed=="linseed") %>%
    select(weight)

We're replacing the following t-test with bayesian estimation.

t.test(casein, linseed, paired=F)

Run bestan

library(bestan)
fit <- bestan(casein[,1], linseed[,1])

Plot results. Note that in the current version (0.1), it simply spits out histograms, and no interval summaries.

bestan_plot(fit)

All rstan functions can be used.

rstan:::print.stanfit(fit, probs=c(.025, .5, .975))


mvuorre/bestan documentation built on May 23, 2019, 10:55 a.m.