Data 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.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ 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(psych)){
  install.packages("psych", dependencies = TRUE)
  require(psych)
}
Loading required package: psych

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

    %+%, alpha
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

Import Data

SPSS

dataset <- read_sav("CincoData.sav")

Clean Data

(dataset %>% 
  filter(Duration__in_seconds_ > 120) %>% 
  filter(!is.na(Stress1)) %>% 
  mutate(age_as_a_number = as.numeric(Age)) -> dataset.clean)
# A tibble: 34 × 31
   StartDate           EndDate             Status         IPAddress     Progress
   <dttm>              <dttm>              <dbl+lbl>      <chr>            <dbl>
 1 2024-04-03 11:20:26 2024-04-03 11:23:06 0 [IP Address] 67.190.227.16      100
 2 2024-04-03 11:21:29 2024-04-03 11:23:35 0 [IP Address] 139.62.223.1…      100
 3 2024-04-03 11:34:39 2024-04-03 11:40:53 0 [IP Address] 73.53.224.92       100
 4 2024-04-03 11:43:20 2024-04-03 11:46:09 0 [IP Address] 174.212.33.2…      100
 5 2024-04-03 11:55:18 2024-04-03 11:57:59 0 [IP Address] 99.171.78.207      100
 6 2024-04-03 12:27:56 2024-04-03 12:32:24 0 [IP Address] 104.28.92.177      100
 7 2024-04-03 12:33:26 2024-04-03 12:35:30 0 [IP Address] 172.59.69.207      100
 8 2024-04-03 13:02:23 2024-04-03 13:10:47 0 [IP Address] 38.85.147.114      100
 9 2024-04-03 13:18:30 2024-04-03 13:21:08 0 [IP Address] 50.204.243.1…      100
10 2024-04-03 13:27:04 2024-04-03 13:29:20 0 [IP Address] 172.59.69.78       100
# ℹ 24 more rows
# ℹ 26 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>, Q1_3 <dbl+lbl>, Q1_4 <dbl+lbl>, Stress1 <dbl+lbl>,
#   Gender <chr>, Race <chr>, Age <chr>, Exit_question <chr>, …

Create Compensation IV

dataset.clean %>%
  mutate(compensationIV = case_when(FL_10_DO_story1AboveavgCom_CollegedegreeAshley == 1 ~ "Above",
                                    FL_10_DO_Story2AboveAvgComp_NoCollDegMakenzie == 1 ~ "Above",
                                    FL_10_DO_Story3BelowAvgComp_CollegeDegMillicent == 1 ~ "Below",
                                    FL_10_DO_Story4BelowAvg_NoCollDegAraya == 1 ~ "Below" )) -> dataset.clean

Create Degree IV

dataset.clean %>%
  mutate(degreeIV = case_when(FL_10_DO_story1AboveavgCom_CollegedegreeAshley == 1 ~ "Yes",
                                    FL_10_DO_Story2AboveAvgComp_NoCollDegMakenzie == 1 ~ "No",
                                    FL_10_DO_Story3BelowAvgComp_CollegeDegMillicent == 1 ~ "Yes",
                                    FL_10_DO_Story4BelowAvg_NoCollDegAraya == 1 ~ "No" )) -> dataset.clean

ANOVA

dataset.clean %>%
  mutate(DV = as.numeric(Stress1)) -> dataset.clean
aov_ez(id = "ResponseId", dv = "DV", data = dataset.clean, between=c("degreeIV", "compensationIV"))
Converting to factor: degreeIV, compensationIV
Contrasts set to contr.sum for the following variables: degreeIV, compensationIV
Anova Table (Type 3 tests)

Response: DV
                   Effect    df  MSE      F   ges p.value
1                degreeIV 1, 30 1.59   0.02 <.001    .891
2          compensationIV 1, 30 1.59 3.62 +  .108    .067
3 degreeIV:compensationIV 1, 30 1.59   1.56  .049    .222
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1