library(readxl)
## Warning: package 'readxl' was built under R version 4.1.3
data2 <- read_excel("D:/data2.xlsx")
## New names:
## * `` -> `...3`
## * `` -> `...4`
## * `` -> `...5`
## * `` -> `...6`
## * `` -> `...7`
## * `` -> `...8`
## * `` -> `...9`
## * `` -> `...10`
## * `` -> `...11`
## * `` -> `...12`
## * `` -> `...13`
## * `` -> `...14`
## * `` -> `...15`
## * `` -> `...16`
## * `` -> `...17`
View(data2)
data2
## # A tibble: 60 x 17
## Treatment DPPH ...3 ...4 ...5 ...6 ...7 ...8 ...9 ...10 ...11 ...12
## <chr> <dbl> <lgl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <lgl> <chr>
## 1 T0+ 0.052 NA <NA> <NA> <NA> <NA> <NA> <NA> <NA> NA <NA>
## 2 T0+ 0.05 NA <NA> <NA> <NA> <NA> <NA> <NA> <NA> NA <NA>
## 3 T0+ 0.05 NA <NA> <NA> <NA> <NA> <NA> <NA> <NA> NA <NA>
## 4 T0+ 0.054 NA raw da~ <NA> <NA> <NA> <NA> <NA> <NA> NA <NA>
## 5 T0+ 0.055 NA <NA> <NA> T0+ T0- T1 T2 T3 NA <NA>
## 6 T0+ 0.054 NA <NA> R1 5.19~ 4.80~ 0.113 0.129 0.13~ NA <NA>
## 7 T0+ 0.059 NA <NA> <NA> 0.05 4.49~ 0.14~ 0.14~ 0.127 NA <NA>
## 8 T0+ 0.057 NA <NA> <NA> 0.05 4.39~ 0.161 0.16~ 0.16 NA <NA>
## 9 T0+ 0.055 NA <NA> <NA> 5.39~ 4.29~ 0.191 0.19~ 0.191 NA <NA>
## 10 T0+ 0.053 NA <NA> Mean 5.19~ 4.49~ 0.152 0.15~ 0.153 NA <NA>
## # ... with 50 more rows, and 5 more variables: ...13 <chr>, ...14 <chr>,
## # ...15 <lgl>, ...16 <chr>, ...17 <chr>
data2<-data2[, 1:2]
data2
## # A tibble: 60 x 2
## Treatment DPPH
## <chr> <dbl>
## 1 T0+ 0.052
## 2 T0+ 0.05
## 3 T0+ 0.05
## 4 T0+ 0.054
## 5 T0+ 0.055
## 6 T0+ 0.054
## 7 T0+ 0.059
## 8 T0+ 0.057
## 9 T0+ 0.055
## 10 T0+ 0.053
## # ... with 50 more rows
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.3
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.6 v purrr 0.3.4
## v tibble 3.1.7 v dplyr 1.0.9
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.1.3
## Warning: package 'tibble' was built under R version 4.1.3
## Warning: package 'tidyr' was built under R version 4.1.3
## Warning: package 'readr' was built under R version 4.1.3
## Warning: package 'purrr' was built under R version 4.1.3
## Warning: package 'dplyr' was built under R version 4.1.3
## Warning: package 'stringr' was built under R version 4.1.3
## Warning: package 'forcats' was built under R version 4.1.3
## -- 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 4.1.3
library(rstatix)
## Warning: package 'rstatix' was built under R version 4.1.3
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library(dplyr)
data2 <- data2 %>%
reorder_levels(Treatment, order = c("T0+", "T0-", "T1", "T2", "T3"))
library(dplyr)
library(rstatix)
data2%>%
group_by(Treatment)%>%
get_summary_stats(DPPH, type="common")
## # A tibble: 5 x 11
## Treatment variable n min max median iqr mean sd se ci
## <fct> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 T0+ DPPH 12 0.05 0.059 0.054 0.003 0.054 0.003 0.001 0.002
## 2 T0- DPPH 12 0.043 0.048 0.045 0.001 0.045 0.001 0 0.001
## 3 T1 DPPH 12 0.111 0.194 0.152 0.04 0.153 0.031 0.009 0.02
## 4 T2 DPPH 12 0.124 0.195 0.154 0.039 0.158 0.027 0.008 0.017
## 5 T3 DPPH 12 0.111 0.195 0.146 0.04 0.15 0.031 0.009 0.02
The mean for treatments are T0+ is 0.054, T0- is 0.045, T1 is 0.153, T2 is 0.158 and T3 is 0.150.
library(ggplot2)
ggplot(data2) +
aes(x = Treatment, y = DPPH, color = Treatment) +
geom_jitter() +
theme(legend.position = "none")
The above graph shows the plotting of data by treatment, which contains five treatments such as T0+, T0-, T1, T2, and T3.
library(tidyverse)
library(ggpubr)
library(rstatix)
ggboxplot(data2, x = "Treatment", y = "DPPH", fill="Treatment")
It clearly shows that there are differences between the five treatments T0+, T0-, T1, T2 and T3.
res_aov <- aov(DPPH ~ Treatment, data = data2)
par(mfrow = c(1, 2)) # combine plots
# histogram
hist(res_aov$residuals)
# QQ-plot
library(car)
## Warning: package 'car' was built under R version 4.1.3
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.1.3
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
## The following object is masked from 'package:purrr':
##
## some
qqPlot(res_aov$residuals,
id = FALSE # id = FALSE to remove point identification
)
The histogram resembles a bell curve as seen above, means that the residuals have a normal distribution. Moreover, the points in the QQ-plots roughly follow the straight line, with the majority of them falling within the confidence bands. This also indicates that residuals have a normal distribution.
shapiro.test(res_aov$residuals)
##
## Shapiro-Wilk normality test
##
## data: res_aov$residuals
## W = 0.93435, p-value = 0.003052
The Shapiro-Wilk p-value = 0.003052 on the residuals is less than the usual significance level of 0.05. Thus, we reject the hypothesis that residuals have a normal distribution.
library(car)
leveneTest(DPPH ~ Treatment,
data = data2)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 4 16.451 6.403e-09 ***
## 55
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The p-value is greater than the 0.05 level of significance.
res.kruskal <- data2 %>% kruskal_test(DPPH ~ Treatment)
res.kruskal
## # A tibble: 1 x 6
## .y. n statistic df p method
## * <chr> <int> <dbl> <int> <dbl> <chr>
## 1 DPPH 60 45.8 4 0.00000000277 Kruskal-Wallis
There was a significant difference between the five treatments by the p-value.
The effect size values normally interpreted as 0.01- < 0.06 (small effect), 0.06 â < 0.14 (moderate effect) and >= 0.14 (large effect).
data2 %>% kruskal_effsize(DPPH ~ Treatment)
## # A tibble: 1 x 5
## .y. n effsize method magnitude
## * <chr> <int> <dbl> <chr> <ord>
## 1 DPPH 60 0.759 eta2[H] large
The size of the effect is substantial. This means that even with a small sample size, we can easily identify significant differences.
res1<- data2 %>%
dunn_test(DPPH ~ Treatment, p.adjust.method = "bonferroni")
res1
## # A tibble: 10 x 9
## .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif
## * <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <chr>
## 1 DPPH T0+ T0- 12 12 -1.68 0.0922 9.22e-1 ns
## 2 DPPH T0+ T1 12 12 3.34 0.000841 8.41e-3 **
## 3 DPPH T0+ T2 12 12 3.69 0.000225 2.25e-3 **
## 4 DPPH T0+ T3 12 12 3.08 0.00210 2.10e-2 *
## 5 DPPH T0- T1 12 12 5.02 0.000000509 5.09e-6 ****
## 6 DPPH T0- T2 12 12 5.37 0.0000000771 7.71e-7 ****
## 7 DPPH T0- T3 12 12 4.76 0.00000194 1.94e-5 ****
## 8 DPPH T1 T2 12 12 0.351 0.726 1 e+0 ns
## 9 DPPH T1 T3 12 12 -0.263 0.792 1 e+0 ns
## 10 DPPH T2 T3 12 12 -0.614 0.539 1 e+0 ns
Based on the pairwise comparison, there is a significant difference observed in T0+, T0-, T1, T2, and T3.
res1 <- res1 %>% add_xy_position(x = "Treatment")
ggboxplot(data2, x = "Treatment", y = "DPPH") +
stat_pvalue_manual(res1, hide.ns = TRUE) +
labs(
subtitle = get_test_label(res.kruskal, detailed = TRUE),
caption = get_pwc_label(res1))