###Reading in data, excluding people who are already very likely or very unlikely to get vaccine, computing pre/post change in likelihood for each condition.

setwd("~/Google Drive/Research/Lisa/Vaccine Bot Mar2021")
bot<-read.csv ("Bot Conditions Mar2021.csv", header=T, sep=",")
static<-read.csv ("Static condition.csv", header=T, sep=",")

bot<-subset(bot, t1!=1 & t1!=7)
static<-subset(static, t1!=1 & t1!=7)
anecdote_bot<-subset(bot, condition==1)
stat_bot<-subset(bot, condition==2)



t.test(static$t1, static$t2) ###Static condition
## 
##  Welch Two Sample t-test
## 
## data:  static$t1 and static$t2
## t = -1.458, df = 383.79, p-value = 0.1457
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.51107531  0.07584215
## sample estimates:
## mean of x mean of y 
##  4.424870  4.642487
t.test(bot$t1, bot$t2) ###Overall bot (both anecdotes+stats conditions)
## 
##  Welch Two Sample t-test
## 
## data:  bot$t1 and bot$t2
## t = -1.8223, df = 786.14, p-value = 0.06879
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.41439144  0.01540154
## sample estimates:
## mean of x mean of y 
##  4.303030  4.502525
t.test(anecdote_bot$t1, anecdote_bot$t2) ###Anecdote bot condition only
## 
##  Welch Two Sample t-test
## 
## data:  anecdote_bot$t1 and anecdote_bot$t2
## t = -1.4484, df = 358.43, p-value = 0.1484
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.56013777  0.08499965
## sample estimates:
## mean of x mean of y 
##  4.265193  4.502762
t.test(stat_bot$t1, stat_bot$t2) ###Stat bot condition only
## 
##  Welch Two Sample t-test
## 
## data:  stat_bot$t1 and stat_bot$t2
## t = -1.1371, df = 425.67, p-value = 0.2561
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.4568728  0.1219890
## sample estimates:
## mean of x mean of y 
##  4.334884  4.502326

###Looking at effectiveness in each condition, broken down by T1 likelihood (pre-intervention). Starting with static condition.

two<-subset(static, t1==2) #this is people who answered 2 at T2, etc.
three<-subset(static, t1==3)
four<-subset(static, t1==4)
five<-subset(static, t1==5)
six<-subset(static, t1==6)

t.test(two$t1, two$t2)
## 
##  Welch Two Sample t-test
## 
## data:  two$t1 and two$t2
## t = -2.6536, df = 28, p-value = 0.01298
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.7943140 -0.1022378
## sample estimates:
## mean of x mean of y 
##  2.000000  2.448276
t.test(three$t1, three$t2)
## 
##  Welch Two Sample t-test
## 
## data:  three$t1 and three$t2
## t = -1.8, df = 27, p-value = 0.08304
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.68782688  0.04496974
## sample estimates:
## mean of x mean of y 
##  3.000000  3.321429
t.test(four$t1, four$t2)
## 
##  Welch Two Sample t-test
## 
## data:  four$t1 and four$t2
## t = -1.7236, df = 30, p-value = 0.09508
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.6343302  0.0536850
## sample estimates:
## mean of x mean of y 
##  4.000000  4.290323
t.test(five$t1, five$t2)
## 
##  Welch Two Sample t-test
## 
## data:  five$t1 and five$t2
## t = -3.3224, df = 41, p-value = 0.001885
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.5359509 -0.1307157
## sample estimates:
## mean of x mean of y 
##  5.000000  5.333333
t.test(six$t1, six$t2)
## 
##  Welch Two Sample t-test
## 
## data:  six$t1 and six$t2
## t = 0.90321, df = 62, p-value = 0.3699
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.05777068  0.15300877
## sample estimates:
## mean of x mean of y 
##  6.000000  5.952381
#Static info was at least marginally persuasive at all T1 levels except 6. Most effective at 5. 

###Same breakdown for the anecdote bot.

two<-subset(anecdote_bot, t1==2)  
three<-subset(anecdote_bot, t1==3)
four<-subset(anecdote_bot, t1==4)
five<-subset(anecdote_bot, t1==5)
six<-subset(anecdote_bot, t1==6)

t.test(two$t1, two$t2)
## 
##  Welch Two Sample t-test
## 
## data:  two$t1 and two$t2
## t = -3.0774, df = 35, p-value = 0.004041
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.0603485 -0.2174293
## sample estimates:
## mean of x mean of y 
##  2.000000  2.638889
t.test(three$t1, three$t2)
## 
##  Welch Two Sample t-test
## 
## data:  three$t1 and three$t2
## t = -1.1554, df = 22, p-value = 0.2603
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.6075952  0.1728126
## sample estimates:
## mean of x mean of y 
##  3.000000  3.217391
t.test(four$t1, four$t2)
## 
##  Welch Two Sample t-test
## 
## data:  four$t1 and four$t2
## t = -0.4878, df = 34, p-value = 0.6288
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.4428135  0.2713850
## sample estimates:
## mean of x mean of y 
##  4.000000  4.085714
t.test(five$t1, five$t2)
## 
##  Welch Two Sample t-test
## 
## data:  five$t1 and five$t2
## t = -2.5156, df = 30, p-value = 0.01747
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.5260212 -0.0546240
## sample estimates:
## mean of x mean of y 
##  5.000000  5.290323
t.test(six$t1, six$t2)
## 
##  Welch Two Sample t-test
## 
## data:  six$t1 and six$t2
## t = -0.62211, df = 55, p-value = 0.5364
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.2261446  0.1190018
## sample estimates:
## mean of x mean of y 
##  6.000000  6.053571
#Anecdote was only effective at T1 = 2 or 5 

###Same breakdown for the stat bot.

two<-subset(stat_bot, t1==2)  
three<-subset(stat_bot, t1==3)
four<-subset(stat_bot, t1==4)
five<-subset(stat_bot, t1==5)
six<-subset(stat_bot, t1==6)

t.test(two$t1, two$t2)
## 
##  Welch Two Sample t-test
## 
## data:  two$t1 and two$t2
## t = -1.8426, df = 36, p-value = 0.07364
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.73807801  0.03537531
## sample estimates:
## mean of x mean of y 
##  2.000000  2.351351
t.test(three$t1, three$t2)
## 
##  Welch Two Sample t-test
## 
## data:  three$t1 and three$t2
## t = -1.9873, df = 29, p-value = 0.05641
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.87930546  0.01263879
## sample estimates:
## mean of x mean of y 
##  3.000000  3.433333
t.test(four$t1, four$t2)
## 
##  Welch Two Sample t-test
## 
## data:  four$t1 and four$t2
## t = -2.0185, df = 37, p-value = 0.05084
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.3691272723  0.0007062196
## sample estimates:
## mean of x mean of y 
##  4.000000  4.184211
t.test(five$t1, five$t2)
## 
##  Welch Two Sample t-test
## 
## data:  five$t1 and five$t2
## t = -0.53442, df = 43, p-value = 0.5958
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.3254715  0.1891079
## sample estimates:
## mean of x mean of y 
##  5.000000  5.068182
t.test(six$t1, six$t2)
## 
##  Welch Two Sample t-test
## 
## data:  six$t1 and six$t2
## t = 0, df = 65, p-value = 1
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1724862  0.1724862
## sample estimates:
## mean of x mean of y 
##         6         6
#Stat bot was  effective at T1 = 2, 3, and 4

Were any of the pre/post differences different from each other? First looking at conditions overall without breaking down by T1.

static$delta<-static$t2 - static$t1
anecdote_bot$delta<-anecdote_bot$t2 - anecdote_bot$t1
stat_bot$delta<-stat_bot$t2 - stat_bot$t1

t.test(static$delta, anecdote_bot$delta)
## 
##  Welch Two Sample t-test
## 
## data:  static$delta and anecdote_bot$delta
## t = -0.22846, df = 348.09, p-value = 0.8194
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1917213  0.1518164
## sample estimates:
## mean of x mean of y 
## 0.2176166 0.2375691
t.test(static$delta, stat_bot$delta)
## 
##  Welch Two Sample t-test
## 
## data:  static$delta and stat_bot$delta
## t = 0.61612, df = 404.54, p-value = 0.5382
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1099175  0.2102670
## sample estimates:
## mean of x mean of y 
## 0.2176166 0.1674419
t.test(stat_bot$delta, anecdote_bot$delta)
## 
##  Welch Two Sample t-test
## 
## data:  stat_bot$delta and anecdote_bot$delta
## t = -0.76589, df = 377.99, p-value = 0.4442
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.2501636  0.1099092
## sample estimates:
## mean of x mean of y 
## 0.1674419 0.2375691
###No differences.

###Next letโ€™s merge the bots and static conditions so we can do regressions.

static_small<-static[c(20,23,29,36,43,45,47)]
static_small$cond<-"aa_static"

a_bot_small<-anecdote_bot[c(43,47,49,8,16,18,23)]
a_bot_small$cond<-"anecdote"

s_bot_small<-stat_bot[c(43,47,49,8,16,18,23)]
s_bot_small$cond<-"stat"

all<-rbind(static_small, a_bot_small, s_bot_small)
all$delta<-all$t2-all$t1

###First comparing the two bot conditions to the static condition.
summary(lm(delta~cond, all))
## 
## Call:
## lm(formula = delta ~ cond, data = all)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1674 -0.2376 -0.2176 -0.1674  4.8326 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.21762    0.06178   3.523 0.000461 ***
## condanecdote  0.01995    0.08880   0.225 0.822301    
## condstat     -0.05017    0.08510  -0.590 0.555691    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8582 on 586 degrees of freedom
## Multiple R-squared:  0.001217,   Adjusted R-squared:  -0.002192 
## F-statistic: 0.357 on 2 and 586 DF,  p-value: 0.6999
###Interaction with T1? 
summary(lm(delta~cond*t1, all))
## 
## Call:
## lm(formula = delta ~ cond * t1, data = all)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.9942 -0.3063 -0.0424  0.0058  4.5896 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.709806   0.195866   3.624 0.000315 ***
## condanecdote     0.021774   0.272093   0.080 0.936245    
## condstat        -0.091354   0.265938  -0.344 0.731334    
## t1              -0.111232   0.042077  -2.644 0.008425 ** 
## condanecdote:t1 -0.004591   0.059283  -0.077 0.938294    
## condstat:t1      0.007190   0.057583   0.125 0.900670    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8449 on 583 degrees of freedom
## Multiple R-squared:  0.03703,    Adjusted R-squared:  0.02878 
## F-statistic: 4.484 on 5 and 583 DF,  p-value: 0.0005106
###Interactions with demographics or timing? 

summary(lm(delta~cond*time, all))
## 
## Call:
## lm(formula = delta ~ cond * time, data = all)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1692 -0.2579 -0.1724 -0.0603  4.8275 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        0.3038667  0.0826508   3.677 0.000258 ***
## condanecdote       0.1319609  0.1462224   0.902 0.367181    
## condstat          -0.1722053  0.1375342  -1.252 0.211039    
## time              -0.0011838  0.0007563  -1.565 0.118074    
## condanecdote:time  0.0006139  0.0008117   0.756 0.449796    
## condstat:time      0.0012894  0.0008047   1.602 0.109634    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8558 on 583 degrees of freedom
## Multiple R-squared:  0.01196,    Adjusted R-squared:  0.003487 
## F-statistic: 1.412 on 5 and 583 DF,  p-value: 0.2182
summary(lm(delta~cond*age, all))
## 
## Call:
## lm(formula = delta ~ cond * age, data = all)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.0000 -0.2813 -0.1871  0.1274  4.8130 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.682825   0.198971   3.432 0.000642 ***
## condanecdote     -0.189438   0.272775  -0.694 0.487657    
## condstat         -0.288030   0.268826  -1.071 0.284417    
## age              -0.014649   0.005959  -2.458 0.014250 *  
## condanecdote:age  0.006796   0.008050   0.844 0.398935    
## condstat:age      0.007724   0.007917   0.976 0.329710    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8539 on 582 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.01798,    Adjusted R-squared:  0.009541 
## F-statistic: 2.131 on 5 and 582 DF,  p-value: 0.06025
summary(lm(delta~cond*Sex, all))
## 
## Call:
## lm(formula = delta ~ cond * Sex, data = all)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1546 -0.2377 -0.1831 -0.1546  4.8454 
## 
## Coefficients: (3 not defined because of singularities)
##                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)             2.846e-02  8.727e-01   0.033    0.974
## condanecdote           -2.846e-02  1.227e+00  -0.023    0.982
## condstat               -2.846e-02  1.347e-01  -0.211    0.833
## SexFemale               2.092e-01  8.762e-01   0.239    0.811
## SexMale                 1.546e-01  8.667e-01   0.178    0.858
## SexYes                 -2.533e-13  1.219e+00   0.000    1.000
## condanecdote:SexFemale  5.289e-02  1.232e+00   0.043    0.966
## condstat:SexFemale     -2.821e-02  1.750e-01  -0.161    0.872
## condanecdote:SexMale    5.315e-02  1.226e+00   0.043    0.965
## condstat:SexMale               NA         NA      NA       NA
## condanecdote:SexYes            NA         NA      NA       NA
## condstat:SexYes                NA         NA      NA       NA
## 
## Residual standard error: 0.8622 on 580 degrees of freedom
## Multiple R-squared:  0.002175,   Adjusted R-squared:  -0.01159 
## F-statistic: 0.158 on 8 and 580 DF,  p-value: 0.9959
###Covariates

summary(lm(delta ~ cond + time + age + Sex, all))
## 
## Call:
## lm(formula = delta ~ cond + time + age + Sex, data = all)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.9228 -0.2881 -0.1962  0.1175  4.8385 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)   
## (Intercept)   0.3234911  0.6205185   0.521   0.6023   
## condanecdote  0.0785308  0.1038757   0.756   0.4500   
## condstat      0.0119508  0.1000003   0.120   0.9049   
## time         -0.0001734  0.0001996  -0.869   0.3853   
## age          -0.0090406  0.0032375  -2.792   0.0054 **
## SexFemale     0.2110407  0.6137943   0.344   0.7311   
## SexMale       0.1643337  0.6146938   0.267   0.7893   
## SexYes       -0.0936341  1.0513304  -0.089   0.9291   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8551 on 580 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.0186, Adjusted R-squared:  0.006751 
## F-statistic:  1.57 on 7 and 580 DF,  p-value: 0.1415