Mindfulness Experiment Analysis

Load Packages

if (!require(haven)){
  install.packages("haven", dependencies = TRUE)
  require(haven)
}
Loading required package: haven
if (!require(tidyverse)){
  install.packages("tidyverse", dependencies = TRUE)
  require(tidyverse)
}
Loading required package: tidyverse
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
if (!require(afex)){
  install.packages("afex", dependencies = TRUE)
  require(afex)
}
Loading required package: afex
Loading required package: lme4
Loading required package: Matrix

Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':

    expand, pack, unpack
************
Welcome to afex. For support visit: http://afex.singmann.science/
- Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
- Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
- 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
- Get and set global package options with: afex_options()
- Set sum-to-zero contrasts globally: set_sum_contrasts()
- For example analyses see: browseVignettes("afex")
************

Attaching package: 'afex'
The following object is masked from 'package:lme4':

    lmer
if (!require(summarytools)){
  install.packages("summarytools", dependencies = TRUE)
  require(summarytools)
}
Loading required package: summarytools
Warning in fun(libname, pkgname): couldn't connect to display ":0"
system might not have X11 capabilities; in case of errors when using dfSummary(), set st_options(use.x11 = FALSE)

Attaching package: 'summarytools'
The following object is masked from 'package:tibble':

    view
if (!require(psych)){
  install.packages("psych", dependencies = TRUE)
  require(psych)
}
Loading required package: psych

Attaching package: 'psych'
The following objects are masked from 'package:ggplot2':

    %+%, alpha

Import Data

dataset <- read_sav("Psykicks Mindfulness Data.sav")

Cleaning based on progress

(dataset %>%
  filter(Progress > 79) -> dataset.clean)
# A tibble: 124 × 44
   StartDate           EndDate             Status         IPAddress     Progress
   <dttm>              <dttm>              <dbl+lbl>      <chr>            <dbl>
 1 2024-03-13 16:47:14 2024-03-13 16:47:23 0 [IP Address] 73.224.66.184      100
 2 2024-03-13 19:17:10 2024-03-13 19:21:25 0 [IP Address] 76.122.42.81       100
 3 2024-03-13 19:34:32 2024-03-13 19:45:01 0 [IP Address] 73.6.5.118         100
 4 2024-03-13 21:12:43 2024-03-13 21:26:04 0 [IP Address] 92.119.18.122      100
 5 2024-03-14 09:56:42 2024-03-14 10:03:37 0 [IP Address] 139.62.222.1…      100
 6 2024-03-15 01:31:54 2024-03-15 15:07:03 0 [IP Address] 107.115.224.…      100
 7 2024-03-14 11:15:41 2024-03-14 11:24:47 0 [IP Address] 65.87.105.57        97
 8 2024-03-14 13:06:19 2024-03-14 13:25:21 0 [IP Address] 166.205.159.…       97
 9 2024-03-22 12:31:08 2024-03-22 12:40:46 0 [IP Address] 104.28.32.246      100
10 2024-03-25 17:07:22 2024-03-25 17:15:07 0 [IP Address] 139.62.222.2…      100
# ℹ 114 more rows
# ℹ 39 more variables: Duration__in_seconds_ <dbl>, Finished <dbl+lbl>,
#   RecordedDate <dttm>, ResponseId <chr>, RecipientLastName <chr>,
#   RecipientFirstName <chr>, RecipientEmail <chr>, ExternalReference <chr>,
#   LocationLatitude <chr>, LocationLongitude <chr>, DistributionChannel <chr>,
#   UserLanguage <chr>, Informed_Consent <dbl+lbl>, TP_1 <dbl+lbl>,
#   TP_3 <dbl+lbl>, TP_4 <dbl+lbl>, TP_5 <dbl+lbl>, TP_2 <dbl+lbl>, …

Cleaning based on duration in seconds

(dataset.clean %>%
  filter(Duration__in_seconds_ > 120) -> dataset.clean)
# A tibble: 119 × 44
   StartDate           EndDate             Status         IPAddress     Progress
   <dttm>              <dttm>              <dbl+lbl>      <chr>            <dbl>
 1 2024-03-13 19:17:10 2024-03-13 19:21:25 0 [IP Address] 76.122.42.81       100
 2 2024-03-13 19:34:32 2024-03-13 19:45:01 0 [IP Address] 73.6.5.118         100
 3 2024-03-13 21:12:43 2024-03-13 21:26:04 0 [IP Address] 92.119.18.122      100
 4 2024-03-14 09:56:42 2024-03-14 10:03:37 0 [IP Address] 139.62.222.1…      100
 5 2024-03-15 01:31:54 2024-03-15 15:07:03 0 [IP Address] 107.115.224.…      100
 6 2024-03-14 11:15:41 2024-03-14 11:24:47 0 [IP Address] 65.87.105.57        97
 7 2024-03-14 13:06:19 2024-03-14 13:25:21 0 [IP Address] 166.205.159.…       97
 8 2024-03-22 12:31:08 2024-03-22 12:40:46 0 [IP Address] 104.28.32.246      100
 9 2024-03-25 17:07:22 2024-03-25 17:15:07 0 [IP Address] 139.62.222.2…      100
10 2024-03-25 17:53:57 2024-03-25 18:05:40 0 [IP Address] 172.59.67.194      100
# ℹ 109 more rows
# ℹ 39 more variables: Duration__in_seconds_ <dbl>, Finished <dbl+lbl>,
#   RecordedDate <dttm>, ResponseId <chr>, RecipientLastName <chr>,
#   RecipientFirstName <chr>, RecipientEmail <chr>, ExternalReference <chr>,
#   LocationLatitude <chr>, LocationLongitude <chr>, DistributionChannel <chr>,
#   UserLanguage <chr>, Informed_Consent <dbl+lbl>, TP_1 <dbl+lbl>,
#   TP_3 <dbl+lbl>, TP_4 <dbl+lbl>, TP_5 <dbl+lbl>, TP_2 <dbl+lbl>, …

Create Mindfulness Meditation IV

(dataset.clean %>%
  mutate(MindfulnessIV = case_when(FL_10_DO_NoMindfulnessMeditation_PhysiologicalArousal == 1 ~ "No Mindfulness", 
                                      FL_10_DO_NoMindfulnessMeditation_NoPhysiologicalArousal == 1 ~ "No Mindfulness",
                                      FL_10_DO_MindfulnessMeditation_PhysiologicalArousal == 1 ~ "Mindfulness", 
                                      FL_10_DO_MindfulnessMeditation_NoPhysiologicalArousal == 1 ~ "Mindfulness")) -> dataset.clean)
# A tibble: 119 × 45
   StartDate           EndDate             Status         IPAddress     Progress
   <dttm>              <dttm>              <dbl+lbl>      <chr>            <dbl>
 1 2024-03-13 19:17:10 2024-03-13 19:21:25 0 [IP Address] 76.122.42.81       100
 2 2024-03-13 19:34:32 2024-03-13 19:45:01 0 [IP Address] 73.6.5.118         100
 3 2024-03-13 21:12:43 2024-03-13 21:26:04 0 [IP Address] 92.119.18.122      100
 4 2024-03-14 09:56:42 2024-03-14 10:03:37 0 [IP Address] 139.62.222.1…      100
 5 2024-03-15 01:31:54 2024-03-15 15:07:03 0 [IP Address] 107.115.224.…      100
 6 2024-03-14 11:15:41 2024-03-14 11:24:47 0 [IP Address] 65.87.105.57        97
 7 2024-03-14 13:06:19 2024-03-14 13:25:21 0 [IP Address] 166.205.159.…       97
 8 2024-03-22 12:31:08 2024-03-22 12:40:46 0 [IP Address] 104.28.32.246      100
 9 2024-03-25 17:07:22 2024-03-25 17:15:07 0 [IP Address] 139.62.222.2…      100
10 2024-03-25 17:53:57 2024-03-25 18:05:40 0 [IP Address] 172.59.67.194      100
# ℹ 109 more rows
# ℹ 40 more variables: Duration__in_seconds_ <dbl>, Finished <dbl+lbl>,
#   RecordedDate <dttm>, ResponseId <chr>, RecipientLastName <chr>,
#   RecipientFirstName <chr>, RecipientEmail <chr>, ExternalReference <chr>,
#   LocationLatitude <chr>, LocationLongitude <chr>, DistributionChannel <chr>,
#   UserLanguage <chr>, Informed_Consent <dbl+lbl>, TP_1 <dbl+lbl>,
#   TP_3 <dbl+lbl>, TP_4 <dbl+lbl>, TP_5 <dbl+lbl>, TP_2 <dbl+lbl>, …

Create Physiological Arousal IV

(dataset.clean %>%
  mutate(PhysiologicalArousalIV = case_when(FL_10_DO_NoMindfulnessMeditation_PhysiologicalArousal == 1 ~ "Physiological Arousal", 
                                      FL_10_DO_NoMindfulnessMeditation_NoPhysiologicalArousal == 1 ~ "No Physiological Arousal",
                                      FL_10_DO_MindfulnessMeditation_PhysiologicalArousal == 1 ~ "Physiological Arousal", 
                                      FL_10_DO_MindfulnessMeditation_NoPhysiologicalArousal == 1 ~ "No Physiological Arousal")) -> dataset.clean)
# A tibble: 119 × 46
   StartDate           EndDate             Status         IPAddress     Progress
   <dttm>              <dttm>              <dbl+lbl>      <chr>            <dbl>
 1 2024-03-13 19:17:10 2024-03-13 19:21:25 0 [IP Address] 76.122.42.81       100
 2 2024-03-13 19:34:32 2024-03-13 19:45:01 0 [IP Address] 73.6.5.118         100
 3 2024-03-13 21:12:43 2024-03-13 21:26:04 0 [IP Address] 92.119.18.122      100
 4 2024-03-14 09:56:42 2024-03-14 10:03:37 0 [IP Address] 139.62.222.1…      100
 5 2024-03-15 01:31:54 2024-03-15 15:07:03 0 [IP Address] 107.115.224.…      100
 6 2024-03-14 11:15:41 2024-03-14 11:24:47 0 [IP Address] 65.87.105.57        97
 7 2024-03-14 13:06:19 2024-03-14 13:25:21 0 [IP Address] 166.205.159.…       97
 8 2024-03-22 12:31:08 2024-03-22 12:40:46 0 [IP Address] 104.28.32.246      100
 9 2024-03-25 17:07:22 2024-03-25 17:15:07 0 [IP Address] 139.62.222.2…      100
10 2024-03-25 17:53:57 2024-03-25 18:05:40 0 [IP Address] 172.59.67.194      100
# ℹ 109 more rows
# ℹ 41 more variables: Duration__in_seconds_ <dbl>, Finished <dbl+lbl>,
#   RecordedDate <dttm>, ResponseId <chr>, RecipientLastName <chr>,
#   RecipientFirstName <chr>, RecipientEmail <chr>, ExternalReference <chr>,
#   LocationLatitude <chr>, LocationLongitude <chr>, DistributionChannel <chr>,
#   UserLanguage <chr>, Informed_Consent <dbl+lbl>, TP_1 <dbl+lbl>,
#   TP_3 <dbl+lbl>, TP_4 <dbl+lbl>, TP_5 <dbl+lbl>, TP_2 <dbl+lbl>, …

Create Test Performance DV

Rubric

  1. 4
  2. 3
  3. 2
  4. 1
  5. 4
  6. 4
  7. 3
(dataset.clean %>% 
  mutate(tp1 = case_when(TP_1 == 4 ~ 1,
                         TRUE ~ 0)) %>%
   mutate(tp2 = case_when(TP_2 == 3 ~ 1,
                         TRUE ~ 0)) %>%
   mutate(tp3 = case_when(TP_3 == 2 ~ 1,
                         TRUE ~ 0)) %>%
   mutate(tp4 = case_when(TP_4 == 1 ~ 1,
                         TRUE ~ 0)) %>%
   mutate(tp5 = case_when(TP_5 == 4 ~ 1,
                         TRUE ~ 0)) %>%
   mutate(tp6 = case_when(TP_6 == 4 ~ 1,
                         TRUE ~ 0)) %>%
   mutate(tp7 = case_when(TP_7 == 3 ~ 1,
                         TRUE ~ 0)) -> dataset.clean)
# A tibble: 119 × 53
   StartDate           EndDate             Status         IPAddress     Progress
   <dttm>              <dttm>              <dbl+lbl>      <chr>            <dbl>
 1 2024-03-13 19:17:10 2024-03-13 19:21:25 0 [IP Address] 76.122.42.81       100
 2 2024-03-13 19:34:32 2024-03-13 19:45:01 0 [IP Address] 73.6.5.118         100
 3 2024-03-13 21:12:43 2024-03-13 21:26:04 0 [IP Address] 92.119.18.122      100
 4 2024-03-14 09:56:42 2024-03-14 10:03:37 0 [IP Address] 139.62.222.1…      100
 5 2024-03-15 01:31:54 2024-03-15 15:07:03 0 [IP Address] 107.115.224.…      100
 6 2024-03-14 11:15:41 2024-03-14 11:24:47 0 [IP Address] 65.87.105.57        97
 7 2024-03-14 13:06:19 2024-03-14 13:25:21 0 [IP Address] 166.205.159.…       97
 8 2024-03-22 12:31:08 2024-03-22 12:40:46 0 [IP Address] 104.28.32.246      100
 9 2024-03-25 17:07:22 2024-03-25 17:15:07 0 [IP Address] 139.62.222.2…      100
10 2024-03-25 17:53:57 2024-03-25 18:05:40 0 [IP Address] 172.59.67.194      100
# ℹ 109 more rows
# ℹ 48 more variables: Duration__in_seconds_ <dbl>, Finished <dbl+lbl>,
#   RecordedDate <dttm>, ResponseId <chr>, RecipientLastName <chr>,
#   RecipientFirstName <chr>, RecipientEmail <chr>, ExternalReference <chr>,
#   LocationLatitude <chr>, LocationLongitude <chr>, DistributionChannel <chr>,
#   UserLanguage <chr>, Informed_Consent <dbl+lbl>, TP_1 <dbl+lbl>,
#   TP_3 <dbl+lbl>, TP_4 <dbl+lbl>, TP_5 <dbl+lbl>, TP_2 <dbl+lbl>, …
(dataset.clean %>%
  rowwise()%>%
  mutate(TP_totalCorrect = sum(tp1, tp2, tp3, tp4, tp5, tp6, tp7)) -> dataset.clean)
# A tibble: 119 × 54
# Rowwise: 
   StartDate           EndDate             Status         IPAddress     Progress
   <dttm>              <dttm>              <dbl+lbl>      <chr>            <dbl>
 1 2024-03-13 19:17:10 2024-03-13 19:21:25 0 [IP Address] 76.122.42.81       100
 2 2024-03-13 19:34:32 2024-03-13 19:45:01 0 [IP Address] 73.6.5.118         100
 3 2024-03-13 21:12:43 2024-03-13 21:26:04 0 [IP Address] 92.119.18.122      100
 4 2024-03-14 09:56:42 2024-03-14 10:03:37 0 [IP Address] 139.62.222.1…      100
 5 2024-03-15 01:31:54 2024-03-15 15:07:03 0 [IP Address] 107.115.224.…      100
 6 2024-03-14 11:15:41 2024-03-14 11:24:47 0 [IP Address] 65.87.105.57        97
 7 2024-03-14 13:06:19 2024-03-14 13:25:21 0 [IP Address] 166.205.159.…       97
 8 2024-03-22 12:31:08 2024-03-22 12:40:46 0 [IP Address] 104.28.32.246      100
 9 2024-03-25 17:07:22 2024-03-25 17:15:07 0 [IP Address] 139.62.222.2…      100
10 2024-03-25 17:53:57 2024-03-25 18:05:40 0 [IP Address] 172.59.67.194      100
# ℹ 109 more rows
# ℹ 49 more variables: Duration__in_seconds_ <dbl>, Finished <dbl+lbl>,
#   RecordedDate <dttm>, ResponseId <chr>, RecipientLastName <chr>,
#   RecipientFirstName <chr>, RecipientEmail <chr>, ExternalReference <chr>,
#   LocationLatitude <chr>, LocationLongitude <chr>, DistributionChannel <chr>,
#   UserLanguage <chr>, Informed_Consent <dbl+lbl>, TP_1 <dbl+lbl>,
#   TP_3 <dbl+lbl>, TP_4 <dbl+lbl>, TP_5 <dbl+lbl>, TP_2 <dbl+lbl>, …

ANOVA

aov_ez(id = "ResponseId", 
       dv = "TP_totalCorrect", 
       data = dataset.clean, 
       between=c("PhysiologicalArousalIV", "MindfulnessIV"),
       anova_table = list(es = "pes"))
Converting to factor: PhysiologicalArousalIV, MindfulnessIV
Contrasts set to contr.sum for the following variables: PhysiologicalArousalIV, MindfulnessIV
Anova Table (Type 3 tests)

Response: TP_totalCorrect
                                Effect     df  MSE      F  pes p.value
1               PhysiologicalArousalIV 1, 115 1.97 3.48 + .029    .065
2                        MindfulnessIV 1, 115 1.97   0.38 .003    .540
3 PhysiologicalArousalIV:MindfulnessIV 1, 115 1.97   0.48 .004    .490
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1