library(psy) #  cronbach
cat("\014")  # cleans screen

rm(list=ls(all=TRUE))  # remove variables in working memory
setwd("C:/Users/evazquez/Downloads")  # sets working directory

## PRETEST 1 VIVIDNESS
MainStudy<-read.csv("pretest 1 vividness.csv", skip=0, header=T)
boxplot(MainStudy$exposure.time.FB,MainStudy$exposure.time.TW,MainStudy$exposure.time.YT)

t.test(MainStudy$exposure.time.YT,MainStudy$exposure.time.TW,paired = T)
## 
##  Paired t-test
## 
## data:  MainStudy$exposure.time.YT and MainStudy$exposure.time.TW
## t = 0.9817, df = 44, p-value = 0.3316
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -2.681169  7.773925
## sample estimates:
## mean of the differences 
##                2.546378
t.test(MainStudy$exposure.time.YT,MainStudy$exposure.time.FB,paired = T)
## 
##  Paired t-test
## 
## data:  MainStudy$exposure.time.YT and MainStudy$exposure.time.FB
## t = 0.018366, df = 44, p-value = 0.9854
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -6.565129  6.685884
## sample estimates:
## mean of the differences 
##              0.06037778
t.test(MainStudy$exposure.time.FB,MainStudy$exposure.time.TW,paired = T) 
## 
##  Paired t-test
## 
## data:  MainStudy$exposure.time.FB and MainStudy$exposure.time.TW
## t = 0.7958, df = 44, p-value = 0.4304
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -3.809773  8.781773
## sample estimates:
## mean of the differences 
##                   2.486
## Exposure time is equivalent for all SMP
boxplot(MainStudy$vividness.FB,MainStudy$vividness.TW,MainStudy$vividness.YT)

t.test(MainStudy$vividness.YT,MainStudy$vividness.TW,paired = T)
## 
##  Paired t-test
## 
## data:  MainStudy$vividness.YT and MainStudy$vividness.TW
## t = -2.6931, df = 44, p-value = 0.009978
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.68806873 -0.09904238
## sample estimates:
## mean of the differences 
##              -0.3935556
t.test(MainStudy$vividness.YT,MainStudy$vividness.FB,paired = T)
## 
##  Paired t-test
## 
## data:  MainStudy$vividness.YT and MainStudy$vividness.FB
## t = 1.1488, df = 44, p-value = 0.2568
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1339213  0.4890324
## sample estimates:
## mean of the differences 
##               0.1775556
t.test(MainStudy$vividness.FB,MainStudy$vividness.TW,paired = T) 
## 
##  Paired t-test
## 
## data:  MainStudy$vividness.FB and MainStudy$vividness.TW
## t = -3.097, df = 44, p-value = 0.003398
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.9427625 -0.1994597
## sample estimates:
## mean of the differences 
##              -0.5711111
## Only two levels of vividness are found


## MAIN STUDY
MainStudy<-read.csv("DatasetJRIM.csv", skip=0, header=T)
summary(MainStudy$EXPOSURE.TIME)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   30.84   48.31   62.93   61.60   72.83   98.44
MainStudy$Time2<-ifelse(MainStudy$EXPOSURE.TIME<=62.93,1,2)
MainStudy$Time3<-ifelse(MainStudy$Time==1,"1.Low",ifelse(MainStudy$Time==2,"2.Med","3.High"))
MainStudy$Vividness<-ifelse(MainStudy$X205=="Twitter","Vivid","NonVivid")

cronbach(cbind(MainStudy$FREQ.BUY,MainStudy$IMPORTANCE,MainStudy$FREQ.BUY.ONLINE))
## $sample.size
## [1] 900
## 
## $number.of.items
## [1] 3
## 
## $alpha
## [1] 0.8612343
## >.86 INVOLVEMENT
summary(lm(WOM~INVOLVEMENT+Vividness+Time+GENDER.1.IS.F+INCOME+EDU+RACE+YROFBIRTH,MainStudy))
## 
## Call:
## lm(formula = WOM ~ INVOLVEMENT + Vividness + Time + GENDER.1.IS.F + 
##     INCOME + EDU + RACE + YROFBIRTH, data = MainStudy)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.5966 -1.8916  0.2395  1.6036  5.6609 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    24.197479  14.234907   1.700   0.0895 .  
## INVOLVEMENT     0.265714   0.035169   7.555 1.03e-13 ***
## VividnessVivid -0.338262   0.146469  -2.309   0.0211 *  
## Time            0.110448   0.098727   1.119   0.2636    
## GENDER.1.IS.F   0.029924   0.139967   0.214   0.8308    
## INCOME         -0.030113   0.035679  -0.844   0.3989    
## EDU            -0.042312   0.036125  -1.171   0.2418    
## RACE           -0.050695   0.084754  -0.598   0.5499    
## YROFBIRTH      -0.010418   0.007157  -1.456   0.1459    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.066 on 891 degrees of freedom
## Multiple R-squared:  0.07189,    Adjusted R-squared:  0.06355 
## F-statistic: 8.627 on 8 and 891 DF,  p-value: 2.23e-11
## Positive effect of enduring involvement - H1: APPROVED
results=lm(WOM~INVOLVEMENT+Vividness*Time3+GENDER.1.IS.F+INCOME+EDU+RACE+YROFBIRTH,MainStudy)
anova(results)
## Analysis of Variance Table
## 
## Response: WOM
##                  Df Sum Sq Mean Sq F value    Pr(>F)    
## INVOLVEMENT       1  244.5 244.541 57.7150 7.681e-14 ***
## Vividness         1   23.7  23.650  5.5818  0.018363 *  
## Time3             2    7.0   3.521  0.8310  0.435938    
## GENDER.1.IS.F     1    0.0   0.026  0.0063  0.937000    
## INCOME            1    3.2   3.238  0.7643  0.382213    
## EDU               1    5.7   5.725  1.3512  0.245388    
## RACE              1    1.4   1.407  0.3320  0.564614    
## YROFBIRTH         1    9.0   9.025  2.1300  0.144799    
## Vividness:Time3   2   41.6  20.816  4.9128  0.007553 ** 
## Residuals       888 3762.5   4.237                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## ANCOVA Vividness and time have interaction effects - H2: APPROVED
interaction.plot(MainStudy$Time3,MainStudy$Vividness,MainStudy$WOM)

qqnorm(results$res)

plot(results$fitted,results$res,xlab="Fitted",ylab="Residuals")

hist(results$res)

MainStudy3High<-subset(MainStudy,MainStudy$Time3=="3.High"&MainStudy$Vividness=="Vivid")
MainStudy3Low<-subset(MainStudy,MainStudy$Time3=="3.High"&MainStudy$Vividness=="NonVivid")
t.test(MainStudy3High$WOM,MainStudy3Low$WOM)
## 
##  Welch Two Sample t-test
## 
## data:  MainStudy3High$WOM and MainStudy3Low$WOM
## t = -3.358, df = 160.79, p-value = 0.0009801
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.6041322 -0.4160637
## sample estimates:
## mean of x mean of y 
##  3.865079  4.875177
## Nonvivid content produces greater effect than vivid content when cognition is high - H3: APPROVED
MainStudy2High<-subset(MainStudy,MainStudy$Time3=="2.Med"&MainStudy$Vividness=="Vivid")
MainStudy2Low<-subset(MainStudy,MainStudy$Time3=="2.Med"&MainStudy$Vividness=="NonVivid")
t.test(MainStudy2High$WOM,MainStudy2Low$WOM)
## 
##  Welch Two Sample t-test
## 
## data:  MainStudy2High$WOM and MainStudy2Low$WOM
## t = 1.1793, df = 237.69, p-value = 0.2395
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1756087  0.6994325
## sample estimates:
## mean of x mean of y 
##  4.563910  4.301998
## Vivid content produces greater effect than nonvivid content when cognition is medium - H4: REJECTED
MainStudy1High<-subset(MainStudy,MainStudy$Time3=="1.Low"&MainStudy$Vividness=="Vivid")
MainStudy1Low<-subset(MainStudy,MainStudy$Time3=="1.Low"&MainStudy$Vividness=="NonVivid")
t.test(MainStudy1High$WOM,MainStudy1Low$WOM)
## 
##  Welch Two Sample t-test
## 
## data:  MainStudy1High$WOM and MainStudy1Low$WOM
## t = -2.3359, df = 178.5, p-value = 0.02061
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.2484857 -0.1050298
## sample estimates:
## mean of x mean of y 
##  3.815261  4.492019
## Nonvivid content produces greater effect than vivid content when cognition is low - H5: APPROVED
MainStudy1.2.3.High<-rbind(MainStudy1High,MainStudy2High,MainStudy3High)
summary(aov(WOM~Time3,MainStudy1.2.3.High))
##              Df Sum Sq Mean Sq F value Pr(>F)  
## Time3         2   38.9  19.434   4.127 0.0171 *
## Residuals   297 1398.6   4.709                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
aov.out<-aov(WOM~Time3,MainStudy1.2.3.High)
TukeyHSD(aov.out)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = WOM ~ Time3, data = MainStudy1.2.3.High)
## 
## $Time3
##                     diff         lwr        upr     p adj
## 2.Med-1.Low   0.74864873  0.03363705 1.46366041 0.0377029
## 3.High-1.Low  0.04981832 -0.74128039 0.84091703 0.9879432
## 3.High-2.Med -0.69883041 -1.41121667 0.01355585 0.0558571
## Two levels of inverted U-shape
t.test(MainStudy1High$WOM,MainStudy2High$WOM) 
## 
##  Welch Two Sample t-test
## 
## data:  MainStudy1High$WOM and MainStudy2High$WOM
## t = -2.5417, df = 181.56, p-value = 0.01187
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.3298286 -0.1674689
## sample estimates:
## mean of x mean of y 
##  3.815261  4.563910
t.test(MainStudy2High$WOM,MainStudy3High$WOM)
## 
##  Welch Two Sample t-test
## 
## data:  MainStudy2High$WOM and MainStudy3High$WOM
## t = 2.2488, df = 171.72, p-value = 0.02579
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.08544365 1.31221717
## sample estimates:
## mean of x mean of y 
##  4.563910  3.865079
t.test(MainStudy1High$WOM,MainStudy3High$WOM)
## 
##  Welch Two Sample t-test
## 
## data:  MainStudy1High$WOM and MainStudy3High$WOM
## t = -0.14889, df = 163.91, p-value = 0.8818
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.7104985  0.6108618
## sample estimates:
## mean of x mean of y 
##  3.815261  3.865079
## Two levels of inverted U-shape confirmed
results=lm(WOM~INVOLVEMENT+Time3+GENDER.1.IS.F+INCOME+EDU+RACE+YROFBIRTH,MainStudy1.2.3.High)
anova(results) ## ANCOVA
## Analysis of Variance Table
## 
## Response: WOM
##                Df  Sum Sq Mean Sq F value    Pr(>F)    
## INVOLVEMENT     1  108.09 108.085 24.4080 1.317e-06 ***
## Time3           2   28.51  14.253  3.2186   0.04144 *  
## GENDER.1.IS.F   1    5.27   5.272  1.1905   0.27614    
## INCOME          1    0.06   0.063  0.0142   0.90512    
## EDU             1    0.03   0.032  0.0073   0.93197    
## RACE            1    0.11   0.109  0.0247   0.87527    
## YROFBIRTH       1    6.74   6.743  1.5227   0.21821    
## Residuals     291 1288.63   4.428                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Vivid content will produce an inverted U shape patter when sizing their effect on digital engagement. H6: APPROVED
qqnorm(results$res)

plot(results$fitted,results$res,xlab="Fitted",ylab="Residuals")

hist(results$res)

MainStudy1.2.3.Low<-rbind(MainStudy1Low,MainStudy2Low,MainStudy3Low)
summary(lm(WOM~INVOLVEMENT+Time3+GENDER.1.IS.F+INCOME+EDU+RACE+YROFBIRTH,MainStudy1.2.3.Low))
## 
## Call:
## lm(formula = WOM ~ INVOLVEMENT + Time3 + GENDER.1.IS.F + INCOME + 
##     EDU + RACE + YROFBIRTH, data = MainStudy1.2.3.Low)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.8083 -1.7981  0.2374  1.5077  5.3994 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   17.648130  17.069394   1.034    0.302    
## INVOLVEMENT    0.241217   0.043497   5.546 4.42e-08 ***
## Time32.Med    -0.160178   0.207772  -0.771    0.441    
## Time33.High    0.276061   0.246597   1.119    0.263    
## GENDER.1.IS.F -0.091436   0.169651  -0.539    0.590    
## INCOME        -0.036465   0.043341  -0.841    0.400    
## EDU           -0.067941   0.043801  -1.551    0.121    
## RACE          -0.080978   0.104950  -0.772    0.441    
## YROFBIRTH     -0.006641   0.008587  -0.773    0.440    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.039 on 591 degrees of freedom
## Multiple R-squared:  0.06928,    Adjusted R-squared:  0.05668 
## F-statistic: 5.499 on 8 and 591 DF,  p-value: 1.024e-06
## Vivid content will produce an inverted U shape patter when sizing their effect on digital engagement. H7: REJECTED
results=lm(WOM~INVOLVEMENT+Time3+GENDER.1.IS.F+INCOME+EDU+RACE+YROFBIRTH,MainStudy1.2.3.Low)
qqnorm(results$res)

plot(results$fitted,results$res,xlab="Fitted",ylab="Residuals")

hist(results$res)