### groupLikely means
groupLikely <- aggregate(d2$groupLikelihood ~ d2$Introspection_Condition,
FUN = mean, na.rm = T)
groupLikely
## d2$Introspection_Condition d2$groupLikelihood
## 1 control 3.720511
## 2 introspect 3.658929
### groupLikely means
groupLikely <- aggregate(d2$groupLikelihood ~(d2$Introspection_Condition*d2$country_factor),
FUN = mean, na.rm = T)
groupLikely
## d2$Introspection_Condition d2$country_factor d2$groupLikelihood
## 1 control Brazil 3.706667
## 2 introspect Brazil 3.678191
## 3 control Korea 4.284530
## 4 introspect Korea 4.201705
## 5 control Sweden 3.128713
## 6 introspect Sweden 3.034722
## 7 control UK 4.324397
## 8 introspect UK 4.195187
## 9 control US 3.476253
## 10 introspect US 3.475921
#descriptive graphs
## violin plot
p1 <- ggplot(d2,
aes(y = partyLikely,
x = country,
group = interaction(as.factor(Introspection_Condition),as.factor(country)),
fill = Introspection_Condition,
color = Introspection_Condition)) +
geom_boxplot(color = "gray4")+
geom_violin(alpha = .1, color = "gray4") +
scale_x_discrete(labels = c("1" = "US", "2" = "UK", "3" = "Korea", "4" = "Italy", "5"="Sweden", "6" = "Israel", "7" = "Brazil")) +
scale_y_continuous(name = "Likelihood of attending party") +
scale_fill_manual(values = c("indianred1","steelblue1"),
name = "Condition",
labels = c("Control", "Introspection")) +
theme_classic()
p1
## Warning: Removed 2089 rows containing non-finite values (stat_boxplot).
## Warning: Removed 2089 rows containing non-finite values (stat_ydensity).
## means between countries
p2m <- aggregate(d2$partyLikely ~ (d2$Introspection_Condition*d2$country),
FUN = mean, na.rm = T)
p2m$sd <- aggregate(d2$partyLikely ~ (d2$Introspection_Condition*d2$country),
FUN = mean, na.rm = T)[,3]
getN <- function(vector) sum(!is.na(vector))
p2m$n <- aggregate(d2$partyLikely ~ (d2$Introspection_Condition*d2$country),
FUN = getN)[,3]
p2m$se <- p2m$sd/sqrt(p2m$n)
names(p2m)[1:3] <- c("intro","country","partyLikely")
p2 <- ggplot(d2,
aes(y = partyLikely,
x = country,
group = interaction(as.factor(intro),as.factor(country)),
fill = intro,
color = intro)) +
geom_bar(data=p2m,
stat = "identity",
position = position_dodge(),
color = "gray4") +
geom_errorbar(data = p2m,
aes(ymin=partyLikely - se,
ymax=partyLikely + se),
position = position_dodge(),
color = "gray4") +
scale_x_discrete(labels = c("1" = "US", "2" = "UK", "3" = "Korea", "4" = "Italy", "5"="Sweden", "6" = "Israel", "7" = "Brazil")) +
scale_y_continuous(name = "Likelihood of attending party") +
scale_fill_manual(values = c("indianred1","steelblue1"),
name = "Condition",
labels = c("Control", "Introspection")) +
theme_classic()
p2
#contrast code social gains: control = -.5; introspection = .5
d2$intro_cc_.5 <- ifelse(d2$Introspection_Condition == 1, .5, -.5)
#tried to include random slopes for introspection condition, but singularity issues
m1 <-
lmer(partyLikely ~ intro_cc_.5 + ( 1 | country),
data = d2)
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
summary(m1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: partyLikely ~ intro_cc_.5 + (1 | country)
## Data: d2
##
## REML criterion at convergence: 21775.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.0492 -0.8266 -0.4447 0.6444 2.6384
##
## Random effects:
## Groups Name Variance Std.Dev.
## country (Intercept) 0.1025 0.3201
## Residual 3.3720 1.8363
## Number of obs: 5367, groups: country, 6
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.5705 0.1332 4.9632 19.3 7.36e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
d2 %>% ggplot(aes(Introspection_Condition, partyLikely, fill = Introspection_Condition)) +
stat_summary(fun.data = mean_sdl, geom = "bar", position = "dodge") +
scale_fill_manual(values = c("indianred1","steelblue1"),
name = "Condition",
labels = c("Introspection", "Control")) +
theme_minimal() +
coord_cartesian(ylim = c(1, 3))
## Warning: Removed 2089 rows containing non-finite values (stat_summary).
plot_model(m1,
type = "re",
grid = F)
## Warning: `select_vars()` is deprecated as of dplyr 0.8.4.
## Please use `tidyselect::vars_select()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
##
## Call:
## lm(formula = partyLikely ~ intro_cc_.5 + spread + expSymp + Policy_Condition_cc,
## data = d3)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.6836 -0.9302 -0.6580 0.8819 5.3420
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.09425 0.07400 68.843 < 2e-16 ***
## intro_cc_.5 NA NA NA NA
## spread -0.33146 0.01975 -16.786 < 2e-16 ***
## expSymp -0.14941 0.01958 -7.630 2.77e-14 ***
## Policy_Condition_cc 0.14042 0.06587 2.132 0.0331 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.661 on 5329 degrees of freedom
## (8 observations deleted due to missingness)
## Multiple R-squared: 0.1981, Adjusted R-squared: 0.1976
## F-statistic: 438.8 on 3 and 5329 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = partyLikely ~ intro_cc_.5 + Policy_Condition_cc,
## data = d3)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.6146 -1.5407 -0.5851 1.4149 4.5036
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.55552 0.02539 100.646 <2e-16 ***
## intro_cc_.5 NA NA NA NA
## Policy_Condition_cc 0.11818 0.07352 1.607 0.108
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.854 on 5331 degrees of freedom
## (8 observations deleted due to missingness)
## Multiple R-squared: 0.0004845, Adjusted R-squared: 0.000297
## F-statistic: 2.584 on 1 and 5331 DF, p-value: 0.108
## SSE (Compact) = 18324.33
## SSE (Augmented) = 14701.65
## Delta R-Squared = 0.1976016
## Partial Eta-Squared (PRE) = 0.1976974
## F(2,5329) = 656.566, p = 1.285841e-255
summary(m<-lmer(partyLikely ~ intro_cc_.5*avg_screen + (avg_screen | country), data = d2))
## fixed-effect model matrix is rank deficient so dropping 2 columns / coefficients
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: partyLikely ~ intro_cc_.5 * avg_screen + (avg_screen | country)
## Data: d2
##
## REML criterion at convergence: 20256.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.8819 -0.6343 -0.2937 0.5932 3.4879
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## country (Intercept) 1.5439 1.243
## avg_screen 0.0676 0.260 -0.98
## Residual 2.5909 1.610
## Number of obs: 5333, groups: country, 6
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.0939 0.5134 5.0370 9.921 0.00017 ***
## avg_screen -0.4686 0.1071 5.0051 -4.375 0.00717 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## avg_screen -0.983
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 2 columns / coefficients