library(qualtRics)
data <- read_survey("~/Desktop/MASTER/RLang/Work Directory/results-fixed.csv")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## .default = col_double(),
## StartDate = col_datetime(format = ""),
## EndDate = col_datetime(format = ""),
## IPAddress = col_character(),
## RecordedDate = col_datetime(format = ""),
## ResponseId = col_character(),
## RecipientLastName = col_logical(),
## RecipientFirstName = col_logical(),
## RecipientEmail = col_logical(),
## ExternalReference = col_logical(),
## DistributionChannel = col_character(),
## UserLanguage = col_character(),
## Intro_3_4_TEXT = col_character(),
## Control = col_character(),
## Test = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
head(data)
## # A tibble: 6 × 54
## StartDate EndDate Status IPAddress Progress
## <dttm> <dttm> <dbl> <chr> <dbl>
## 1 2023-12-01 13:02:50 2023-12-01 13:06:40 0 89.144.197.164 100
## 2 2023-12-01 13:01:56 2023-12-01 13:07:49 0 178.115.61.146 100
## 3 2023-12-01 13:04:38 2023-12-01 13:07:55 0 77.118.213.190 100
## 4 2023-12-01 13:05:08 2023-12-01 13:09:06 0 85.255.234.253 100
## 5 2023-12-01 13:09:59 2023-12-01 13:14:59 0 213.142.97.199 100
## 6 2023-12-01 13:21:24 2023-12-01 13:25:23 0 176.199.208.146 100
## # ℹ 49 more variables: `Duration (in seconds)` <dbl>, Finished <dbl>,
## # RecordedDate <dttm>, ResponseId <chr>, RecipientLastName <lgl>,
## # RecipientFirstName <lgl>, RecipientEmail <lgl>, ExternalReference <lgl>,
## # LocationLatitude <dbl>, LocationLongitude <dbl>, DistributionChannel <chr>,
## # UserLanguage <chr>, Intro_2 <dbl>, Intro_3 <dbl>, Intro_3_4_TEXT <chr>,
## # Intro_4_moderators_1 <dbl>, Intro_4_moderators_2 <dbl>,
## # Intro_4_moderators_3 <dbl>, Intro_6_10 <dbl>, Intro_6_11 <dbl>, …
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ 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
library(dplyr)
library(psych)
##
## Attaching package: 'psych'
##
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
data_new <- data %>%
mutate(price = coalesce(CG1_price_1, TG1_price_1)) %>%
mutate(Price_attribute = coalesce(CG2_attributes_10, TG1_attributes_10)) %>%
mutate(Style_attribute = coalesce(CG2_attributes_11, TG1_attributes_11)) %>%
mutate(Sust_attribute = coalesce(CG2_attributes_12, TG1_attributes_12)) %>%
mutate(Quality_attribute = coalesce(CG2_attributes_13, TG1_attributes_13)) %>%
mutate(Helping_Env = coalesce(CG2_sust1, TG2_sust1)) %>%
mutate(Eco_fr_material = coalesce(CG3_sust2, TG3_sust2)) %>%
mutate(costs_more = coalesce(CG4_sust3, TG4_sust3)) %>%
mutate(how_fashionable = coalesce(CG6_styl1, TG6_styl1)) %>%
mutate(likely_purchase = coalesce(CG7_purchase, TG7_purchase)) %>%
mutate(groups = coalesce(Test, Control))
data_clear <- data_new %>% filter(Finished == 1) %>%
select(
Intro_2, Intro_3, Intro_4_moderators_1, Intro_4_moderators_2, Intro_4_moderators_3, Intro_6_10,
Intro_6_11, Intro_6_12, Intro_6_13, Intro_7_1, price, Price_attribute, Style_attribute, Sust_attribute, Quality_attribute, Helping_Env,
Eco_fr_material, costs_more, how_fashionable, likely_purchase, groups, Age, Gender, Income, Education
)
head(data)
## # A tibble: 6 × 54
## StartDate EndDate Status IPAddress Progress
## <dttm> <dttm> <dbl> <chr> <dbl>
## 1 2023-12-01 13:02:50 2023-12-01 13:06:40 0 89.144.197.164 100
## 2 2023-12-01 13:01:56 2023-12-01 13:07:49 0 178.115.61.146 100
## 3 2023-12-01 13:04:38 2023-12-01 13:07:55 0 77.118.213.190 100
## 4 2023-12-01 13:05:08 2023-12-01 13:09:06 0 85.255.234.253 100
## 5 2023-12-01 13:09:59 2023-12-01 13:14:59 0 213.142.97.199 100
## 6 2023-12-01 13:21:24 2023-12-01 13:25:23 0 176.199.208.146 100
## # ℹ 49 more variables: `Duration (in seconds)` <dbl>, Finished <dbl>,
## # RecordedDate <dttm>, ResponseId <chr>, RecipientLastName <lgl>,
## # RecipientFirstName <lgl>, RecipientEmail <lgl>, ExternalReference <lgl>,
## # LocationLatitude <dbl>, LocationLongitude <dbl>, DistributionChannel <chr>,
## # UserLanguage <chr>, Intro_2 <dbl>, Intro_3 <dbl>, Intro_3_4_TEXT <chr>,
## # Intro_4_moderators_1 <dbl>, Intro_4_moderators_2 <dbl>,
## # Intro_4_moderators_3 <dbl>, Intro_6_10 <dbl>, Intro_6_11 <dbl>, …
t.test(price ~ groups, data = data_clear, mu = 0, alternative = "two.sided", conf.level = 0.95, var.equal = FALSE)
##
## Welch Two Sample t-test
##
## data: price by groups
## t = -6.906, df = 110.36, p-value = 3.34e-10
## alternative hypothesis: true difference in means between group A and group B is not equal to 0
## 95 percent confidence interval:
## -51.86156 -28.73433
## sample estimates:
## mean in group A mean in group B
## 45.98276 86.28070
library(ggstatsplot)
## You can cite this package as:
## Patil, I. (2021). Visualizations with statistical details: The 'ggstatsplot' approach.
## Journal of Open Source Software, 6(61), 3167, doi:10.21105/joss.03167
ggbetweenstats(
data = data_clear,
plot.type = "box",
x = groups, # 2 groups
y = price,
type = "p", # default
effsize.type = "d", # display effect size (Cohen's d in output)
messages = FALSE,
bf.message = FALSE,
mean.ci = TRUE,
title = "Mean price for control and test groups"
)
describeBy(data_clear$likely_purchase, data_clear$groups)
##
## Descriptive statistics by group
## group: A
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 58 2.33 1.03 2 2.29 1.48 1 4 3 0.27 -1.11 0.14
## ------------------------------------------------------------
## group: B
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 58 2.95 1.11 3 3.04 1.48 1 4 3 -0.5 -1.24 0.15
t.test(likely_purchase ~ groups, data = data_clear, mu = 0, alternative = "two.sided", conf.level = 0.95, var.equal = FALSE)
##
## Welch Two Sample t-test
##
## data: likely_purchase by groups
## t = -3.1107, df = 113.34, p-value = 0.002361
## alternative hypothesis: true difference in means between group A and group B is not equal to 0
## 95 percent confidence interval:
## -1.0159841 -0.2253952
## sample estimates:
## mean in group A mean in group B
## 2.327586 2.948276
library(ggstatsplot)
ggbetweenstats(
data = data_clear,
plot.type = "box",
x = groups, # 2 groups
y = likely_purchase,
type = "p", # default
effsize.type = "d", # display effect size (Cohen's d in output)
messages = FALSE,
bf.message = FALSE,
mean.ci = TRUE,
title = "Mean desire to purchase for test and control groups"
)
We had an independent-means t-test, and