library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(ggpubr)
library(rstatix)
## 
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
## 
##     filter
library(readxl)

dat <- read_excel("/Users/riku/Documents/zxy.xlsx", sheet = "noab")


dat$id <- as.factor(dat$id)
dat$label_1st <- as.factor(dat$label_1st)
#dat$AB <- as.factor(dat$AB)
#dat$label_1st <- as.factor(dat$label_1st)
#dat$score <- as.numeric(dat$score)
dat$naka_2nd <- as.numeric(dat$naka_2nd)


dat$irt_3level <- as.factor(dat$irt_3level)
dat$irt_3level <- ordered(dat$irt_3level, levels = c("L", "M", "H"))


dat_p <- dat %>% filter(dat$label_1st == "p")
dat_t <- dat %>% filter(dat$label_1st == "t")



hist(dat_p$diff_atama)

hist(dat_p$diff_heiban)

hist(dat_p$diff_naka)

hist(dat_p$diff_o)

hist(dat_t$diff_atama)

hist(dat_t$diff_heiban)

hist(dat_t$diff_naka)

hist(dat_t$diff_o)

hist(dat_p$diff_total)

hist(dat_t$diff_total)

#########
library(hrbrthemes)
## NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
##       Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
##       if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow
##### PS L------
p_a_l <- dat_p %>% filter(dat_p$irt_3level == "L") %>% 
  ggplot( aes(x=diff_atama)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#EB455F") +  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of atama (PS, Lower)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


p_h_l <- dat_p %>% filter(dat_p$irt_3level == "L") %>% 
  ggplot( aes(x=diff_heiban)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#FCFFE7") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of heiban (PS, Lower)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


p_n_l <- dat_p %>% filter(dat_p$irt_3level == "L") %>% 
  ggplot( aes(x=diff_naka)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#BAD7E9") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of naka (PS, Lower)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

p_o_l <- dat_p %>% filter(dat_p$irt_3level == "L") %>% 
  ggplot( aes(x=diff_o)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#2B3467") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of o (PS, Lower)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

##### PS M ------
p_a_m <- dat_p %>% filter(dat_p$irt_3level == "M") %>% 
  ggplot( aes(x=diff_atama)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#EB455F") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of atama (PS, Middle)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

p_h_m <- dat_p %>% filter(dat_p$irt_3level == "M") %>% 
  ggplot( aes(x=diff_heiban)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#FCFFE7") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of heiban (PS, Middle)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

p_n_m <- dat_p %>% filter(dat_p$irt_3level == "M") %>% 
  ggplot( aes(x=diff_naka)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#BAD7E9") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of naka (PS, Middle)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

p_o_m <- dat_p %>% filter(dat_p$irt_3level == "M") %>% 
  ggplot( aes(x=diff_o)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#2B3467") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of o (PS, Middle)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


##### PS H ------


p_a_h <- dat_p %>% filter(dat_p$irt_3level == "H") %>% 
  ggplot( aes(x=diff_atama)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#EB455F") +  
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of atama (PS, Upper)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


p_h_h <- dat_p %>% filter(dat_p$irt_3level == "H") %>% 
  ggplot( aes(x=diff_heiban)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#FCFFE7") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of heiban (PS, Upper)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


p_n_h <- dat_p %>% filter(dat_p$irt_3level == "H") %>% 
  ggplot( aes(x=diff_naka)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#BAD7E9") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of naka (PS, Upper)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

p_o_h <- dat_p %>% filter(dat_p$irt_3level == "H") %>% 
  ggplot( aes(x=diff_o)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#2B3467") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of o (PS, Upper)") +
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


library(gridExtra)
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
grid.arrange(p_a_l, p_h_l, p_n_l, p_o_l,
             p_a_m, p_h_m, p_n_m, p_o_m,
             p_a_h, p_h_h, p_n_h, p_o_h,
             nrow = 3)

##### TS L------
t_a_l <- dat_t %>% filter(dat_t$irt_3level == "L") %>% 
  ggplot( aes(x=diff_atama)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#EB455F") +  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of atama (TS, Lower)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


t_h_l <- dat_t %>% filter(dat_t$irt_3level == "L") %>% 
  ggplot( aes(x=diff_heiban)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#FCFFE7") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of heiban (TS, Lower)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


t_n_l <- dat_t %>% filter(dat_t$irt_3level == "L") %>% 
  ggplot( aes(x=diff_naka)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#BAD7E9") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of naka (TS, Lower)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

t_o_l <- dat_t %>% filter(dat_t$irt_3level == "L") %>% 
  ggplot( aes(x=diff_o)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#2B3467") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of o (TS, Lower)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

##### TS M ------
t_a_m <- dat_t %>% filter(dat_t$irt_3level == "M") %>% 
  ggplot( aes(x=diff_atama)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#EB455F") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of atama (TS, Middle)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

t_h_m <- dat_t %>% filter(dat_t$irt_3level == "M") %>% 
  ggplot( aes(x=diff_heiban)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#FCFFE7") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of heiban (TS, Middle)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

t_n_m <- dat_t %>% filter(dat_t$irt_3level == "M") %>% 
  ggplot( aes(x=diff_naka)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#BAD7E9") +
  #scale_fill_manual(values=c("#F3EFE0", "#434242", "#22A39F")) +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of naka (TS, Middle)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

t_o_m <- dat_t %>% filter(dat_t$irt_3level == "M") %>% 
  ggplot( aes(x=diff_o)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#2B3467") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of o (TS, Middle)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


##### TS H ------


t_a_h <- dat_t %>% filter(dat_t$irt_3level == "H") %>% 
  ggplot( aes(x=diff_atama)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#EB455F") +  
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of atama (TS, Upper)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


t_h_h <- dat_t %>% filter(dat_t$irt_3level == "H") %>% 
  ggplot( aes(x=diff_heiban)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#FCFFE7") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of heiban (TS, Upper)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)


t_n_h <- dat_t %>% filter(dat_t$irt_3level == "H") %>% 
  ggplot( aes(x=diff_naka)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#BAD7E9") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of naka (TS, Upper)")+
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)

t_o_h <- dat_t %>% filter(dat_t$irt_3level == "H") %>% 
  ggplot( aes(x=diff_o)) +
  geom_histogram( breaks=seq(-6, 6, by=1),
                  color="black", alpha=0.6, position = 'identity', 
                  binwidth = 1, fill = "#2B3467") +
  theme_ipsum() +
  labs(fill="") +
  ggtitle("Subtraction of o (TS, Upper)") +
  theme(plot.title = element_text(size=10)) +
  ylim(0, 10)




grid.arrange(t_a_l, t_h_l, t_n_l, t_o_l,
             t_a_m, t_h_m, t_n_m, t_o_m,
             t_a_h, t_h_h, t_n_h, t_o_h,
             nrow = 3)
## Warning: Removed 1 rows containing missing values (geom_bar).

Including Plots

You can also embed plots, for example:

##### atama-----

dat %>%
  group_by(label_1st, irt_3level) %>%
  get_summary_stats(diff_atama, type = "mean_sd")
## # A tibble: 6 × 6
##   label_1st irt_3level variable       n  mean    sd
##   <fct>     <ord>      <chr>      <dbl> <dbl> <dbl>
## 1 p         L          diff_atama    12 1     1.28 
## 2 p         M          diff_atama    19 0.684 1.16 
## 3 p         H          diff_atama    15 0.467 1.12 
## 4 t         L          diff_atama    12 0.917 1.08 
## 5 t         M          diff_atama    19 0.789 0.855
## 6 t         H          diff_atama    15 1.07  1.34
bxp <- ggboxplot(
  dat, x = "label_1st", y = "diff_atama",
  color = "irt_3level", palette = "uchicago"
)
bxp

dat %>%
  group_by(label_1st, irt_3level) %>%
  identify_outliers(diff_atama)
## # A tibble: 4 × 23
##   label_1st irt_3l…¹ id    atama…² heiba…³ naka_…⁴ o_1st label…⁵ atama…⁶ heiba…⁷
##   <fct>     <ord>    <fct>   <dbl>   <dbl>   <dbl> <dbl> <chr>     <dbl>   <dbl>
## 1 p         L        33          2       6       3     0 ps-b          6       6
## 2 p         M        26          3       5       4     0 ps-a          6       6
## 3 p         M        42          1       3       3     3 ps-a          4       4
## 4 p         H        48          1       5       3     1 ps-a          4       4
## # … with 13 more variables: naka_2nd <dbl>, o_2nd <dbl>, label2nd <chr>,
## #   label_2nd <chr>, diff_atama <dbl>, diff_heiban <dbl>, diff_naka <dbl>,
## #   diff_o <dbl>, `1st_total` <dbl>, `2nd_total` <dbl>, diff_total <dbl>,
## #   is.outlier <lgl>, is.extreme <lgl>, and abbreviated variable names
## #   ¹​irt_3level, ²​atama_1st, ³​heiban_1st, ⁴​naka_1st, ⁵​label1st, ⁶​atama_2nd,
## #   ⁷​heiban_2nd
## # ℹ Use `colnames()` to see all variable names
dat %>%
  group_by(label_1st, irt_3level) %>%
  shapiro_test(diff_atama)
## # A tibble: 6 × 5
##   label_1st irt_3level variable   statistic      p
##   <fct>     <ord>      <chr>          <dbl>  <dbl>
## 1 p         L          diff_atama     0.902 0.170 
## 2 p         M          diff_atama     0.884 0.0254
## 3 p         H          diff_atama     0.905 0.113 
## 4 t         L          diff_atama     0.939 0.487 
## 5 t         M          diff_atama     0.877 0.0189
## 6 t         H          diff_atama     0.904 0.110
ggqqplot(dat, "diff_atama", 
         ggtheme = theme_bw()) +
  facet_grid(label_1st ~ irt_3level)

dat %>%
  group_by(label_1st) %>%
  levene_test(diff_atama ~ irt_3level)
## # A tibble: 2 × 5
##   label_1st   df1   df2 statistic      p
##   <fct>     <int> <int>     <dbl>  <dbl>
## 1 p             2    43    0.0161 0.984 
## 2 t             2    43    2.58   0.0878
box_m(dat[, "diff_atama", drop = FALSE], dat$irt_3level)
## # A tibble: 1 × 4
##   statistic p.value parameter method                                            
##       <dbl>   <dbl>     <dbl> <chr>                                             
## 1      1.59   0.452         2 Box's M-test for Homogeneity of Covariance Matric…
res.aov <- anova_test(
  data = dat, dv = diff_atama, wid = id,
  between = irt_3level, within = label_1st
)
get_anova_table(res.aov)
## ANOVA Table (type III tests)
## 
##                 Effect DFn DFd     F     p p<.05   ges
## 1           irt_3level   2  43 0.369 0.693       0.007
## 2            label_1st   1  43 0.630 0.432       0.009
## 3 irt_3level:label_1st   2  43 0.581 0.564       0.016
##### heiban-----

dat %>%
  group_by(label_1st, irt_3level) %>%
  get_summary_stats(diff_heiban, type = "mean_sd")
## # A tibble: 6 × 6
##   label_1st irt_3level variable        n   mean    sd
##   <fct>     <ord>      <chr>       <dbl>  <dbl> <dbl>
## 1 p         L          diff_heiban    12  0.083 1.50 
## 2 p         M          diff_heiban    19  0.211 0.713
## 3 p         H          diff_heiban    15  0.067 1.03 
## 4 t         L          diff_heiban    12  0.5   1    
## 5 t         M          diff_heiban    19 -0.158 1.21 
## 6 t         H          diff_heiban    15  0.267 1.49
bxp <- ggboxplot(
  dat, x = "label_1st", y = "diff_heiban",
  color = "irt_3level", palette = "uchicago"
)
bxp

dat %>%
  group_by(label_1st, irt_3level) %>%
  identify_outliers(diff_heiban)
## # A tibble: 13 × 23
##    label_1st irt_3…¹ id    atama…² heiba…³ naka_…⁴ o_1st label…⁵ atama…⁶ heiba…⁷
##    <fct>     <ord>   <fct>   <dbl>   <dbl>   <dbl> <dbl> <chr>     <dbl>   <dbl>
##  1 p         L       30          3       1       2     4 ps-a          2       5
##  2 t         M       11          3       4       0     2 ts-a          4       2
##  3 t         M       19          3       5       4     3 ts-a          5       3
##  4 t         M       22          4       4       1     0 ts-b          5       6
##  5 t         M       26          5       5       5     0 ts-b          5       6
##  6 t         M       34          4       4       3     2 ts-b          5       6
##  7 t         M       42          5       4       6     1 ts-b          5       5
##  8 t         M       44          4       5       4     2 ts-b          5       3
##  9 t         M       46          5       5       2     0 ts-b          6       3
## 10 t         H       7           3       2       5     6 ts-a          3       6
## 11 t         H       15          4       6       3     0 ts-a          5       3
## 12 t         H       12          4       4       6     1 ts-b          5       6
## 13 t         H       48          4       6       4     0 ts-b          4       5
## # … with 13 more variables: naka_2nd <dbl>, o_2nd <dbl>, label2nd <chr>,
## #   label_2nd <chr>, diff_atama <dbl>, diff_heiban <dbl>, diff_naka <dbl>,
## #   diff_o <dbl>, `1st_total` <dbl>, `2nd_total` <dbl>, diff_total <dbl>,
## #   is.outlier <lgl>, is.extreme <lgl>, and abbreviated variable names
## #   ¹​irt_3level, ²​atama_1st, ³​heiban_1st, ⁴​naka_1st, ⁵​label1st, ⁶​atama_2nd,
## #   ⁷​heiban_2nd
## # ℹ Use `colnames()` to see all variable names
dat %>%
  group_by(label_1st, irt_3level) %>%
  shapiro_test(diff_heiban)
## # A tibble: 6 × 5
##   label_1st irt_3level variable    statistic       p
##   <fct>     <ord>      <chr>           <dbl>   <dbl>
## 1 p         L          diff_heiban     0.841 0.0285 
## 2 p         M          diff_heiban     0.802 0.00122
## 3 p         H          diff_heiban     0.932 0.293  
## 4 t         L          diff_heiban     0.783 0.00609
## 5 t         M          diff_heiban     0.856 0.00844
## 6 t         H          diff_heiban     0.819 0.00658
ggqqplot(dat, "diff_heiban", 
         ggtheme = theme_bw()) +
  facet_grid(label_1st ~ irt_3level)

dat %>%
  group_by(label_1st) %>%
  levene_test(diff_heiban ~ irt_3level)
## # A tibble: 2 × 5
##   label_1st   df1   df2 statistic     p
##   <fct>     <int> <int>     <dbl> <dbl>
## 1 p             2    43    0.932  0.402
## 2 t             2    43    0.0674 0.935
box_m(dat[, "diff_heiban", drop = FALSE], dat$irt_3level)
## # A tibble: 1 × 4
##   statistic p.value parameter method                                            
##       <dbl>   <dbl>     <dbl> <chr>                                             
## 1      2.27   0.322         2 Box's M-test for Homogeneity of Covariance Matric…
res.aov <- anova_test(
  data = dat, dv = diff_heiban, wid = id,
  between = irt_3level, within = label_1st
)
get_anova_table(res.aov)
## ANOVA Table (type III tests)
## 
##                 Effect DFn DFd     F     p p<.05   ges
## 1           irt_3level   2  43 0.366 0.696       0.009
## 2            label_1st   1  43 0.119 0.732       0.001
## 3 irt_3level:label_1st   2  43 1.027 0.367       0.022
##### naka-----

dat %>%
  group_by(label_1st, irt_3level) %>%
  get_summary_stats(diff_naka, type = "mean_sd")
## # A tibble: 6 × 6
##   label_1st irt_3level variable      n  mean    sd
##   <fct>     <ord>      <chr>     <dbl> <dbl> <dbl>
## 1 p         L          diff_naka    12 1     1.13 
## 2 p         M          diff_naka    19 0.684 0.82 
## 3 p         H          diff_naka    15 0.267 1.34 
## 4 t         L          diff_naka    12 0.333 0.888
## 5 t         M          diff_naka    19 0.684 1.76 
## 6 t         H          diff_naka    15 0.2   0.941
bxp <- ggboxplot(
  dat, x = "label_1st", y = "diff_naka",
  color = "irt_3level", palette = "uchicago"
)
bxp

dat %>%
  group_by(label_1st, irt_3level) %>%
  identify_outliers(diff_naka)
## # A tibble: 8 × 23
##   label_1st irt_3l…¹ id    atama…² heiba…³ naka_…⁴ o_1st label…⁵ atama…⁶ heiba…⁷
##   <fct>     <ord>    <fct>   <dbl>   <dbl>   <dbl> <dbl> <chr>     <dbl>   <dbl>
## 1 p         H        27          4       6       6     0 ps-b          6       6
## 2 p         H        49          4       5       5     0 ps-b          5       6
## 3 t         M        11          3       4       0     2 ts-a          4       2
## 4 t         H        15          4       6       3     0 ts-a          5       3
## 5 t         H        17          0       4       5     0 ts-a          2       4
## 6 t         H        23          4       3       2     1 ts-a          3       4
## 7 t         H        37          2       5       3     2 ts-a          5       5
## 8 t         H        45          4       0       4     6 ts-a          4       0
## # … with 13 more variables: naka_2nd <dbl>, o_2nd <dbl>, label2nd <chr>,
## #   label_2nd <chr>, diff_atama <dbl>, diff_heiban <dbl>, diff_naka <dbl>,
## #   diff_o <dbl>, `1st_total` <dbl>, `2nd_total` <dbl>, diff_total <dbl>,
## #   is.outlier <lgl>, is.extreme <lgl>, and abbreviated variable names
## #   ¹​irt_3level, ²​atama_1st, ³​heiban_1st, ⁴​naka_1st, ⁵​label1st, ⁶​atama_2nd,
## #   ⁷​heiban_2nd
## # ℹ Use `colnames()` to see all variable names
dat %>%
  group_by(label_1st, irt_3level) %>%
  shapiro_test(diff_naka)
## # A tibble: 6 × 5
##   label_1st irt_3level variable  statistic       p
##   <fct>     <ord>      <chr>         <dbl>   <dbl>
## 1 p         L          diff_naka     0.947 0.598  
## 2 p         M          diff_naka     0.874 0.0167 
## 3 p         H          diff_naka     0.804 0.00413
## 4 t         L          diff_naka     0.900 0.160  
## 5 t         M          diff_naka     0.940 0.267  
## 6 t         H          diff_naka     0.838 0.0118
ggqqplot(dat, "diff_naka", 
         ggtheme = theme_bw()) +
  facet_grid(label_1st ~ irt_3level)

dat %>%
  group_by(label_1st) %>%
  levene_test(diff_naka ~ irt_3level)
## # A tibble: 2 × 5
##   label_1st   df1   df2 statistic      p
##   <fct>     <int> <int>     <dbl>  <dbl>
## 1 p             2    43     0.349 0.708 
## 2 t             2    43     2.56  0.0892
box_m(dat[, "diff_naka", drop = FALSE], dat$irt_3level)
## # A tibble: 1 × 4
##   statistic p.value parameter method                                            
##       <dbl>   <dbl>     <dbl> <chr>                                             
## 1      2.10   0.349         2 Box's M-test for Homogeneity of Covariance Matric…
res.aov <- anova_test(
  data = dat, dv = diff_naka, wid = id,
  between = irt_3level, within = label_1st
)
get_anova_table(res.aov)
## ANOVA Table (type III tests)
## 
##                 Effect DFn DFd     F     p p<.05   ges
## 1           irt_3level   2  43 1.153 0.325       0.030
## 2            label_1st   1  43 1.061 0.309       0.010
## 3 irt_3level:label_1st   2  43 0.727 0.489       0.014
##### o-----

dat %>%
  group_by(label_1st, irt_3level) %>%
  get_summary_stats(diff_o, type = "mean_sd")
## # A tibble: 6 × 6
##   label_1st irt_3level variable     n   mean    sd
##   <fct>     <ord>      <chr>    <dbl>  <dbl> <dbl>
## 1 p         L          diff_o      12 -0.083 1.44 
## 2 p         M          diff_o      19 -0.368 1.26 
## 3 p         H          diff_o      15  0.267 1.1  
## 4 t         L          diff_o      12 -0.167 1.95 
## 5 t         M          diff_o      19  0     0.816
## 6 t         H          diff_o      15 -0.4   1.68
bxp <- ggboxplot(
  dat, x = "label_1st", y = "diff_o",
  color = "irt_3level", palette = "uchicago"
)
bxp

dat %>%
  group_by(label_1st, irt_3level) %>%
  identify_outliers(diff_o)
## # A tibble: 22 × 23
##    label_1st irt_3…¹ id    atama…² heiba…³ naka_…⁴ o_1st label…⁵ atama…⁶ heiba…⁷
##    <fct>     <ord>   <fct>   <dbl>   <dbl>   <dbl> <dbl> <chr>     <dbl>   <dbl>
##  1 p         L       30          3       1       2     4 ps-a          2       5
##  2 p         L       38          3       6       2     1 ps-a          5       5
##  3 p         L       9           3       0       5     6 ps-b          4       1
##  4 p         L       13          4       5       3     1 ps-b          5       5
##  5 p         L       29          1       5       4     0 ps-b          3       6
##  6 p         M       34          4       3       2     4 ps-a          4       3
##  7 p         M       5           5       6       5     0 ps-b          5       6
##  8 t         L       9           2       2       5     4 ts-a          4       4
##  9 t         L       13          3       5       2     2 ts-a          3       5
## 10 t         L       33          2       5       3     1 ts-a          3       4
## # … with 12 more rows, 13 more variables: naka_2nd <dbl>, o_2nd <dbl>,
## #   label2nd <chr>, label_2nd <chr>, diff_atama <dbl>, diff_heiban <dbl>,
## #   diff_naka <dbl>, diff_o <dbl>, `1st_total` <dbl>, `2nd_total` <dbl>,
## #   diff_total <dbl>, is.outlier <lgl>, is.extreme <lgl>, and abbreviated
## #   variable names ¹​irt_3level, ²​atama_1st, ³​heiban_1st, ⁴​naka_1st, ⁵​label1st,
## #   ⁶​atama_2nd, ⁷​heiban_2nd
## # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
dat %>%
  group_by(label_1st, irt_3level) %>%
  shapiro_test(diff_o)
## # A tibble: 6 × 5
##   label_1st irt_3level variable statistic        p
##   <fct>     <ord>      <chr>        <dbl>    <dbl>
## 1 p         L          diff_o       0.764 0.00376 
## 2 p         M          diff_o       0.865 0.0117  
## 3 p         H          diff_o       0.881 0.0492  
## 4 t         L          diff_o       0.826 0.0187  
## 5 t         M          diff_o       0.791 0.000851
## 6 t         H          diff_o       0.885 0.0563
ggqqplot(dat, "diff_o", 
         ggtheme = theme_bw()) +
  facet_grid(label_1st ~ irt_3level)

dat %>%
  group_by(label_1st) %>%
  levene_test(diff_o ~ irt_3level)
## # A tibble: 2 × 5
##   label_1st   df1   df2 statistic     p
##   <fct>     <int> <int>     <dbl> <dbl>
## 1 p             2    43    0.0428 0.958
## 2 t             2    43    1.95   0.154
box_m(dat[, "diff_o", drop = FALSE], dat$irt_3level)
## # A tibble: 1 × 4
##   statistic p.value parameter method                                            
##       <dbl>   <dbl>     <dbl> <chr>                                             
## 1      6.27  0.0435         2 Box's M-test for Homogeneity of Covariance Matric…
res.aov <- anova_test(
  data = dat, dv = diff_o, wid = id,
  between = irt_3level, within = label_1st
)
get_anova_table(res.aov)
## ANOVA Table (type III tests)
## 
##                 Effect DFn DFd     F     p p<.05   ges
## 1           irt_3level   2  43 0.047 0.954       0.001
## 2            label_1st   1  43 0.284 0.597       0.002
## 3 irt_3level:label_1st   2  43 1.777 0.181       0.027
dat %>%
  group_by(label_1st, irt_3level) %>%
  get_summary_stats(diff_total, type = "mean_sd")
## # A tibble: 6 × 6
##   label_1st irt_3level variable       n  mean    sd
##   <fct>     <ord>      <chr>      <dbl> <dbl> <dbl>
## 1 p         L          diff_total    12  2     2.34
## 2 p         M          diff_total    19  1.21  2.17
## 3 p         H          diff_total    15  1.07  1.94
## 4 t         L          diff_total    12  1.58  2.43
## 5 t         M          diff_total    19  1.32  2.26
## 6 t         H          diff_total    15  1.13  1.88
bxp <- ggboxplot(
  dat, x = "label_1st", y = "diff_total",
  color = "irt_3level", palette = "uchicago"
)
bxp

dat %>%
  group_by(label_1st, irt_3level) %>%
  identify_outliers(diff_total)
##  [1] label_1st   irt_3level  id          atama_1st   heiban_1st  naka_1st   
##  [7] o_1st       label1st    atama_2nd   heiban_2nd  naka_2nd    o_2nd      
## [13] label2nd    label_2nd   diff_atama  diff_heiban diff_naka   diff_o     
## [19] 1st_total   2nd_total   diff_total  is.outlier  is.extreme 
## <0 rows> (or 0-length row.names)
dat %>%
  group_by(label_1st, irt_3level) %>%
  shapiro_test(diff_total)
## # A tibble: 6 × 5
##   label_1st irt_3level variable   statistic     p
##   <fct>     <ord>      <chr>          <dbl> <dbl>
## 1 p         L          diff_total     0.964 0.840
## 2 p         M          diff_total     0.948 0.368
## 3 p         H          diff_total     0.958 0.661
## 4 t         L          diff_total     0.945 0.565
## 5 t         M          diff_total     0.920 0.115
## 6 t         H          diff_total     0.950 0.521
ggqqplot(dat, "diff_total", 
         ggtheme = theme_bw()) +
  facet_grid(label_1st ~ irt_3level)

dat %>%
  group_by(label_1st) %>%
  levene_test(diff_total ~ irt_3level)
## # A tibble: 2 × 5
##   label_1st   df1   df2 statistic     p
##   <fct>     <int> <int>     <dbl> <dbl>
## 1 p             2    43    0.0596 0.942
## 2 t             2    43    0.352  0.706
box_m(dat[, "diff_total", drop = FALSE], dat$irt_3level)
## # A tibble: 1 × 4
##   statistic p.value parameter method                                            
##       <dbl>   <dbl>     <dbl> <chr>                                             
## 1      1.29   0.525         2 Box's M-test for Homogeneity of Covariance Matric…
res.aov <- anova_test(
  data = dat, dv = diff_total, wid = id,
  between = irt_3level, within = label_1st
)
get_anova_table(res.aov)
## ANOVA Table (type III tests)
## 
##                 Effect DFn DFd     F     p p<.05      ges
## 1           irt_3level   2  43 0.728 0.489       0.017000
## 2            label_1st   1  43 0.031 0.860       0.000365
## 3 irt_3level:label_1st   2  43 0.121 0.887       0.003000