setwd("~/Google Drive/Research")
ra<-read.csv ("Robots_v_Algorithms_Prejudice_v2.csv", header=T, sep=",")

names(ra)
##  [1] "V1"                "V2"                "V3"               
##  [4] "V4"                "V5"                "V6"               
##  [7] "V7"                "V8"                "V9"               
## [10] "V10"               "PROLIFIC_PID"      "Prompt"           
## [13] "theirs"            "ours"              "control"          
## [16] "pan"               "realistic_1"       "realistic_3"      
## [19] "realistic_4"       "realistic_5"       "realistic_9"      
## [22] "symbolic_1"        "symbolic_2"        "symbolic_3"       
## [25] "symbolic_8"        "immpol1R"          "immpol2"          
## [28] "immpol3"           "immpol4"           "assoc_1"          
## [31] "assoc_2"           "assoc_3"           "assoc_4"          
## [34] "assoc_5"           "assoc_6"           "blur1"            
## [37] "blur2"             "blur3"             "Gender"           
## [40] "Age"               "ID"                "Politics"         
## [43] "Income"            "LocationLatitude"  "LocationLongitude"
## [46] "LocationAccuracy"  "X"
ra$cond[ra$theirs==1]<-"algorithm"
ra$cond[ra$ours==1]<-"robot"
ra$cond[ra$control==1]<-"acontrol"
  
ra$Rthreat<-(ra$realistic_1+ra$realistic_3+ra$realistic_5+ra$realistic_9)/4
ra$Sthreat<-(ra$symbolic_1+ra$symbolic_2+(8-ra$symbolic_3)+ra$symbolic_8)/4

ra$pol<-((8-ra$immpol1R) + ra$immpol2 + ra$immpol3 + ra$immpol4)/4

ra$blur<-(ra$blur1+ra$blur2+ra$blur3)/3


#support for restrictive immigration policies (bigger numbers = more restrictive)
summary(lm(pol~cond, ra))
## 
## Call:
## lm(formula = pol ~ cond, data = ra)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.9549 -1.0095 -0.1146  0.7405  4.2405 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    2.86458    0.11660  24.567   <2e-16 ***
## condalgorithm  0.09033    0.16422   0.550    0.583    
## condrobot     -0.10504    0.16140  -0.651    0.516    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.277 on 370 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.003994,   Adjusted R-squared:  -0.00139 
## F-statistic: 0.7419 on 2 and 370 DF,  p-value: 0.4769
#panhumanism (overlapping circles)
summary(lm(pan~cond, ra))
## 
## Call:
## lm(formula = pan ~ cond, data = ra)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -3.07500 -1.02963 -0.02963  0.97037  2.22951 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    4.07500    0.12253  33.258   <2e-16 ***
## condalgorithm -0.30451    0.17257  -1.765   0.0785 .  
## condrobot     -0.04537    0.16840  -0.269   0.7878    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.342 on 374 degrees of freedom
## Multiple R-squared:  0.009734,   Adjusted R-squared:  0.004438 
## F-statistic: 1.838 on 2 and 374 DF,  p-value: 0.1606
#realistic threats from immigrants
summary(lm(Rthreat~cond, ra))
## 
## Call:
## lm(formula = Rthreat ~ cond, data = ra)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7625 -1.2377 -0.2625  0.9875  4.3796 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.7625     0.1338  20.650   <2e-16 ***
## condalgorithm  -0.0248     0.1884  -0.132    0.895    
## condrobot      -0.1421     0.1839  -0.773    0.440    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.465 on 374 degrees of freedom
## Multiple R-squared:  0.001856,   Adjusted R-squared:  -0.003482 
## F-statistic: 0.3477 on 2 and 374 DF,  p-value: 0.7065
#symbolic threats from immigrants

summary(lm(Sthreat~cond, ra))
## 
## Call:
## lm(formula = Sthreat ~ cond, data = ra)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2971 -0.8778 -0.0471  0.7271  3.7271 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    3.27292    0.11505  28.448   <2e-16 ***
## condalgorithm  0.02421    0.16203   0.149    0.881    
## condrobot     -0.14514    0.15812  -0.918    0.359    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.26 on 374 degrees of freedom
## Multiple R-squared:  0.003658,   Adjusted R-squared:  -0.00167 
## F-statistic: 0.6866 on 2 and 374 DF,  p-value: 0.5039
#perceived blurring between human and machine

summary(lm(blur~cond, ra))
## 
## Call:
## lm(formula = blur ~ cond, data = ra)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.25141 -0.89807 -0.03008  0.63659  2.74859 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   19.25141    0.08606 223.694   <2e-16 ***
## condalgorithm -0.02001    0.12095  -0.165    0.869    
## condrobot     -0.22134    0.11823  -1.872    0.062 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9349 on 369 degrees of freedom
##   (5 observations deleted due to missingness)
## Multiple R-squared:  0.01175,    Adjusted R-squared:  0.006398 
## F-statistic: 2.194 on 2 and 369 DF,  p-value: 0.1129