Overview

This analysis illustrates how to fit and report a model where the dependent is continuous, and the predictor is a group factor with two levels (e.g., Group A and Group B). That is, this is the bayesian equivalent for an independent t-test that is used in frequentist analysis.

Here is an example of what you get:

Untitled

Figure X. Group effect. (A) Scatter plot showing the observations for each group. Regression lines are posterior samples denoting uncertainty in the group effect. Dots represent group expected values with 90% certainty. (B) Posterior distribution for the group effect, including the posterior median and a 90% credible interval.

Reporting (all valid options):

There is a 99.9% probability that, in the population, the average score of group A is between 1 to 2 times larger compared to group B

There is a 99.81% probability that, in the population, the average of group A is larger in 4 to 8 points compared to the average of group B.

There is a 90% probability that, in the population, the average of group A is larger in 5.66 to 7.37 points compared to the average of group A.

We found a statistically significant results suggesting that in the population the average score of group A is larger compared to group B (t(149) = -5.36, p<.001).

Last updated 05-May-2024

Data

You can simulate data using the generative model:

#### Generating data for y ~ b0 + b1*group ----
# True parameters
b0          = 10  # Mean for group_A
b1          = 5   # Mean group_B - mean group_A
sigma       = 3   # Noise
N           = 100 # Total number of participants

# Generate data
group_dummy = sample(c(0,1), N, replace = TRUE, prob = c(0.5, 0.5))
group       = factor(group_dummy,levels = c(0,1), labels = c("group_A","group_B"))
y           = rnorm(N, mean = b0 + b1*group_dummy, sigma)

# Creating a dataframe
df = data.frame(group, y)

# Viewing the first few rows of the dataframe
head(df)