library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.6.3
## -- Attaching packages ------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.1 v purrr 0.3.2
## v tibble 3.0.1 v dplyr 0.8.3
## v tidyr 1.0.0 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## Warning: package 'ggplot2' was built under R version 4.0.0
## Warning: package 'tibble' was built under R version 4.0.0
## -- Conflicts ---------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggpubr)
## Warning: package 'ggpubr' was built under R version 3.6.3
library(rstatix)
## Warning: package 'rstatix' was built under R version 3.6.3
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library(readxl)
weight <- read_excel("~/weight.xlsx")
Identical variances between groups indicating equal variance assumptions is satisfied
weight %>%
group_by(Treatment, Time) %>%
get_summary_stats(Weight, type = "mean_sd")
## # A tibble: 6 x 6
## Treatment Time variable n mean sd
## <chr> <chr> <chr> <dbl> <dbl> <dbl>
## 1 C Final Weight 5 0.022 0.001
## 2 C Starting Weight 5 0.022 0.001
## 3 W Final Weight 5 0.023 0.001
## 4 W Starting Weight 5 0.023 0.001
## 5 WS Final Weight 5 0.022 0.001
## 6 WS Starting Weight 5 0.022 0.001
bxp <- ggboxplot(
weight, x = "Time", y = "Weight",
color = "Treatment", palette = "jco"
)
bxp
Large p-values (p > 0.05) implies no issue in normality
weight %>%
group_by(Treatment, Time) %>%
shapiro_test(Weight)
## # A tibble: 6 x 5
## Treatment Time variable statistic p
## <chr> <chr> <chr> <dbl> <dbl>
## 1 C Final Weight 0.950 0.734
## 2 C Starting Weight 0.950 0.734
## 3 W Final Weight 0.987 0.966
## 4 W Starting Weight 0.963 0.826
## 5 WS Final Weight 0.833 0.148
## 6 WS Starting Weight 0.858 0.220
Let see if you can infer from the following result hahaha
res.aov <- anova_test(
data = weight, dv = Weight, wid = ID,
within = c(Treatment, Time)
)
get_anova_table(res.aov)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 Treatment 2 8 3.857 0.067 0.334000
## 2 Time 1 4 16.000 0.016 * 0.000432
## 3 Treatment:Time 2 8 1.000 0.410 0.000216
To check which group is different from one to another
pwc <- weight %>%
group_by(Time) %>%
pairwise_t_test(
Weight ~ Treatment, paired = TRUE,
p.adjust.method = "bonferroni"
)
pwc
## # A tibble: 6 x 11
## Time .y. group1 group2 n1 n2 statistic df p p.adj p.adj.signif
## * <chr> <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 Final Weig~ C W 5 5 -2.44 4 0.071 0.214 ns
## 2 Final Weig~ C WS 5 5 0.402 4 0.709 1 ns
## 3 Final Weig~ W WS 5 5 3.10 4 0.036 0.109 ns
## 4 Star~ Weig~ C W 5 5 -2.45 4 0.071 0.212 ns
## 5 Star~ Weig~ C WS 5 5 0.322 4 0.764 1 ns
## 6 Star~ Weig~ W WS 5 5 3.19 4 0.033 0.1 ns