Descriptive
variables <- c("IN1", "IN2",
"HA1", "HA2",
"Degro1", "Degro2")
S4 %>%
count(Condition)
## # A tibble: 5 × 2
## Condition n
## <chr> <int>
## 1 Cambridge 523
## 2 Flammable 527
## 3 Harm 525
## 4 Harm + Norm 522
## 5 <NA> 4
S4 <- S4 %>%
filter(!is.na(Condition))
S4 %>%
count(Condition)
## # A tibble: 4 × 2
## Condition n
## <chr> <int>
## 1 Cambridge 523
## 2 Flammable 527
## 3 Harm 525
## 4 Harm + Norm 522
summary_table <- S4 %>%
group_by(Condition) %>%
summarise(across(all_of(variables), list(mean = ~ mean(.x, na.rm = TRUE),
sd = ~ sd(.x, na.rm = TRUE)))) %>%
pivot_longer(-Condition, names_to = c("Variable", ".value"),
names_pattern = "(.*)_(mean|sd)") %>%
arrange(Variable, Condition)
summary_table <- summary_table %>%
mutate(Mean_SD = paste0(round(mean, 2), " (", round(sd, 2), ")")) %>%
select(Variable, Condition, Mean_SD)
final_table <- summary_table %>%
pivot_wider(names_from = Condition, values_from = Mean_SD)
final_table <- final_table[, colSums(is.na(final_table)) < nrow(final_table)]
final_table %>%
kbl(caption = "Means and Standard Deviation by Condition",
format = "html",
align = "c",
digits = 2) %>%
kable_styling(full_width = FALSE,
position = "center",
font_size = 12) %>%
row_spec(0, bold = TRUE)
Means and Standard Deviation by Condition
|
Variable
|
Cambridge
|
Flammable
|
Harm
|
Harm + Norm
|
|
Degro1
|
3.41 (1.3)
|
3.24 (1.31)
|
3.39 (1.28)
|
3.33 (1.33)
|
|
Degro2
|
3.53 (1.33)
|
3.3 (1.4)
|
3.5 (1.25)
|
3.42 (1.38)
|
|
HA1
|
4.85 (1.15)
|
4.82 (1.05)
|
4.81 (1.07)
|
4.74 (1.12)
|
|
HA2
|
4.87 (1.24)
|
4.83 (1.13)
|
4.84 (1.12)
|
4.7 (1.3)
|
|
IN1
|
2.85 (1.2)
|
2.53 (1.17)
|
2.81 (1.16)
|
3.06 (1.27)
|
|
IN2
|
3.16 (1.22)
|
2.94 (1.19)
|
3.19 (1.2)
|
3.45 (1.23)
|
Correlation
dvs <- S4[, c("IN1", "IN2",
"HA1", "HA2",
"Degro1", "Degro2")]
cor_matrix <- cor(dvs, use = "complete.obs")
print(cor_matrix)
## IN1 IN2 HA1 HA2 Degro1 Degro2
## IN1 1.0000000 0.6378206 0.2889961 0.2699962 0.4442693 0.4441357
## IN2 0.6378206 1.0000000 0.3826041 0.3859057 0.5562734 0.5550745
## HA1 0.2889961 0.3826041 1.0000000 0.7261133 0.4996712 0.5321865
## HA2 0.2699962 0.3859057 0.7261133 1.0000000 0.4988231 0.5391493
## Degro1 0.4442693 0.5562734 0.4996712 0.4988231 1.0000000 0.7144461
## Degro2 0.4441357 0.5550745 0.5321865 0.5391493 0.7144461 1.0000000
corrplot(cor_matrix, method = "circle", type = "upper",
tl.col = "black", tl.srt = 45,
title = "Correlation Plot", mar = c(0, 0, 1, 0))

#Average pairs
S4$IN <- rowMeans(S4[, c("IN1", "IN2")], na.rm = TRUE)
S4$Degro <- rowMeans(S4[, c("Degro1", "Degro2")], na.rm = TRUE)
S4$HA <- rowMeans(S4[, c("HA1", "HA2")], na.rm = TRUE)
Compared to Cambridge Sign
summary(lm(S4$Degro ~S4$Condition))
##
## Call:
## lm(formula = S4$Degro ~ S4$Condition)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.4684 -0.8726 0.1274 1.0543 1.7268
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.46845 0.05362 64.689 < 2e-16 ***
## S4$ConditionFlammable -0.19521 0.07568 -2.579 0.00997 **
## S4$ConditionHarm -0.02274 0.07575 -0.300 0.76410
## S4$ConditionHarm + Norm -0.09585 0.07586 -1.263 0.20658
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.226 on 2093 degrees of freedom
## Multiple R-squared: 0.003859, Adjusted R-squared: 0.002431
## F-statistic: 2.703 on 3 and 2093 DF, p-value: 0.04411
summary(lm(S4$HA ~S4$Condition))
##
## Call:
## lm(formula = S4$HA ~ S4$Condition)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.8633 -0.7261 0.1781 0.7739 1.2739
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.86329 0.04671 104.108 <2e-16 ***
## S4$ConditionFlammable -0.04261 0.06594 -0.646 0.518
## S4$ConditionHarm -0.04138 0.06600 -0.627 0.531
## S4$ConditionHarm + Norm -0.13724 0.06609 -2.076 0.038 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.068 on 2093 degrees of freedom
## Multiple R-squared: 0.00221, Adjusted R-squared: 0.0007797
## F-statistic: 1.545 on 3 and 2093 DF, p-value: 0.2009
summary(lm(S4$IN ~S4$Condition))
##
## Call:
## lm(formula = S4$IN ~ S4$Condition)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.25096 -0.75096 -0.00095 0.76281 2.26281
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.00669 0.04760 63.162 < 2e-16 ***
## S4$ConditionFlammable -0.26950 0.06719 -4.011 6.26e-05 ***
## S4$ConditionHarm -0.00574 0.06726 -0.085 0.931997
## S4$ConditionHarm + Norm 0.24427 0.06735 3.627 0.000294 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.089 on 2093 degrees of freedom
## Multiple R-squared: 0.02718, Adjusted R-squared: 0.02578
## F-statistic: 19.49 on 3 and 2093 DF, p-value: 1.839e-12
Compared to Flammable Sign
S4$Condition <- relevel(factor(S4$Condition), ref = "Flammable")
summary(lm(S4$Degro ~S4$Condition))
##
## Call:
## lm(formula = S4$Degro ~ S4$Condition)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.4684 -0.8726 0.1274 1.0543 1.7268
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.27324 0.05341 61.282 < 2e-16 ***
## S4$ConditionCambridge 0.19521 0.07568 2.579 0.00997 **
## S4$ConditionHarm 0.17247 0.07561 2.281 0.02265 *
## S4$ConditionHarm + Norm 0.09936 0.07572 1.312 0.18958
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.226 on 2093 degrees of freedom
## Multiple R-squared: 0.003859, Adjusted R-squared: 0.002431
## F-statistic: 2.703 on 3 and 2093 DF, p-value: 0.04411
summary(lm(S4$HA ~S4$Condition))
##
## Call:
## lm(formula = S4$HA ~ S4$Condition)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.8633 -0.7261 0.1781 0.7739 1.2739
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.820683 0.046536 103.590 <2e-16 ***
## S4$ConditionCambridge 0.042606 0.065938 0.646 0.518
## S4$ConditionHarm 0.001222 0.065875 0.019 0.985
## S4$ConditionHarm + Norm -0.094629 0.065970 -1.434 0.152
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.068 on 2093 degrees of freedom
## Multiple R-squared: 0.00221, Adjusted R-squared: 0.0007797
## F-statistic: 1.545 on 3 and 2093 DF, p-value: 0.2009
summary(lm(S4$IN ~S4$Condition))
##
## Call:
## lm(formula = S4$IN ~ S4$Condition)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.25096 -0.75096 -0.00095 0.76281 2.26281
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.73719 0.04742 57.720 < 2e-16 ***
## S4$ConditionCambridge 0.26950 0.06719 4.011 6.26e-05 ***
## S4$ConditionHarm 0.26376 0.06713 3.929 8.80e-05 ***
## S4$ConditionHarm + Norm 0.51377 0.06722 7.643 3.22e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.089 on 2093 degrees of freedom
## Multiple R-squared: 0.02718, Adjusted R-squared: 0.02578
## F-statistic: 19.49 on 3 and 2093 DF, p-value: 1.839e-12