library(tidyverse)
library(readxl)
library(mclust)
__ ___________ __ _____________
/ |/ / ____/ / / / / / ___/_ __/
/ /|_/ / / / / / / / /\__ \ / /
/ / / / /___/ /___/ /_/ /___/ // /
/_/ /_/\____/_____/\____//____//_/ version 5.4.9
Type 'citation("mclust")' for citing this R package in publications.
Attaching package: ‘mclust’
The following object is masked from ‘package:purrr’:
map
ankeito <- read_excel("/Users/riku/Dropbox/zemizemi/data/honjiken/ankeitodata_with_correct_ans_2022.xlsx", sheet = "Sheet1")
#ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
# select("Q1") %>% rename(Q1L = Q1)
Q1L <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select("Q1") %>% rename(Q1L = Q1)
Q1M <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "M") %>%
select("Q1") %>% rename(Q1M = Q1)
Q1H <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "H") %>%
select("Q1") %>% rename(Q1H = Q1)
Q2L <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select("Q2") %>% rename(Q2L = Q2)
Q2M <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "M") %>%
select("Q2") %>% rename(Q2M = Q2)
Q2H <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "H") %>%
select("Q2") %>% rename(Q2H = Q2)
Q3L <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select("Q3") %>% rename(Q3L = Q3)
Q3M <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "M") %>%
select("Q3") %>% rename(Q3M = Q3)
Q3H <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "H") %>%
select("Q3") %>% rename(Q3H = Q3)
Q4L <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select("Q4") %>% rename(Q4L = Q4)
Q4M <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "M") %>%
select("Q4") %>% rename(Q4M = Q4)
Q4H <- ankeito %>% filter(TASK == "MAT", COMPLEXITY == "H") %>%
select("Q4") %>% rename(Q4H = Q4)
#ankeito.frame <- data.frame(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H, Q4L, Q4M, Q4H)
ankeito.frame <- data.frame(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H)
ankeito.frame
ankeito_clustering <- ankeito.frame %>%
na.omit()
#%>%
# mutate_all(list(scale))
BIC <- mclustBIC(ankeito_clustering)
fitting ...
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|=== | 3%
|
|=== | 4%
|
|==== | 5%
|
|===== | 6%
|
|====== | 7%
|
|======= | 8%
|
|======== | 9%
|
|========= | 10%
|
|========== | 11%
|
|========== | 12%
|
|=========== | 13%
|
|============ | 13%
|
|============ | 14%
|
|============= | 15%
|
|============== | 16%
|
|============== | 17%
|
|=============== | 17%
|
|================ | 18%
|
|================ | 19%
|
|================= | 20%
|
|================== | 20%
|
|================== | 21%
|
|=================== | 22%
|
|==================== | 23%
|
|===================== | 24%
|
|====================== | 25%
|
|======================= | 26%
|
|======================= | 27%
|
|======================== | 28%
|
|========================= | 28%
|
|========================= | 29%
|
|========================== | 30%
|
|=========================== | 31%
|
|============================ | 32%
|
|============================= | 33%
|
|============================= | 34%
|
|============================== | 35%
|
|=============================== | 35%
|
|================================ | 36%
|
|================================ | 37%
|
|================================= | 38%
|
|================================== | 39%
|
|=================================== | 40%
|
|==================================== | 41%
|
|==================================== | 42%
|
|===================================== | 43%
|
|====================================== | 43%
|
|====================================== | 44%
|
|======================================= | 45%
|
|======================================== | 46%
|
|========================================= | 47%
|
|========================================== | 48%
|
|========================================== | 49%
|
|=========================================== | 50%
|
|============================================ | 50%
|
|============================================= | 51%
|
|============================================= | 52%
|
|============================================== | 53%
|
|=============================================== | 54%
|
|================================================ | 55%
|
|================================================= | 56%
|
|================================================= | 57%
|
|================================================== | 57%
|
|=================================================== | 58%
|
|=================================================== | 59%
|
|==================================================== | 60%
|
|===================================================== | 61%
|
|====================================================== | 62%
|
|======================================================= | 63%
|
|======================================================= | 64%
|
|======================================================== | 65%
|
|========================================================= | 65%
|
|========================================================== | 66%
|
|========================================================== | 67%
|
|=========================================================== | 68%
|
|============================================================ | 69%
|
|============================================================= | 70%
|
|============================================================== | 71%
|
|============================================================== | 72%
|
|=============================================================== | 72%
|
|================================================================ | 73%
|
|================================================================ | 74%
|
|================================================================= | 75%
|
|================================================================== | 76%
|
|=================================================================== | 77%
|
|==================================================================== | 78%
|
|===================================================================== | 79%
|
|===================================================================== | 80%
|
|====================================================================== | 80%
|
|======================================================================= | 81%
|
|======================================================================= | 82%
|
|======================================================================== | 83%
|
|========================================================================= | 83%
|
|========================================================================= | 84%
|
|========================================================================== | 85%
|
|=========================================================================== | 86%
|
|=========================================================================== | 87%
|
|============================================================================ | 87%
|
|============================================================================= | 88%
|
|============================================================================= | 89%
|
|============================================================================== | 90%
|
|=============================================================================== | 91%
|
|================================================================================ | 92%
|
|================================================================================= | 93%
|
|================================================================================== | 94%
|
|=================================================================================== | 95%
|
|==================================================================================== | 96%
|
|==================================================================================== | 97%
|
|===================================================================================== | 98%
|
|====================================================================================== | 98%
|
|====================================================================================== | 99%
|
|=======================================================================================| 100%
plot(BIC)
summary(BIC)
Best BIC values:
VEE,2 EEE,1 EEV,1
BIC -1107.615 -1113.016920 -1113.016920
BIC diff 0.000 -5.402222 -5.402222
mod1 <- Mclust(ankeito_clustering, modelNames = "VEE", G = 2, x = BIC)
summary(mod1)
----------------------------------------------------
Gaussian finite mixture model fitted by EM algorithm
----------------------------------------------------
Mclust VEE (ellipsoidal, equal shape and orientation) model with 2 components:
Clustering table:
1 2
19 17
ICL <- mclustICL(ankeito_clustering)
fitting ...
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|=== | 3%
|
|=== | 4%
|
|==== | 5%
|
|===== | 6%
|
|====== | 7%
|
|======= | 8%
|
|======== | 9%
|
|========= | 10%
|
|========== | 11%
|
|========== | 12%
|
|=========== | 13%
|
|============ | 13%
|
|============ | 14%
|
|============= | 15%
|
|============== | 16%
|
|============== | 17%
|
|=============== | 17%
|
|================ | 18%
|
|================ | 19%
|
|================= | 20%
|
|================== | 20%
|
|================== | 21%
|
|=================== | 22%
|
|==================== | 23%
|
|===================== | 24%
|
|====================== | 25%
|
|======================= | 26%
|
|======================= | 27%
|
|======================== | 28%
|
|========================= | 28%
|
|========================= | 29%
|
|========================== | 30%
|
|=========================== | 31%
|
|============================ | 32%
|
|============================= | 33%
|
|============================= | 34%
|
|============================== | 35%
|
|=============================== | 35%
|
|================================ | 36%
|
|================================ | 37%
|
|================================= | 38%
|
|================================== | 39%
|
|=================================== | 40%
|
|==================================== | 41%
|
|==================================== | 42%
|
|===================================== | 43%
|
|====================================== | 43%
|
|====================================== | 44%
|
|======================================= | 45%
|
|======================================== | 46%
|
|========================================= | 47%
|
|========================================== | 48%
|
|========================================== | 49%
|
|=========================================== | 50%
|
|============================================ | 50%
|
|============================================= | 51%
|
|============================================= | 52%
|
|============================================== | 53%
|
|=============================================== | 54%
|
|================================================ | 55%
|
|================================================= | 56%
|
|================================================= | 57%
|
|================================================== | 57%
|
|=================================================== | 58%
|
|=================================================== | 59%
|
|==================================================== | 60%
|
|===================================================== | 61%
|
|====================================================== | 62%
|
|======================================================= | 63%
|
|======================================================= | 64%
|
|======================================================== | 65%
|
|========================================================= | 65%
|
|========================================================== | 66%
|
|========================================================== | 67%
|
|=========================================================== | 68%
|
|============================================================ | 69%
|
|============================================================= | 70%
|
|============================================================== | 71%
|
|============================================================== | 72%
|
|=============================================================== | 72%
|
|================================================================ | 73%
|
|================================================================ | 74%
|
|================================================================= | 75%
|
|================================================================== | 76%
|
|=================================================================== | 77%
|
|==================================================================== | 78%
|
|===================================================================== | 79%
|
|===================================================================== | 80%
|
|====================================================================== | 80%
|
|======================================================================= | 81%
|
|======================================================================= | 82%
|
|======================================================================== | 83%
|
|========================================================================= | 83%
|
|========================================================================= | 84%
|
|========================================================================== | 85%
|
|=========================================================================== | 86%
|
|=========================================================================== | 87%
|
|============================================================================ | 87%
|
|============================================================================= | 88%
|
|============================================================================= | 89%
|
|============================================================================== | 90%
|
|=============================================================================== | 91%
|
|================================================================================ | 92%
|
|================================================================================= | 93%
|
|================================================================================== | 94%
|
|=================================================================================== | 95%
|
|==================================================================================== | 96%
|
|==================================================================================== | 97%
|
|===================================================================================== | 98%
|
|====================================================================================== | 98%
|
|====================================================================================== | 99%
|
|=======================================================================================| 100%
plot(ICL)
summary(ICL)
Best ICL values:
VEE,2 EEE,1 EEV,1
ICL -1108.527 -1113.016920 -1113.016920
ICL diff 0.000 -4.490142 -4.490142
#mclustBootstrapLRT(ankeito_clustering, modelName = "VVE")
means <- data.frame(mod1$parameters$mean) %>%
rownames_to_column() %>%
rename(ankeito = rowname) %>%
pivot_longer(cols = c(X1, X2), names_to = "Profile", values_to = "Mean") %>%
mutate(Mean = round(Mean, 2),
Mean = ifelse(Mean > 1, 1, Mean))
#means %>%
# ggplot(aes(ankeito, Mean, group = Profile, color = Profile)) +
# geom_point(size = 2.25) +
# geom_line(size = 1.25) +
# scale_x_discrete(limits = c("Q1L", "Q1M", "Q1H", "Q2L", "Q2M", "Q2H", "Q3L", "Q3M", "Q3H", #"Q4L", "Q4M", "Q4H")) +
# labs(x = NULL, y = "Standardized mean interest") +
# theme_bw(base_size = 14) +
# theme(axis.text.x = element_text(angle = 45, hjust = 1), legend.position = "top")
p <- means %>%
mutate(Profile = recode(Profile,
X1 = "Profile A: 50%",
X2 = "Profile B: 50%")) %>%
ggplot(aes(ankeito, Mean, group = Profile, color = Profile)) +
geom_point(size = 2.25) +
geom_line(size = 1.25) +
scale_x_discrete(limits = c("Q1L", "Q1M", "Q1H", "Q2L", "Q2M", "Q2H", "Q3L", "Q3M", "Q3H")) +
labs(x = NULL, y = "Standardized mean ankeito") +
theme_bw(base_size = 14) +
theme(axis.text.x = element_text(angle = 45, hjust = 1), legend.position = "top")
#library(plotly)
#ggplotly(p, tooltip = c("Ankeito", "Mean")) %>%
layout(legend = list(orientation = "h", y = 1.2))
Error in UseMethod("layout") :
no applicable method for 'layout' applied to an object of class "list"
ankeito.frame$profile <- as.factor(mod1$classification)
ankeito.frame.means <- sapply(ankeito.frame %>% filter(profile == "1"), mean)
Warning in mean.default(X[[i]], ...) :
argument is not numeric or logical: returning NA
ankeito.frame.means2 <- as_tibble(as.list(ankeito.frame.means))
ankeito.frame.means3 <- as.data.frame(t(ankeito.frame.means2))
ankeito.frame.means4 <- as_tibble(ankeito.frame.means3) %>% rename(Mean = V1)
ankeito.frame.means4$Ankeito <- names(ankeito.frame.means)
ankeito.frame.means4$Profile <- "X1"
ankeito.frame.means4 <- ankeito.frame.means4[-13,]
ankeito.frame.means.p1 <- ankeito.frame.means4
ankeito.frame.means <- sapply(ankeito.frame %>% filter(profile == "2"), mean)
Warning in mean.default(X[[i]], ...) :
argument is not numeric or logical: returning NA
ankeito.frame.means2 <- as_tibble(as.list(ankeito.frame.means))
ankeito.frame.means3 <- as.data.frame(t(ankeito.frame.means2))
ankeito.frame.means4 <- as_tibble(ankeito.frame.means3) %>% rename(Mean = V1)
ankeito.frame.means4$Ankeito <- names(ankeito.frame.means)
ankeito.frame.means4$Profile <- "X2"
ankeito.frame.means4 <- ankeito.frame.means4[-13,]
ankeito.frame.means.p2 <- ankeito.frame.means4
ankeito.frame.means <- rbind(ankeito.frame.means.p1, ankeito.frame.means.p2)
p <- ankeito.frame.means %>%
mutate(Profile = recode(Profile,
X1 = "Profile A: 50%",
X2 = "Profile B: 50%")) %>%
ggplot(aes(Ankeito, Mean, group = Profile, color = Profile)) +
geom_point(size = 2.25) +
geom_line(size = 1.25) +
scale_x_discrete(limits = c("Q1L", "Q1M", "Q1H", "Q2L", "Q2M", "Q2H", "Q3L", "Q3M", "Q3H")) +
labs(x = NULL, y = "Standardized mean ankeito") +
theme_bw(base_size = 14) +
theme(axis.text.x = element_text(angle = 45, hjust = 1), legend.position = "top")
library(plotly)
ggplotly(p, tooltip = c("Ankeito", "Mean")) %>%
layout(legend = list(orientation = "h", y = 1.2))
#add mean lisas score
library(rstatix)
library(ggpubr)
mod1_profile <- data.frame(id = c(1:36), profile = mod1$classification)
ankeito_with_profile2 <- cbind(ankeito_clustering, mod1_profile)
# Visualization
ggboxplot(
ankeito_with_profile2, x = "profile", y = c("Q1L", "Q1M", "Q1H", "Q2L", "Q2M", "Q2H", "Q3L", "Q3M", "Q3H"),
merge = TRUE, palette = "jco"
)
Warning: `gather_()` was deprecated in tidyr 1.2.0.
Please use `gather()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
# Summary statistics
ankeito_with_profile2 %>%
group_by(profile) %>%
get_summary_stats(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H, type = "mean_sd")
# Check sample size assumption
ankeito_with_profile2 %>%
group_by(profile) %>%
summarise(N = n())
# Identify univariate outliers
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q1L)
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q1M)
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q1H)
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q2L)
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q2M)
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q2H)
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q3L)
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q3M)
ankeito_with_profile2 %>%
group_by(profile) %>%
identify_outliers(Q3H)
# Detect multivariate outliers
ankeito_with_profile2 %>%
group_by(profile) %>%
mahalanobis_distance(-id) %>%
filter(is.outlier == TRUE) %>%
as.data.frame()
# Check univariate normality assumption
ankeito_with_profile2 %>%
group_by(profile) %>%
shapiro_test(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H) %>%
arrange(variable)
# QQplot
ggqqplot(ankeito_with_profile2, "Q1L", facet.by = "profile",
ylab = "Q1L", ggtheme = theme_bw())
ggqqplot(ankeito_with_profile2, "Q1M", facet.by = "profile",
ylab = "Q1M", ggtheme = theme_bw())
ggqqplot(ankeito_with_profile2, "Q1H", facet.by = "profile",
ylab = "Q1H", ggtheme = theme_bw())
ggqqplot(ankeito_with_profile2, "Q2L", facet.by = "profile",
ylab = "Q2L", ggtheme = theme_bw())
ggqqplot(ankeito_with_profile2, "Q2M", facet.by = "profile",
ylab = "Q2M", ggtheme = theme_bw())
ggqqplot(ankeito_with_profile2, "Q2H", facet.by = "profile",
ylab = "Q3M", ggtheme = theme_bw())
ggqqplot(ankeito_with_profile2, "Q3L", facet.by = "profile",
ylab = "Q3L", ggtheme = theme_bw())
ggqqplot(ankeito_with_profile2, "Q3M", facet.by = "profile",
ylab = "Q3M", ggtheme = theme_bw())
ggqqplot(ankeito_with_profile2, "Q3H", facet.by = "profile",
ylab = "Q3H", ggtheme = theme_bw())
# Multivariate normality
ankeito_with_profile2 %>%
select(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H) %>%
mshapiro_test()
# Identify multicollinearity
ankeito_with_profile2 %>% cor_mat(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H) %>%
cor_get_pval()
# Check linearity assumption
library(GGally)
results <- ankeito_with_profile2 %>%
select(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H, profile) %>%
group_by(profile) %>%
doo(~ggpairs(.) + theme_bw(), result = "plots")
results
results$plots
[[1]]
plot: [1,1] [>------------------------------------------------------------------] 1% est: 0s
plot: [1,2] [=>-----------------------------------------------------------------] 2% est: 1s
plot: [1,3] [=>-----------------------------------------------------------------] 4% est: 1s
plot: [1,4] [==>----------------------------------------------------------------] 5% est: 1s
plot: [1,5] [===>---------------------------------------------------------------] 6% est: 1s
plot: [1,6] [====>--------------------------------------------------------------] 7% est: 1s
plot: [1,7] [=====>-------------------------------------------------------------] 9% est: 1s
plot: [1,8] [======>------------------------------------------------------------] 10% est: 1s
plot: [1,9] [======>------------------------------------------------------------] 11% est: 1s
plot: [2,1] [=======>-----------------------------------------------------------] 12% est: 1s
plot: [2,2] [========>----------------------------------------------------------] 14% est: 1s
plot: [2,3] [=========>---------------------------------------------------------] 15% est: 1s
plot: [2,4] [==========>--------------------------------------------------------] 16% est: 1s
plot: [2,5] [===========>-------------------------------------------------------] 17% est: 1s
plot: [2,6] [===========>-------------------------------------------------------] 19% est: 1s
plot: [2,7] [============>------------------------------------------------------] 20% est: 1s
plot: [2,8] [=============>-----------------------------------------------------] 21% est: 1s
plot: [2,9] [==============>----------------------------------------------------] 22% est: 1s
plot: [3,1] [===============>---------------------------------------------------] 23% est: 1s
plot: [3,2] [================>--------------------------------------------------] 25% est: 1s
plot: [3,3] [================>--------------------------------------------------] 26% est: 1s
plot: [3,4] [=================>-------------------------------------------------] 27% est: 1s
plot: [3,5] [==================>------------------------------------------------] 28% est: 1s
plot: [3,6] [===================>-----------------------------------------------] 30% est: 1s
plot: [3,7] [====================>----------------------------------------------] 31% est: 1s
plot: [3,8] [=====================>---------------------------------------------] 32% est: 1s
plot: [3,9] [=====================>---------------------------------------------] 33% est: 1s
plot: [4,1] [======================>--------------------------------------------] 35% est: 1s
plot: [4,2] [=======================>-------------------------------------------] 36% est: 1s
plot: [4,3] [========================>------------------------------------------] 37% est: 1s
plot: [4,4] [=========================>-----------------------------------------] 38% est: 1s
plot: [4,5] [=========================>-----------------------------------------] 40% est: 1s
plot: [4,6] [==========================>----------------------------------------] 41% est: 1s
plot: [4,7] [===========================>---------------------------------------] 42% est: 1s
plot: [4,8] [============================>--------------------------------------] 43% est: 1s
plot: [4,9] [=============================>-------------------------------------] 44% est: 1s
plot: [5,1] [==============================>------------------------------------] 46% est: 1s
plot: [5,2] [==============================>------------------------------------] 47% est: 1s
plot: [5,3] [===============================>-----------------------------------] 48% est: 1s
plot: [5,4] [================================>----------------------------------] 49% est: 1s
plot: [5,5] [=================================>---------------------------------] 51% est: 1s
plot: [5,6] [==================================>--------------------------------] 52% est: 1s
plot: [5,7] [===================================>-------------------------------] 53% est: 1s
plot: [5,8] [===================================>-------------------------------] 54% est: 1s
plot: [5,9] [====================================>------------------------------] 56% est: 1s
plot: [6,1] [=====================================>-----------------------------] 57% est: 1s
plot: [6,2] [======================================>----------------------------] 58% est: 1s
plot: [6,3] [=======================================>---------------------------] 59% est: 1s
plot: [6,4] [========================================>--------------------------] 60% est: 1s
plot: [6,5] [========================================>--------------------------] 62% est: 1s
plot: [6,6] [=========================================>-------------------------] 63% est: 1s
plot: [6,7] [==========================================>------------------------] 64% est: 1s
plot: [6,8] [===========================================>-----------------------] 65% est: 1s
plot: [6,9] [============================================>----------------------] 67% est: 1s
plot: [7,1] [============================================>----------------------] 68% est: 1s
plot: [7,2] [=============================================>---------------------] 69% est: 0s
plot: [7,3] [==============================================>--------------------] 70% est: 0s
plot: [7,4] [===============================================>-------------------] 72% est: 0s
plot: [7,5] [================================================>------------------] 73% est: 0s
plot: [7,6] [=================================================>-----------------] 74% est: 0s
plot: [7,7] [=================================================>-----------------] 75% est: 0s
plot: [7,8] [==================================================>----------------] 77% est: 0s
plot: [7,9] [===================================================>---------------] 78% est: 0s
plot: [8,1] [====================================================>--------------] 79% est: 0s
plot: [8,2] [=====================================================>-------------] 80% est: 0s
plot: [8,3] [======================================================>------------] 81% est: 0s
plot: [8,4] [======================================================>------------] 83% est: 0s
plot: [8,5] [=======================================================>-----------] 84% est: 0s
plot: [8,6] [========================================================>----------] 85% est: 0s
plot: [8,7] [=========================================================>---------] 86% est: 0s
plot: [8,8] [==========================================================>--------] 88% est: 0s
plot: [8,9] [===========================================================>-------] 89% est: 0s
plot: [9,1] [===========================================================>-------] 90% est: 0s
plot: [9,2] [============================================================>------] 91% est: 0s
plot: [9,3] [=============================================================>-----] 93% est: 0s
plot: [9,4] [==============================================================>----] 94% est: 0s
plot: [9,5] [===============================================================>---] 95% est: 0s
plot: [9,6] [================================================================>--] 96% est: 0s
plot: [9,7] [================================================================>--] 98% est: 0s
plot: [9,8] [=================================================================>-] 99% est: 0s
plot: [9,9] [===================================================================]100% est: 0s
[[2]]
plot: [1,1] [>------------------------------------------------------------------] 1% est: 0s
plot: [1,2] [=>-----------------------------------------------------------------] 2% est: 1s
plot: [1,3] [=>-----------------------------------------------------------------] 4% est: 1s
plot: [1,4] [==>----------------------------------------------------------------] 5% est: 1s
plot: [1,5] [===>---------------------------------------------------------------] 6% est: 1s
plot: [1,6] [====>--------------------------------------------------------------] 7% est: 1s
plot: [1,7] [=====>-------------------------------------------------------------] 9% est: 1s
plot: [1,8] [======>------------------------------------------------------------] 10% est: 2s
plot: [1,9] [======>------------------------------------------------------------] 11% est: 1s
plot: [2,1] [=======>-----------------------------------------------------------] 12% est: 1s
plot: [2,2] [========>----------------------------------------------------------] 14% est: 1s
plot: [2,3] [=========>---------------------------------------------------------] 15% est: 1s
plot: [2,4] [==========>--------------------------------------------------------] 16% est: 1s
plot: [2,5] [===========>-------------------------------------------------------] 17% est: 1s
plot: [2,6] [===========>-------------------------------------------------------] 19% est: 1s
plot: [2,7] [============>------------------------------------------------------] 20% est: 1s
plot: [2,8] [=============>-----------------------------------------------------] 21% est: 1s
plot: [2,9] [==============>----------------------------------------------------] 22% est: 1s
plot: [3,1] [===============>---------------------------------------------------] 23% est: 1s
plot: [3,2] [================>--------------------------------------------------] 25% est: 1s
plot: [3,3] [================>--------------------------------------------------] 26% est: 1s
plot: [3,4] [=================>-------------------------------------------------] 27% est: 1s
plot: [3,5] [==================>------------------------------------------------] 28% est: 1s
plot: [3,6] [===================>-----------------------------------------------] 30% est: 1s
plot: [3,7] [====================>----------------------------------------------] 31% est: 1s
plot: [3,8] [=====================>---------------------------------------------] 32% est: 1s
plot: [3,9] [=====================>---------------------------------------------] 33% est: 1s
plot: [4,1] [======================>--------------------------------------------] 35% est: 1s
plot: [4,2] [=======================>-------------------------------------------] 36% est: 1s
plot: [4,3] [========================>------------------------------------------] 37% est: 1s
plot: [4,4] [=========================>-----------------------------------------] 38% est: 1s
plot: [4,5] [=========================>-----------------------------------------] 40% est: 1s
plot: [4,6] [==========================>----------------------------------------] 41% est: 1s
plot: [4,7] [===========================>---------------------------------------] 42% est: 1s
plot: [4,8] [============================>--------------------------------------] 43% est: 1s
plot: [4,9] [=============================>-------------------------------------] 44% est: 1s
plot: [5,1] [==============================>------------------------------------] 46% est: 1s
plot: [5,2] [==============================>------------------------------------] 47% est: 1s
plot: [5,3] [===============================>-----------------------------------] 48% est: 1s
plot: [5,4] [================================>----------------------------------] 49% est: 1s
plot: [5,5] [=================================>---------------------------------] 51% est: 1s
plot: [5,6] [==================================>--------------------------------] 52% est: 1s
plot: [5,7] [===================================>-------------------------------] 53% est: 1s
plot: [5,8] [===================================>-------------------------------] 54% est: 1s
plot: [5,9] [====================================>------------------------------] 56% est: 1s
plot: [6,1] [=====================================>-----------------------------] 57% est: 1s
plot: [6,2] [======================================>----------------------------] 58% est: 1s
plot: [6,3] [=======================================>---------------------------] 59% est: 1s
plot: [6,4] [========================================>--------------------------] 60% est: 1s
plot: [6,5] [========================================>--------------------------] 62% est: 1s
plot: [6,6] [=========================================>-------------------------] 63% est: 1s
plot: [6,7] [==========================================>------------------------] 64% est: 1s
plot: [6,8] [===========================================>-----------------------] 65% est: 1s
plot: [6,9] [============================================>----------------------] 67% est: 1s
plot: [7,1] [============================================>----------------------] 68% est: 1s
plot: [7,2] [=============================================>---------------------] 69% est: 1s
plot: [7,3] [==============================================>--------------------] 70% est: 1s
plot: [7,4] [===============================================>-------------------] 72% est: 0s
plot: [7,5] [================================================>------------------] 73% est: 0s
plot: [7,6] [=================================================>-----------------] 74% est: 0s
plot: [7,7] [=================================================>-----------------] 75% est: 0s
plot: [7,8] [==================================================>----------------] 77% est: 0s
plot: [7,9] [===================================================>---------------] 78% est: 0s
plot: [8,1] [====================================================>--------------] 79% est: 0s
plot: [8,2] [=====================================================>-------------] 80% est: 0s
plot: [8,3] [======================================================>------------] 81% est: 0s
plot: [8,4] [======================================================>------------] 83% est: 0s
plot: [8,5] [=======================================================>-----------] 84% est: 0s
plot: [8,6] [========================================================>----------] 85% est: 0s
plot: [8,7] [=========================================================>---------] 86% est: 0s
plot: [8,8] [==========================================================>--------] 88% est: 0s
plot: [8,9] [===========================================================>-------] 89% est: 0s
plot: [9,1] [===========================================================>-------] 90% est: 0s
plot: [9,2] [============================================================>------] 91% est: 0s
plot: [9,3] [=============================================================>-----] 93% est: 0s
plot: [9,4] [==============================================================>----] 94% est: 0s
plot: [9,5] [===============================================================>---] 95% est: 0s
plot: [9,6] [================================================================>--] 96% est: 0s
plot: [9,7] [================================================================>--] 98% est: 0s
plot: [9,8] [=================================================================>-] 99% est: 0s
plot: [9,9] [===================================================================]100% est: 0s
# Check the homogeneity of covariances assumption
## とりあえず略します
# Computation
model <- lm(cbind(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H) ~ profile, ankeito_with_profile2)
Manova(model, test.statistic = "Pillai")
Type II MANOVA Tests: Pillai test statistic
Df test stat approx F num Df den Df Pr(>F)
profile 1 0.81517 12.741 9 26 1.799e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Post-hoc tests
# Group the data by variable
grouped.data <- ankeito_with_profile2 %>%
gather(key = "variable", value = "value", Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H) %>%
group_by(variable)
# Do welch one way anova test
grouped.data %>% welch_anova_test(value ~ profile)
pwc <- ankeito_with_profile2 %>%
gather(key = "variables", value = "value", Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H) %>%
group_by(variables) %>%
games_howell_test(value ~ profile) %>%
select(-estimate, -conf.low, -conf.high) # Remove details
pwc
# Visualization: box plots with p-values
pwc <- pwc %>% add_xy_position(x = "profile")
test.label <- create_test_label(
description = "MANOVA", statistic.text = quote(italic("F")),
statistic = 12.741, p= "<0.0001", parameter = "9, 26",
type = "expression", detailed = TRUE
)
ggboxplot(
ankeito_with_profile2, x = "profile", y = c("Q1L", "Q1M", "Q1H", "Q2L", "Q2M", "Q2H", "Q3L", "Q3M", "Q3H"),
merge = TRUE, palette = "jco"
) +
stat_pvalue_manual(
pwc, hide.ns = TRUE, tip.length = 0,
step.increase = 0.1, step.group.by = "variables",
color = "variables"
) +
labs(
subtitle = test.label,
caption = get_pwc_label(pwc, type = "expression")
)
NA
NA
ankeito_lisas <- read_xlsx("/Users/riku/Dropbox/zemizemi/data/honjiken/ankeitodata_with_correct_ans_202010version.xlsx", sheet = "lisas")
ankeito_lisas_with_profile <- left_join(ankeito_lisas, mod1_profile)
Joining, by = "id"
ankeito_lisas_with_profile$profile <- as.factor(ankeito_lisas_with_profile$profile)
ankeito_all <- ankeito_with_profile2
lisas_M <- as.data.frame(ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "M") %>%
select(lisas))
ankeito_all$Lisas_M <- lisas_M$lisas
lisas_H <- as.data.frame(ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "H") %>%
select(lisas))
ankeito_all$Lisas_H <- lisas_H$lisas
prepare_time_L <- as.data.frame(ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select(prepare_time))
prepare_time_M <- as.data.frame(ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "M") %>%
select(prepare_time))
prepare_time_H <- as.data.frame(ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "H") %>%
select(prepare_time))
ankeito_all$prepare_time_L <- prepare_time_L$prepare_time
ankeito_all$prepare_time_M <- prepare_time_M$prepare_time
ankeito_all$prepare_time_H <- prepare_time_H$prepare_time
Japan_length <- as.data.frame(ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select(length_of_stay_in_Japan))
SPOT90 <- as.data.frame(ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select(SPOT90))
ankeito_all$Japan_length <- Japan_length$length_of_stay_in_Japan
ankeito_all$SPOT90 <- SPOT90$SPOT90
AGE <- as.data.frame(ankeito %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select(birth_year))
AGE$birth_year <- 2020 - AGE$birth_year
ankeito_all$AGE <- AGE$birth_year
ankeito_all$profile2 <- ifelse(ankeito_all$profile == 1, 1, 0)
logit <- glm(profile2 ~ AGE + Lisas_M + Lisas_H + prepare_time_L + prepare_time_M + prepare_time_H + Japan_length + SPOT90, data = ankeito_all, family = "binomial")
summary(logit)
Call:
glm(formula = profile2 ~ AGE + Lisas_M + Lisas_H + prepare_time_L +
prepare_time_M + prepare_time_H + Japan_length + SPOT90,
family = "binomial", data = ankeito_all)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.7554 -1.0303 0.5446 0.9075 1.9682
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 13.8382503 10.1626950 1.362 0.173
AGE -0.2843983 0.2880162 -0.987 0.323
Lisas_M -0.0008948 0.0015798 -0.566 0.571
Lisas_H -0.0011042 0.0014654 -0.754 0.451
prepare_time_L 0.0044301 0.0174533 0.254 0.800
prepare_time_M 0.0133604 0.0178449 0.749 0.454
prepare_time_H -0.0079313 0.0106826 -0.742 0.458
Japan_length 0.0951881 0.4013859 0.237 0.813
SPOT90 -0.0466264 0.0534844 -0.872 0.383
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 49.795 on 35 degrees of freedom
Residual deviance: 42.841 on 27 degrees of freedom
AIC: 60.841
Number of Fisher Scoring iterations: 4
library(ggpubr)
library(rstatix)
mod1_profile <- data.frame(id = c(1:36), profile = mod1$classification)
ankeito_with_profile <- inner_join(ankeito, mod1_profile)
SPOT90_p <- ankeito_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "L") %>%
select(SPOT90, profile)
SPOT90_p$profile <- as.factor(SPOT90_p$profile)
#ggplot(SPOT90_p, aes(x = profile, group = profile, y = SPOT90)) + geom_boxplot()
#t.test(select(filter(SPOT90_p, profile == "1"), SPOT90), select(filter(SPOT90_p, profile == "2"), SPOT90))
SPOT90_p %>%
group_by(profile) %>%
get_summary_stats(SPOT90, type = "mean_sd")
bxp <- ggboxplot(
SPOT90_p, x = "profile", y = "SPOT90",
ylab = "SPOT90", xlab = "Profile", add = "jitter"
)
bxp
SPOT90_p %>%
group_by(profile) %>%
identify_outliers(SPOT90)
SPOT90_p <- SPOT90_p[c(-36),] #id 36 excluded
SPOT90_p %>%
group_by(profile) %>%
get_summary_stats(SPOT90, type = "mean_sd")
bxp <- ggboxplot(
SPOT90_p, x = "profile", y = "SPOT90",
ylab = "SPOT90", xlab = "Profile", add = "jitter"
)
bxp
SPOT90_p %>%
group_by(profile) %>%
shapiro_test(SPOT90)
ggqqplot(SPOT90_p, x = "SPOT90", facet.by = "profile")
SPOT90_p %>% levene_test(SPOT90 ~ profile)
stat.test <- SPOT90_p %>%
t_test(SPOT90 ~ profile, var.equal = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "profile")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed = TRUE))
ankeito_lisas <- read_xlsx("/Users/riku/Dropbox/zemizemi/data/honjiken/ankeitodata_with_correct_ans_202010version.xlsx", sheet = "lisas")
ankeito_lisas_with_profile <- left_join(ankeito_lisas, mod1_profile)
Joining, by = "id"
ankeito_lisas_with_profile$profile <- as.factor(ankeito_lisas_with_profile$profile)
LISAS_mat_m <- ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "M") %>%
select(lisas, profile)
LISAS_mat_m %>%
group_by(profile) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggboxplot(
LISAS_mat_m, x = "profile", y = "lisas",
ylab = "LISAS MAT M", xlab = "PROFILE", add = "jitter"
)
bxp
LISAS_mat_m %>%
group_by(profile) %>%
identify_outliers(lisas)
LISAS_mat_m %>%
group_by(profile) %>%
shapiro_test(lisas)
LISAS_mat_m %>% levene_test(lisas ~ profile)
stat.test <- LISAS_mat_m %>%
t_test(lisas ~ profile) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "profile")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed = TRUE))
LISAS_mat_h <- ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "H") %>%
select(lisas, profile)
LISAS_mat_h %>%
group_by(profile) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggboxplot(
LISAS_mat_h, x = "profile", y = "lisas",
ylab = "LISAS MAT H", xlab = "PROFILE", add = "jitter"
)
bxp
LISAS_mat_h %>%
group_by(profile) %>%
identify_outliers(lisas)
LISAS_mat_h %>%
group_by(profile) %>%
shapiro_test(lisas)
LISAS_mat_h %>% levene_test(lisas ~ profile)
stat.test <- LISAS_mat_h %>%
t_test(lisas ~ profile, var.equal = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "profile")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed = TRUE))
LISAS_mat_m$task <- "MAT_M"
LISAS_mat_h$task <- "MAT_H"
lisas_mat_p <- rbind(LISAS_mat_m, LISAS_mat_h)
lisas_mat_p1 <- filter(lisas_mat_p, lisas_mat_p$profile == "1")
lisas_mat_p2 <- filter(lisas_mat_p, lisas_mat_p$profile == "2")
mat_profile_1 <- inner_join(
ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "M", profile == "1") %>%
select(id, lisas, profile) %>% rename(MAT_M = lisas),
ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "H", profile == "1") %>%
select(id, lisas, profile) %>% rename(MAT_H = lisas))
Joining, by = c("id", "profile")
mat_profile_1_long <- mat_profile_1 %>%
gather(key = "task", value = "lisas", MAT_M, MAT_H)
mat_profile_1_long %>%
group_by(task) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggpaired(mat_profile_1_long, x = "task", y = "lisas",
order = c("MAT_M", "MAT_H"),
ylab = "LISAS MAT PROFILE 1", xlab = "TASK")
bxp
mat_profile_1 <- mat_profile_1 %>% mutate(differences = MAT_M - MAT_H)
mat_profile_1 %>% identify_outliers(differences)
mat_profile_1 %>% shapiro_test(differences)
stat.test <- mat_profile_1_long %>%
wilcox_test(lisas ~ task, paired = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "task")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed= TRUE))
mat_profile_2 <- inner_join(
ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "M", profile == "2") %>%
select(id, lisas, profile) %>% rename(MAT_M = lisas),
ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "H", profile == "2") %>%
select(id, lisas, profile) %>% rename(MAT_H = lisas))
mat_profile_2_long <- mat_profile_2 %>%
gather(key = "task", value = "lisas", MAT_M, MAT_H)
mat_profile_2_long %>%
group_by(task) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggpaired(mat_profile_2_long, x = "task", y = "lisas",
order = c("MAT_M", "MAT_H"),
ylab = "LISAS MAT PROFILE 2", xlab = "TASK")
bxp
mat_profile_2 <- mat_profile_2 %>% mutate(differences = MAT_M - MAT_H)
mat_profile_2 %>% identify_outliers(differences)
mat_profile_2 %>% shapiro_test(differences)
stat.test <- mat_profile_2_long %>%
t_test(lisas ~ task, paired = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "task")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed= TRUE))
sat_profile_1 <- inner_join(
ankeito_lisas_with_profile %>% filter(TASK == "SAT", COMPLEXITY == "M", profile == "1") %>%
select(id, lisas, profile) %>% rename(SAT_M = lisas),
ankeito_lisas_with_profile %>% filter(TASK == "SAT", COMPLEXITY == "H", profile == "1") %>%
select(id, lisas, profile) %>% rename(SAT_H = lisas))
Joining, by = c("id", "profile")
sat_profile_1_long <- sat_profile_1 %>%
gather(key = "task", value = "lisas", SAT_M, SAT_H)
sat_profile_1_long %>%
group_by(task) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggpaired(sat_profile_1_long, x = "task", y = "lisas",
order = c("SAT_M", "SAT_H"),
ylab = "LISAS MAT PROFILE 1", xlab = "TASK")
bxp
sat_profile_1 <- sat_profile_1 %>% mutate(differences = SAT_M - SAT_H)
sat_profile_1 %>% identify_outliers(differences)
sat_profile_1 %>% shapiro_test(differences)
stat.test <- sat_profile_1_long %>%
t_test(lisas ~ task, paired = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "task")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed= TRUE))
sat_profile_2 <- inner_join(
ankeito_lisas_with_profile %>% filter(TASK == "SAT", COMPLEXITY == "M", profile == "2") %>%
select(id, lisas, profile) %>% rename(SAT_M = lisas),
ankeito_lisas_with_profile %>% filter(TASK == "SAT", COMPLEXITY == "H", profile == "2") %>%
select(id, lisas, profile) %>% rename(SAT_H = lisas))
sat_profile_2_long <- sat_profile_2 %>%
gather(key = "task", value = "lisas", SAT_M, SAT_H)
sat_profile_2_long %>%
group_by(task) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggpaired(sat_profile_2_long, x = "task", y = "lisas",
order = c("SAT_M", "SAT_H"),
ylab = "LISAS MAT PROFILE 2", xlab = "TASK")
bxp
sat_profile_2 <- sat_profile_2 %>% mutate(differences = SAT_M - SAT_H)
sat_profile_2 %>% identify_outliers(differences)
sat_profile_2 %>% shapiro_test(differences)
stat.test <- sat_profile_2_long %>%
t_test(lisas ~ task, paired = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "task")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed= TRUE))
filter(ankeito_lisas_with_profile, TASK == "MAT", COMPLEXITY =="H")
ankeito_lisas_with_profile$Gender <- as.factor(ankeito_lisas_with_profile$Gender)
summary(select(ankeito_lisas_with_profile, Gender, profile))
ankeito_lisas_with_profile %>%
filter(TASK == "MAT", COMPLEXITY =="H", profile == 1) %>%
select(Gender) %>%
summary()
ankeito_lisas_with_profile %>%
filter(TASK == "MAT", COMPLEXITY =="H", profile == 2) %>%
select(Gender) %>%
summary()
ankeito_lisas_with_profile %>%
filter(TASK == "MAT", COMPLEXITY =="H", profile == 1) %>%
select(length_of_stay_in_Japan) %>%
summary()
ankeito_lisas_with_profile %>%
filter(TASK == "MAT", COMPLEXITY =="H", profile == 2) %>%
select(length_of_stay_in_Japan) %>%
summary()
ankeito_lisas_with_profile %>%
filter(TASK == "MAT", COMPLEXITY =="H") %>%
ggboxplot(x = "profile", y = "Q1", color = "profile",
ylab = "Q1 MAT H", xlab = "PROFILE", add = "jitter")
LISAS_mat_m %>%
group_by(profile) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggboxplot(
LISAS_mat_m, x = "profile", y = "lisas",
ylab = "LISAS MAT M", xlab = "PROFILE", add = "jitter"
)
bxp
LISAS_mat_m %>%
group_by(profile) %>%
identify_outliers(lisas)
LISAS_mat_m %>%
group_by(profile) %>%
shapiro_test(lisas)
LISAS_mat_m %>% levene_test(lisas ~ profile)
stat.test <- LISAS_mat_m %>%
wilcox_test(lisas ~ profile) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "profile")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed = TRUE))
LISAS_mat_h <- ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "H") %>%
select(lisas, profile)
LISAS_mat_h %>%
group_by(profile) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggboxplot(
LISAS_mat_h, x = "profile", y = "lisas",
ylab = "LISAS MAT H", xlab = "PROFILE", add = "jitter"
)
bxp
LISAS_mat_h %>%
group_by(profile) %>%
identify_outliers(lisas)
LISAS_mat_h %>%
group_by(profile) %>%
shapiro_test(lisas)
LISAS_mat_h %>% levene_test(lisas ~ profile)
stat.test <- LISAS_mat_h %>%
wilcox_test(lisas ~ profile) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "profile")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed = TRUE))
LISAS_mat_m$task <- "MAT_M"
LISAS_mat_h$task <- "MAT_H"
lisas_mat_p <- rbind(LISAS_mat_m, LISAS_mat_h)
lisas_mat_p1 <- filter(lisas_mat_p, lisas_mat_p$profile == "1")
lisas_mat_p2 <- filter(lisas_mat_p, lisas_mat_p$profile == "2")
mat_profile_1 <- inner_join(
ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "M", profile == "1") %>%
select(id, lisas, profile) %>% rename(MAT_M = lisas),
ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "H", profile == "1") %>%
select(id, lisas, profile) %>% rename(MAT_H = lisas))
mat_profile_1_long <- mat_profile_1 %>%
gather(key = "task", value = "lisas", MAT_M, MAT_H)
mat_profile_1_long %>%
group_by(task) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggpaired(mat_profile_1_long, x = "task", y = "lisas",
order = c("MAT_M", "MAT_H"),
ylab = "LISAS MAT PROFILE 1", xlab = "TASK")
bxp
mat_profile_1 <- mat_profile_1 %>% mutate(differences = MAT_M - MAT_H)
mat_profile_1 %>% identify_outliers(differences)
mat_profile_1 %>% shapiro_test(differences)
stat.test <- mat_profile_1_long %>%
wilcox_test(lisas ~ task, paired = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "task")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed= TRUE))
mat_profile_2 <- inner_join(
ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "M", profile == "2") %>%
select(id, lisas, profile) %>% rename(MAT_M = lisas),
ankeito_lisas_with_profile %>% filter(TASK == "MAT", COMPLEXITY == "H", profile == "2") %>%
select(id, lisas, profile) %>% rename(MAT_H = lisas))
mat_profile_2_long <- mat_profile_2 %>%
gather(key = "task", value = "lisas", MAT_M, MAT_H)
mat_profile_2_long %>%
group_by(task) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggpaired(mat_profile_2_long, x = "task", y = "lisas",
order = c("MAT_M", "MAT_H"),
ylab = "LISAS MAT PROFILE 2", xlab = "TASK")
bxp
mat_profile_2 <- mat_profile_2 %>% mutate(differences = MAT_M - MAT_H)
mat_profile_2 %>% identify_outliers(differences)
mat_profile_2 %>% shapiro_test(differences)
stat.test <- mat_profile_2_long %>%
wilcox_test(lisas ~ task, paired = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "task")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed= TRUE))
Q1L <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "L") %>%
select("Q1") %>% rename(Q1L = Q1)
Q1M <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "M") %>%
select("Q1") %>% rename(Q1M = Q1)
Q1H <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "H") %>%
select("Q1") %>% rename(Q1H = Q1)
Q2L <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "L") %>%
select("Q2") %>% rename(Q2L = Q2)
Q2M <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "M") %>%
select("Q2") %>% rename(Q2M = Q2)
Q2H <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "H") %>%
select("Q2") %>% rename(Q2H = Q2)
Q3L <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "L") %>%
select("Q3") %>% rename(Q3L = Q3)
Q3M <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "M") %>%
select("Q3") %>% rename(Q3M = Q3)
Q3H <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "H") %>%
select("Q3") %>% rename(Q3H = Q3)
Q4L <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "L") %>%
select("Q4") %>% rename(Q4L = Q4)
Q4M <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "M") %>%
select("Q4") %>% rename(Q4M = Q4)
Q4H <- ankeito %>% filter(TASK == "SAT", COMPLEXITY == "H") %>%
select("Q4") %>% rename(Q4H = Q4)
ankeito.frame <- data.frame(Q1L, Q1M, Q1H, Q2L, Q2M, Q2H, Q3L, Q3M, Q3H, Q4L, Q4M, Q4H)
ankeito.frame
summary(mod3)
----------------------------------------------------
Gaussian finite mixture model fitted by EM algorithm
----------------------------------------------------
Mclust EVE (ellipsoidal, equal volume and orientation) model with 2
components:
Clustering table:
1 2
17 19
sat_profile_1 <- inner_join(
ankeito_lisas_with_profile %>% filter(TASK == "SAT", COMPLEXITY == "M", profile == "1") %>%
select(id, lisas, profile) %>% rename(SAT_M = lisas),
ankeito_lisas_with_profile %>% filter(TASK == "SAT", COMPLEXITY == "H", profile == "1") %>%
select(id, lisas, profile) %>% rename(SAT_H = lisas))
Joining, by = c("id", "profile")
sat_profile_1_long <- sat_profile_1 %>%
gather(key = "task", value = "lisas", SAT_M, SAT_H)
sat_profile_1_long %>%
group_by(task) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggpaired(sat_profile_1_long, x = "task", y = "lisas",
order = c("SAT_M", "SAT_H"),
ylab = "LISAS MAT PROFILE 1", xlab = "TASK")
bxp
sat_profile_1 <- sat_profile_1 %>% mutate(differences = SAT_M - SAT_H)
sat_profile_1 %>% identify_outliers(differences)
sat_profile_1 %>% shapiro_test(differences)
stat.test <- sat_profile_1_long %>%
wilcox_test(lisas ~ task, paired = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "task")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed= TRUE))
sat_profile_2 <- inner_join(
ankeito_lisas_with_profile %>% filter(TASK == "SAT", COMPLEXITY == "M", profile == "2") %>%
select(id, lisas, profile) %>% rename(SAT_M = lisas),
ankeito_lisas_with_profile %>% filter(TASK == "SAT", COMPLEXITY == "H", profile == "2") %>%
select(id, lisas, profile) %>% rename(SAT_H = lisas))
Joining, by = c("id", "profile")
sat_profile_2_long <- sat_profile_2 %>%
gather(key = "task", value = "lisas", SAT_M, SAT_H)
sat_profile_2_long %>%
group_by(task) %>%
get_summary_stats(lisas, type = "mean_sd")
bxp <- ggpaired(sat_profile_2_long, x = "task", y = "lisas",
order = c("SAT_M", "SAT_H"),
ylab = "LISAS MAT PROFILE 2", xlab = "TASK")
bxp
sat_profile_2 <- sat_profile_2 %>% mutate(differences = SAT_M - SAT_H)
sat_profile_2 %>% identify_outliers(differences)
sat_profile_2 %>% shapiro_test(differences)
stat.test <- sat_profile_2_long %>%
wilcox_test(lisas ~ task, paired = TRUE) %>%
add_significance()
stat.test
stat.test <- stat.test %>% add_xy_position(x = "task")
bxp +
stat_pvalue_manual(stat.test, tip.length = 0) +
labs(subtitle = get_test_label(stat.test, detailed= TRUE))
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.