setwd("~/Dropbox/Research/Adrian")
a<-read.csv ("AI_vs_human_conservatism_risk.csv", header=T, sep=",")

summary(lm(AIriskCar_1 ~ poli_2, a))
## 
## Call:
## lm(formula = AIriskCar_1 ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -62.554 -21.713   6.397  23.178  37.446 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 64.99393    5.22922  12.429   <2e-16 ***
## poli_2      -0.02440    0.07545  -0.323    0.747    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 27.63 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.0006788,  Adjusted R-squared:  -0.00581 
## F-statistic: 0.1046 on 1 and 154 DF,  p-value: 0.7468
summary(lm(AIriskCar_1 ~ poli_1 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIriskCar_1 ~ poli_1 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -66.274 -19.882   3.374  21.352  41.520 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 46.34024   11.38875   4.069 7.59e-05 ***
## poli_1      -0.01887    0.07358  -0.256  0.79793    
## age          0.51123    0.16566   3.086  0.00241 ** 
## gender       9.11862    4.26095   2.140  0.03396 *  
## edu         -3.29305    1.68553  -1.954  0.05258 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 26.48 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:    0.1,  Adjusted R-squared:  0.0762 
## F-statistic: 4.196 on 4 and 151 DF,  p-value: 0.002993
summary(lm(AIriskCar_1 ~ poli_2 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIriskCar_1 ~ poli_2 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -68.624 -18.648   3.352  21.592  42.059 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 43.23763   11.29417   3.828 0.000189 ***
## poli_2       0.04756    0.07647   0.622 0.534913    
## age          0.52862    0.16612   3.182 0.001775 ** 
## gender       9.32350    4.24763   2.195 0.029691 *  
## edu         -3.73324    1.73290  -2.154 0.032800 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 26.46 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.1019, Adjusted R-squared:  0.07816 
## F-statistic: 4.285 on 4 and 151 DF,  p-value: 0.002592
summary(lm(AIriskCar_1 ~ poli_3 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIriskCar_1 ~ poli_3 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -65.810 -21.112   4.005  20.966  41.834 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 47.21975   11.16146   4.231 4.03e-05 ***
## poli_3      -0.04316    0.07040  -0.613  0.54080    
## age          0.51450    0.16474   3.123  0.00215 ** 
## gender       8.92726    4.26747   2.092  0.03812 *  
## edu         -3.15514    1.68568  -1.872  0.06318 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 26.46 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.1019, Adjusted R-squared:  0.07809 
## F-statistic: 4.282 on 4 and 151 DF,  p-value: 0.002605
summary(lm(AIcomfCar_1 ~ poli_2, a))
## 
## Call:
## lm(formula = AIcomfCar_1 ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -49.872 -30.879  -3.489  28.309  69.096 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 30.90446    6.22039   4.968 1.78e-06 ***
## poli_2       0.19966    0.08976   2.225   0.0276 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 32.87 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.03113,    Adjusted R-squared:  0.02484 
## F-statistic: 4.949 on 1 and 154 DF,  p-value: 0.02757
summary(lm(AIcomfCar_1 ~ poli_1 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIcomfCar_1 ~ poli_1 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -52.471 -25.056  -3.213  26.665  66.502 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept)  44.63467   13.56738   3.290  0.00125 **
## poli_1        0.13377    0.08766   1.526  0.12911   
## age          -0.35811    0.19735  -1.815  0.07157 . 
## gender      -13.31799    5.07605  -2.624  0.00959 **
## edu           5.56690    2.00797   2.772  0.00627 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 31.55 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.1249, Adjusted R-squared:  0.1017 
## F-statistic: 5.388 on 4 and 151 DF,  p-value: 0.0004405
summary(lm(AIcomfCar_1 ~ poli_2 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIcomfCar_1 ~ poli_2 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -52.504 -25.894  -3.424  26.003  65.128 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  46.51408   13.51016   3.443 0.000745 ***
## poli_2        0.10807    0.09148   1.181 0.239297    
## age          -0.35648    0.19872  -1.794 0.074831 .  
## gender      -13.65499    5.08104  -2.687 0.008008 ** 
## edu           5.46233    2.07290   2.635 0.009288 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 31.65 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.1195, Adjusted R-squared:  0.09621 
## F-statistic: 5.125 on 4 and 151 DF,  p-value: 0.0006712
summary(lm(AIcomfCar_1 ~ poli_3 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIcomfCar_1 ~ poli_3 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -54.580 -24.441  -3.642  27.241  67.951 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept)  43.85606   13.21559   3.319  0.00113 **
## poli_3        0.17748    0.08336   2.129  0.03487 * 
## age          -0.38360    0.19506  -1.967  0.05106 . 
## gender      -12.78613    5.05285  -2.530  0.01241 * 
## edu           5.28447    1.99591   2.648  0.00897 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 31.33 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.1373, Adjusted R-squared:  0.1144 
## F-statistic: 6.008 on 4 and 151 DF,  p-value: 0.0001634
summary(lm(AIriskM_1 ~ poli_2, a))
## 
## Call:
## lm(formula = AIriskM_1 ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -63.571 -19.360   6.613  19.508  42.569 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 66.64113    4.86337   13.70   <2e-16 ***
## poli_2      -0.12281    0.07017   -1.75   0.0821 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 25.7 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.0195, Adjusted R-squared:  0.01313 
## F-statistic: 3.063 on 1 and 154 DF,  p-value: 0.08211
summary(lm(AIriskM_1 ~ poli_1 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIriskM_1 ~ poli_1 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -68.190 -19.030   4.445  19.119  47.790 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 48.08105   10.86756   4.424 1.84e-05 ***
## poli_1      -0.13491    0.07022  -1.921   0.0566 .  
## age          0.27237    0.15808   1.723   0.0869 .  
## gender       7.36918    4.06595   1.812   0.0719 .  
## edu         -0.57565    1.60840  -0.358   0.7209    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 25.27 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.07044,    Adjusted R-squared:  0.04581 
## F-statistic: 2.861 on 4 and 151 DF,  p-value: 0.02544
summary(lm(AIriskM_1 ~ poli_2 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIriskM_1 ~ poli_2 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -63.935 -18.662   4.464  19.506  46.180 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 45.92931   10.84900   4.234 3.98e-05 ***
## poli_2      -0.10332    0.07346  -1.407   0.1616    
## age          0.27232    0.15957   1.707   0.0900 .  
## gender       7.72327    4.08020   1.893   0.0603 .  
## edu         -0.51127    1.66459  -0.307   0.7592    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 25.41 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.06003,    Adjusted R-squared:  0.03513 
## F-statistic: 2.411 on 4 and 151 DF,  p-value: 0.05165
summary(lm(AIriskM_1 ~ poli_3 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIriskM_1 ~ poli_3 + age + gender + edu, data = a)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -68.93 -19.11   3.25  18.90  46.42 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 47.58605   10.61886   4.481 1.46e-05 ***
## poli_3      -0.14886    0.06698  -2.222   0.0277 *  
## age          0.29863    0.15673   1.905   0.0586 .  
## gender       7.02628    4.06001   1.731   0.0856 .  
## edu         -0.45391    1.60373  -0.283   0.7775    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 25.17 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.07788,    Adjusted R-squared:  0.05345 
## F-statistic: 3.188 on 4 and 151 DF,  p-value: 0.01511
a$cons<-(a$poli_1+a$poli_2+a$poli_3)

summary(lm(AIriskM_1 ~ cons + age + gender + edu, a))
## 
## Call:
## lm(formula = AIriskM_1 ~ cons + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -67.630 -19.430   3.728  19.072  46.707 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 48.28265   10.83581   4.456 1.62e-05 ***
## cons        -0.05080    0.02523  -2.014   0.0458 *  
## age          0.27524    0.15771   1.745   0.0830 .  
## gender       7.29787    4.06289   1.796   0.0745 .  
## edu         -0.35918    1.62923  -0.220   0.8258    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 25.24 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.07262,    Adjusted R-squared:  0.04805 
## F-statistic: 2.956 on 4 and 151 DF,  p-value: 0.02186
summary(lm(AIcomfM_1 ~ poli_2, a))
## 
## Call:
## lm(formula = AIcomfM_1 ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -56.369 -26.449   7.219  21.066  62.282 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 37.71767    5.59329   6.743 2.93e-10 ***
## poli_2       0.18651    0.08071   2.311   0.0222 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 29.56 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.03352,    Adjusted R-squared:  0.02724 
## F-statistic:  5.34 on 1 and 154 DF,  p-value: 0.02216
summary(lm(AIcomfM_1 ~ poli_1 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIcomfM_1 ~ poli_1 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -58.993 -26.702   4.905  21.824  57.799 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 53.37828   12.57051   4.246 3.78e-05 ***
## poli_1       0.15750    0.08122   1.939   0.0543 .  
## age         -0.21336    0.18285  -1.167   0.2451    
## gender      -9.41736    4.70309  -2.002   0.0470 *  
## edu          2.06055    1.86043   1.108   0.2698    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 29.23 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.07316,    Adjusted R-squared:  0.04861 
## F-statistic:  2.98 on 4 and 151 DF,  p-value: 0.02106
summary(lm(AIcomfM_1 ~ poli_2 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIcomfM_1 ~ poli_2 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -58.344 -26.918   5.758  23.247  56.849 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 54.49653   12.50193   4.359  2.4e-05 ***
## poli_2       0.15148    0.08465   1.790   0.0755 .  
## age         -0.20464    0.18389  -1.113   0.2675    
## gender      -9.75347    4.70185  -2.074   0.0397 *  
## edu          1.76189    1.91821   0.919   0.3598    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 29.28 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.0698, Adjusted R-squared:  0.04516 
## F-statistic: 2.833 on 4 and 151 DF,  p-value: 0.02659
summary(lm(AIcomfM_1 ~ poli_3 + age + gender + edu, a))
## 
## Call:
## lm(formula = AIcomfM_1 ~ poli_3 + age + gender + edu, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -60.415 -25.551   4.014  20.893  59.386 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 53.29359   12.24346   4.353 2.47e-05 ***
## poli_3       0.18939    0.07723   2.452   0.0153 *  
## age         -0.24373    0.18071  -1.349   0.1794    
## gender      -8.91688    4.68116  -1.905   0.0587 .  
## edu          1.83400    1.84909   0.992   0.3229    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 29.02 on 151 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.08646,    Adjusted R-squared:  0.06226 
## F-statistic: 3.573 on 4 and 151 DF,  p-value: 0.008159
#risk/comfort with humans 
summary(lm(hriskCar_1 ~ poli_2, a))
## 
## Call:
## lm(formula = hriskCar_1 ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -49.235 -19.512   1.552  18.955  52.924 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 46.08448    4.68833   9.830   <2e-16 ***
## poli_2       0.03540    0.06765   0.523    0.601    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 24.78 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.001775,   Adjusted R-squared:  -0.004707 
## F-statistic: 0.2739 on 1 and 154 DF,  p-value: 0.6015
summary(lm(hcomfCar_1 ~ poli_2, a))
## 
## Call:
## lm(formula = hcomfCar_1 ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -65.166 -13.878   5.222  17.927  35.735 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 65.51710    4.63969  14.121   <2e-16 ***
## poli_2      -0.01252    0.06695  -0.187    0.852    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 24.52 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.0002271,  Adjusted R-squared:  -0.006265 
## F-statistic: 0.03499 on 1 and 154 DF,  p-value: 0.8519
summary(lm(hriskM_1 ~ poli_2, a))
## 
## Call:
## lm(formula = hriskM_1 ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -45.617 -18.963  -1.809  19.012  58.785 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 45.61691    4.91498   9.281   <2e-16 ***
## poli_2      -0.04402    0.07092  -0.621    0.536    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 25.97 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.002496,   Adjusted R-squared:  -0.003982 
## F-statistic: 0.3853 on 1 and 154 DF,  p-value: 0.5357
summary(lm(hcomfCar_1 ~ poli_2, a))
## 
## Call:
## lm(formula = hcomfCar_1 ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -65.166 -13.878   5.222  17.927  35.735 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 65.51710    4.63969  14.121   <2e-16 ***
## poli_2      -0.01252    0.06695  -0.187    0.852    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 24.52 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.0002271,  Adjusted R-squared:  -0.006265 
## F-statistic: 0.03499 on 1 and 154 DF,  p-value: 0.8519
#mediation with all 3 conservatism measures (1=general, 2=social, 3=fiscal)
library("mediation")
## Loading required package: MASS
## Loading required package: Matrix
## Loading required package: mvtnorm
## Loading required package: sandwich
## mediation: Causal Mediation Analysis
## Version: 4.4.6
med.fit<-lm(AIriskM_1 ~ poli_1, a)
out.fit<-lm(AIcomfM_1 ~ poli_1 + AIriskM_1, a)

med.out <- mediate(med.fit, out.fit, treat = "poli_1", mediator = "AIriskM_1",boot=TRUE, sims = 1000)

summary(med.out)
## 
## Causal Mediation Analysis 
## 
## Nonparametric Bootstrap Confidence Intervals with the Percentile Method
## 
##                Estimate 95% CI Lower 95% CI Upper p-value  
## ACME            0.11950      0.00393         0.23   0.040 *
## ADE             0.07274     -0.06443         0.21   0.246  
## Total Effect    0.19223      0.01904         0.37   0.030 *
## Prop. Mediated  0.62162      0.01228         1.77   0.046 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 156 
## 
## 
## Simulations: 1000
med.fit<-lm(AIriskM_1 ~ poli_2, a)
out.fit<-lm(AIcomfM_1 ~ poli_2 + AIriskM_1, a)

med.out <- mediate(med.fit, out.fit, treat = "poli_2", mediator = "AIriskM_1",boot=TRUE, sims = 1000)

summary(med.out)
## 
## Causal Mediation Analysis 
## 
## Nonparametric Bootstrap Confidence Intervals with the Percentile Method
## 
##                Estimate 95% CI Lower 95% CI Upper p-value  
## ACME             0.0944      -0.0295         0.21   0.118  
## ADE              0.0921      -0.0204         0.21   0.124  
## Total Effect     0.1865       0.0118         0.36   0.036 *
## Prop. Mediated   0.5062      -0.4562         1.41   0.106  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 156 
## 
## 
## Simulations: 1000
med.fit<-lm(AIriskM_1 ~ poli_3, a)
out.fit<-lm(AIcomfM_1 ~ poli_3 + AIriskM_1, a)

med.out <- mediate(med.fit, out.fit, treat = "poli_3", mediator = "AIriskM_1",boot=TRUE, sims = 1000)

summary(med.out)
## 
## Causal Mediation Analysis 
## 
## Nonparametric Bootstrap Confidence Intervals with the Percentile Method
## 
##                Estimate 95% CI Lower 95% CI Upper p-value   
## ACME             0.1219       0.0119         0.22   0.034 * 
## ADE              0.0950      -0.0265         0.22   0.120   
## Total Effect     0.2169       0.0489         0.38   0.008 **
## Prop. Mediated   0.5619       0.1099         1.24   0.034 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 156 
## 
## 
## Simulations: 1000
#difference scores (AI - human)

a$carriskdiff<-a$AIriskCar_1-a$hriskCar_1
a$carcomfdiff<-a$AIcomfCar_1-a$hcomfCar_1

a$medriskdiff<-a$AIriskM_1-a$hriskM_1
a$medcomfdiff<-a$AIcomfM_1-a$hcomfMed_1

#poli 1 is general conservatism
summary(lm(carriskdiff ~ poli_1, a))
## 
## Call:
## lm(formula = carriskdiff ~ poli_1, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -102.37  -21.44   -4.60   28.10   78.22 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 20.38192    6.25907   3.256  0.00139 **
## poli_1      -0.09015    0.09609  -0.938  0.34960   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 35.6 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.005683,   Adjusted R-squared:  -0.0007731 
## F-statistic: 0.8803 on 1 and 154 DF,  p-value: 0.3496
summary(lm(carcomfdiff ~ poli_1, a))
## 
## Call:
## lm(formula = carcomfdiff ~ poli_1, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -75.053 -32.193   6.225  25.122 108.965 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -32.7795     6.8585  -4.779 4.07e-06 ***
## poli_1        0.1981     0.1053   1.882   0.0617 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 39.01 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.02248,    Adjusted R-squared:  0.01613 
## F-statistic: 3.542 on 1 and 154 DF,  p-value: 0.06173
summary(lm(medriskdiff ~ poli_1, a))
## 
## Call:
## lm(formula = medriskdiff ~ poli_1, data = a)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -97.66 -20.40  -2.00  24.78  78.26 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 21.73969    5.91345   3.676 0.000326 ***
## poli_1      -0.09764    0.09078  -1.076 0.283777    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 33.64 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.007457,   Adjusted R-squared:  0.001012 
## F-statistic: 1.157 on 1 and 154 DF,  p-value: 0.2838
summary(lm(medcomfdiff ~ poli_1, a))
## 
## Call:
## lm(formula = medcomfdiff ~ poli_1, data = a)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -67.53 -26.72   6.84  24.04  79.20 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -34.59487    5.75056  -6.016 1.25e-08 ***
## poli_1        0.19242    0.08828   2.180   0.0308 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 32.71 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.02993,    Adjusted R-squared:  0.02363 
## F-statistic: 4.751 on 1 and 154 DF,  p-value: 0.0308
#poli 2 is social conservatism
summary(lm(carriskdiff ~ poli_2, a))
## 
## Call:
## lm(formula = carriskdiff ~ poli_2, data = a)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -104.587  -20.586   -4.944   27.082   80.413 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 18.90946    6.74805   2.802  0.00573 **
## poli_2      -0.05981    0.09737  -0.614  0.53997   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 35.66 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.002444,   Adjusted R-squared:  -0.004034 
## F-statistic: 0.3773 on 1 and 154 DF,  p-value: 0.54
summary(lm(carcomfdiff ~ poli_2, a))
## 
## Call:
## lm(formula = carcomfdiff ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -79.272 -31.488   5.351  24.315 111.728 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -34.6126     7.3720  -4.695 5.85e-06 ***
## poli_2        0.2122     0.1064   1.995   0.0478 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 38.96 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.02519,    Adjusted R-squared:  0.01886 
## F-statistic: 3.979 on 1 and 154 DF,  p-value: 0.04784
summary(lm(medriskdiff ~ poli_2, a))
## 
## Call:
## lm(formula = medriskdiff ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -97.927 -20.029  -3.052  24.889  78.976 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 21.02421    6.37376   3.299  0.00121 **
## poli_2      -0.07878    0.09197  -0.857  0.39297   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 33.68 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.004743,   Adjusted R-squared:  -0.00172 
## F-statistic: 0.7339 on 1 and 154 DF,  p-value: 0.393
summary(lm(medcomfdiff ~ poli_2, a))
## 
## Call:
## lm(formula = medcomfdiff ~ poli_2, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -68.560 -27.325   7.717  23.691  78.959 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -32.0922     6.2371  -5.145 8.02e-07 ***
## poli_2        0.1379     0.0900   1.532    0.128    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 32.96 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.01501,    Adjusted R-squared:  0.00861 
## F-statistic: 2.346 on 1 and 154 DF,  p-value: 0.1276
#poli 3 is fiscal conservatism
summary(lm(carriskdiff ~ poli_3, a))
## 
## Call:
## lm(formula = carriskdiff ~ poli_3, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -97.211 -21.334  -2.906  29.983  72.398 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 26.46200    5.79205   4.569    1e-05 ***
## poli_3      -0.20251    0.09067  -2.234    0.027 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 35.14 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.03138,    Adjusted R-squared:  0.02509 
## F-statistic: 4.989 on 1 and 154 DF,  p-value: 0.02695
summary(lm(carcomfdiff ~ poli_3, a))
## 
## Call:
## lm(formula = carcomfdiff ~ poli_3, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -77.482 -32.226   4.646  25.612 105.950 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -35.62556    6.36817  -5.594 9.87e-08 ***
## poli_3        0.25675    0.09969   2.576   0.0109 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 38.63 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.0413, Adjusted R-squared:  0.03507 
## F-statistic: 6.634 on 1 and 154 DF,  p-value: 0.01095
summary(lm(medriskdiff ~ poli_3, a))
## 
## Call:
## lm(formula = medriskdiff ~ poli_3, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -97.967 -19.457  -1.084  22.931  73.656 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 29.02376    5.43561   5.340 3.29e-07 ***
## poli_3      -0.23186    0.08509  -2.725  0.00718 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 32.98 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.046,  Adjusted R-squared:  0.0398 
## F-statistic: 7.425 on 1 and 154 DF,  p-value: 0.007177
summary(lm(medcomfdiff ~ poli_3, a))
## 
## Call:
## lm(formula = medcomfdiff ~ poli_3, data = a)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -65.135 -27.556   6.801  23.691  74.883 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -37.44559    5.31959  -7.039 5.99e-11 ***
## poli_3        0.25089    0.08327   3.013  0.00303 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 32.27 on 154 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.05566,    Adjusted R-squared:  0.04953 
## F-statistic: 9.078 on 1 and 154 DF,  p-value: 0.003026