Note. Boxplots display the interquartile range (IQR, center box), and the whiskers extend 1.5*IQR from the lower and upper hinge. The white point indicates the mean and the white center line indicates the median.
load("data/wrangled.RData")
# TBD
Run multilevel regression to extract the effect sizes and covariance matrices
# run regresion
lmer_quality_contemporary <-
lmer(
quality_overall_1 ~
keymotive_fulfillemt_1_cwc + (1 + keymotive_fulfillemt_1_cwc | PID),
data = dtWorkerSupp$workerOutWithinBetween
)
lmer_attitude_contemporary <-
lmer(
thermometerDutch_1 ~
keymotive_fulfillemt_1_cwc + (1 + keymotive_fulfillemt_1_cwc | PID),
data = dtWorkerSupp$workerOutWithinBetween
)
lmer_attitude_need_quality_contemporary <-
lmer(
thermometerDutch_1 ~
keymotive_fulfillemt_1_cwc + quality_overall_1_cwc + (1 + keymotive_fulfillemt_1_cwc + quality_overall_1_cwc | PID),
data = dtWorkerSupp$workerOutWithinBetween
)
For the main analyses we have four fixed effects of interest. (1) The effect of need fulfillment on interaction quality: b = 0.433, (2) the effect of need fulfillment on outgroup attitudes: b = 0.175, (3) the effect of need fulfillment on outgroup attitudes while controlling for interaction quality: b = 0.037, as well as (4) the effect of interaction quality on outgroup attitudes while controlling for need fulfillment: b = 0.226.
nsim <- 1000
progress <- FALSE
n_ppt <- 250
n_measure <- 180 # 3 months with 2 measurements per day
# extrapolate data:
sim_n_quality <- extend(lmer_quality_contemporary, along="PID", n = n_ppt)
sim_n_attitude <- extend(lmer_attitude_contemporary, along="PID", n = n_ppt)
sim_n_attitude_full <- extend(lmer_attitude_need_quality_contemporary, along="PID", n = n_ppt)
# extrapolate data:
sim_t_quality <- extend(lmer_quality_contemporary, within="PID", n = n_measure)
sim_t_attitude <- extend(lmer_attitude_contemporary, within="PID", n = n_measure)
sim_t_attitude_full <- extend(lmer_attitude_need_quality_contemporary, within="PID", n = n_measure)
Simulate different participant numbers for all fixed effects.
Quality ~ NeedFulfill
for different numbers of participants# Run and plot simulations
pc_n_quality_need = powerCurve(
fit = sim_n_quality,
test = simr::fixed("keymotive_fulfillemt_1_cwc", "t"),
along = "PID",
progress = progress,
breaks = seq(1, 12, 1),
nsim = nsim
)
plot(pc_n_quality_need) +
title("Quality given Need Fulfillment [participant numbers]")
## integer(0)
Attitude ~ NeedFulfill
for different numbers of participants# Run and plot simulations
pc_n_attitude_need = powerCurve(
fit = sim_n_attitude,
test = simr::fixed("keymotive_fulfillemt_1_cwc", "t"),
along = "PID",
progress = progress,
breaks = seq(1, 45, 1),
nsim = nsim
)
plot(pc_n_attitude_need) +
title("Attitudes given Need Fulfillment [participant numbers]")
## integer(0)
Attitude ~ NeedFulfill + Quality
for different numbers of participantswe expect this to be super small. Keep in mind that the b = 0.037. So even with a large number of participants, we would not expect these effects to be meaningful.
# Run and plot simulations
pc_n_attitude_need = powerCurve(
fit = sim_n_attitude_full,
test = simr::fixed("keymotive_fulfillemt_1_cwc", "t"),
along = "PID",
progress = progress,
breaks = seq(10, 250, 10),
nsim = nsim
)
plot(pc_n_attitude_need) +
title("Attitudes given Need Fulfillment (controling for Quality) [participant numbers]")
## integer(0)
Attitude ~ Quality
given NeedFulfill for different numbers of participants# Run and plot simulations
pc_n_attitude_full_quality = powerCurve(
fit = sim_t_attitude_full,
test = simr::fixed("quality_overall_1_cwc", "t"),
along = "PID",
progress = progress,
breaks = seq(1, 25, 1),
nsim = nsim
)
plot(pc_n_attitude_full_quality) +
title("Attitudes given Quality (controlling for Need Fulfillment) [participant numbers]")
## integer(0)
Simulate different number of within person measurements.
Quality ~ NeedFulfill
for different numbers of measurements# Run and plot simulations
pc_t_quality_need = powerCurve(
fit = sim_t_quality,
test = simr::fixed("keymotive_fulfillemt_1_cwc", "t"),
within = "PID",
progress = progress,
breaks = seq(1, 20, 1),
nsim = nsim
)
plot(pc_t_quality_need) +
title("Quality given Need Fulfillment [measurement numbers]")
## integer(0)
Attitude ~ NeedFulfill
for different numbers of measurements# Run and plot simulations
pc_t_attitude_need = powerCurve(
fit = sim_t_attitude,
test = simr::fixed("keymotive_fulfillemt_1_cwc", "t"),
within = "PID",
progress = progress,
breaks = seq(1, 25, 1),
nsim = nsim
)
plot(pc_t_attitude_need) +
title("Attitudes given Need Fulfillment [measurement numbers]")
## integer(0)
Attitude ~ NeedFulfill
given Quality for different numbers of measurementswe expect this to be super small. Keep in mind that the b = 0.037. So even with a large number of measurements, we would not expect these effects to be meaningful.
# Run and plot simulations
pc_t_attitude_full_need = powerCurve(
fit = sim_t_attitude_full,
test = simr::fixed("keymotive_fulfillemt_1_cwc", "t"),
within = "PID",
progress = progress,
breaks = seq(10, 180, 10),
nsim = nsim
)
plot(pc_t_attitude_full_need) +
title("Attitudes given Need Fulfillment (controlling for Quality) [measurement numbers]")
## integer(0)
Attitude ~ Quality
given NeedFulfill for different numbers of measurements# Run and plot simulations
pc_t_attitude_full_quality = powerCurve(
fit = sim_t_attitude_full,
test = simr::fixed("quality_overall_1_cwc", "t"),
within = "PID",
progress = progress,
breaks = seq(1, 15, 1),
nsim = nsim
)
plot(pc_t_attitude_full_quality) +
title("Attitudes given Quality (controlling for Need Fulfillment) [measurement numbers]")
## integer(0)
# save simulations, because this takes for freakin' ever.
save(list = ls(pattern = "plt."),
file = "data/S1_Workers/processed/PowerSimPlots.RData")
#load("PowerSimPlots.RData")
The full session information with all relevant system information and all loaded and installed packages is available in the collapsible section below.
Setting | Value |
---|---|
version | R version 4.3.0 (2023-04-21) |
os | macOS Ventura 13.3.1 |
system | x86_64, darwin20 |
ui | X11 |
language | (EN) |
collate | en_US.UTF-8 |
ctype | en_US.UTF-8 |
tz | Europe/Amsterdam |
date | 2023-05-19 |
pandoc | 3.1.1 @ /usr/local/bin/ (via rmarkdown) |
Package | Loaded version | Date | Source |
---|---|---|---|
binom | 1.1-1.1 | 2022-05-02 | CRAN (R 4.3.0) |
bookdown | 0.34 | 2023-05-09 | CRAN (R 4.3.0) |
brms | 2.19.0 | 2023-03-14 | CRAN (R 4.3.0) |
car | 3.1-2 | 2023-03-30 | CRAN (R 4.3.0) |
carData | 3.0-5 | 2022-01-06 | CRAN (R 4.3.0) |
data.table | 1.14.8 | 2023-02-17 | CRAN (R 4.3.0) |
devtools | 2.4.5 | 2022-10-11 | CRAN (R 4.3.0) |
dplyr | 1.1.2 | 2023-04-20 | CRAN (R 4.3.0) |
ggpattern | 1.0.1 | 2022-11-09 | CRAN (R 4.3.0) |
ggplot2 | 3.4.2 | 2023-04-03 | CRAN (R 4.3.0) |
ggridges | 0.5.4 | 2022-09-26 | CRAN (R 4.3.0) |
ggthemes | 4.2.4 | 2021-01-20 | CRAN (R 4.3.0) |
gridExtra | 2.3 | 2017-09-09 | CRAN (R 4.3.0) |
haven | 2.5.2 | 2023-02-28 | CRAN (R 4.3.0) |
Hmisc | 5.1-0 | 2023-05-08 | CRAN (R 4.3.0) |
iterators | 1.0.14 | 2022-02-05 | CRAN (R 4.3.0) |
kableExtra | 1.3.4 | 2021-02-20 | CRAN (R 4.3.0) |
knitr | 1.42 | 2023-01-25 | CRAN (R 4.3.0) |
lme4 | 1.1-33 | 2023-04-25 | CRAN (R 4.3.0) |
lmerTest | 3.1-3 | 2020-10-23 | CRAN (R 4.3.0) |
lubridate | 1.9.2 | 2023-02-10 | CRAN (R 4.3.0) |
Matrix | 1.5-4 | 2023-04-04 | CRAN (R 4.3.0) |
pander | 0.6.5 | 2022-03-18 | CRAN (R 4.3.0) |
papaja | 0.1.1 | 2022-07-05 | CRAN (R 4.3.0) |
pbkrtest | 0.5.2 | 2023-01-19 | CRAN (R 4.3.0) |
plotly | 4.10.1 | 2022-11-07 | CRAN (R 4.3.0) |
plotrix | 3.8-2 | 2021-09-08 | CRAN (R 4.3.0) |
plyr | 1.8.8 | 2022-11-11 | CRAN (R 4.3.0) |
psych | 2.3.3 | 2023-03-18 | CRAN (R 4.3.0) |
purrr | 1.0.1 | 2023-01-10 | CRAN (R 4.3.0) |
RColorBrewer | 1.1-3 | 2022-04-03 | CRAN (R 4.3.0) |
Rcpp | 1.0.10 | 2023-01-22 | CRAN (R 4.3.0) |
remedy | 0.1.0 | 2018-12-03 | CRAN (R 4.3.0) |
reshape2 | 1.4.4 | 2020-04-09 | CRAN (R 4.3.0) |
RLRsim | 3.1-8 | 2022-03-16 | CRAN (R 4.3.0) |
rmarkdown | 2.21 | 2023-03-26 | CRAN (R 4.3.0) |
sessioninfo | 1.2.2 | 2021-12-06 | CRAN (R 4.3.0) |
simr | 1.0.7 | 2023-04-13 | CRAN (R 4.3.0) |
stringi | 1.7.12 | 2023-01-11 | CRAN (R 4.3.0) |
stringr | 1.5.0 | 2022-12-02 | CRAN (R 4.3.0) |
testthat | 3.1.8 | 2023-05-04 | CRAN (R 4.3.0) |
tibble | 3.2.1 | 2023-03-20 | CRAN (R 4.3.0) |
tinylabels | 0.2.3 | 2022-02-06 | CRAN (R 4.3.0) |
usethis | 2.1.6 | 2022-05-25 | CRAN (R 4.3.0) |
R version 4.3.0 (2023-04-21)
Platform: x86_64-apple-darwin20 (64-bit)
locale: en_US.UTF-8||en_US.UTF-8||en_US.UTF-8||C||en_US.UTF-8||en_US.UTF-8
attached base packages:
other attached packages:
loaded via a namespace (and not attached):