library(plyr)
## Warning: package 'plyr' was built under R version 3.1.3
library(ggplot2)
setwd("~/Google Drive/work/Good man effect/analysis/pilot 2 direct questions/data")
load("cleaned_data_final1.csv")
temp$MI_centred = temp$moral_internalization - mean(temp$moral_internalization, na.rm=T)
- Effect of MI.Int. on Upset
myModel <- lm('upset_avg ~ MI_centred', data=temp[temp$help_binary ==1, ])
summary(myModel)
##
## Call:
## lm(formula = "upset_avg ~ MI_centred", data = temp[temp$help_binary ==
## 1, ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.7300 -0.6874 -0.3956 0.4828 5.6044
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.93276 0.09449 20.455 < 2e-16 ***
## MI_centred -0.48633 0.08939 -5.441 1.8e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.24 on 172 degrees of freedom
## Multiple R-squared: 0.1468, Adjusted R-squared: 0.1419
## F-statistic: 29.6 on 1 and 172 DF, p-value: 1.801e-07
- Effect of MI.Int. and Reputation on Upset
myModel <- lm('upset_avg ~ MI_centred*good_binary', data=temp[temp$help_binary ==1, ])
summary(myModel)
##
## Call:
## lm(formula = "upset_avg ~ MI_centred*good_binary", data = temp[temp$help_binary ==
## 1, ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.9518 -0.5588 -0.2671 0.2257 5.7818
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.2923 0.1209 18.958 < 2e-16 ***
## MI_centred -0.6827 0.1187 -5.751 4.03e-08 ***
## good_binary -0.8042 0.1784 -4.509 1.21e-05 ***
## MI_centred:good_binary 0.4384 0.1683 2.605 0.01 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.165 on 170 degrees of freedom
## Multiple R-squared: 0.2557, Adjusted R-squared: 0.2426
## F-statistic: 19.47 on 3 and 170 DF, p-value: 6.741e-11
- Plot of effect of MI.Int. and Reputation on Upset
sub_help = subset(temp, temp$help_binary == 1)
sub_help$good_binary=as.factor(sub_help$good_binary)
model1=lm(upset_avg~good_binary*MI_centred, data=sub_help)
summary(model1)
##
## Call:
## lm(formula = upset_avg ~ good_binary * MI_centred, data = sub_help)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.9518 -0.5588 -0.2671 0.2257 5.7818
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.2923 0.1209 18.958 < 2e-16 ***
## good_binary1 -0.8042 0.1784 -4.509 1.21e-05 ***
## MI_centred -0.6827 0.1187 -5.751 4.03e-08 ***
## good_binary1:MI_centred 0.4384 0.1683 2.605 0.01 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.165 on 170 degrees of freedom
## Multiple R-squared: 0.2557, Adjusted R-squared: 0.2426
## F-statistic: 19.47 on 3 and 170 DF, p-value: 6.741e-11
sub_help$predicted<-predict(model1)
apatheme=theme_bw()+
theme(panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
panel.border=element_blank(),
axis.line=element_line(),
text=element_text(family='Times'))
p=ggplot(sub_help, aes(x=MI_centred, y=upset_avg, colour=good_binary))+
geom_point()+
scale_colour_manual(values = c("brown1", "cornflowerblue"), name= "Reputation", labels=c("Bad","Good"))+
geom_line(aes(x = MI_centred, y = predicted, linetype=good_binary)) +
scale_linetype_discrete(name="Reputation", labels=c("Bad","Good"))+ ylim (1, 7) +
labs(x = "Moral Identity Internalization", y = "Upset")+
#ggtitle("Good Reputation")+
apatheme
p
