library(reshape2) #  melt
library(MASS) #  lda
library(psy) #  cronbach
library(psych) # KMO
## 
## Attaching package: 'psych'
## The following object is masked from 'package:psy':
## 
##     wkappa
library(Hmisc) # correlation matrix
## Warning: package 'Hmisc' was built under R version 3.4.2
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
## 
## Attaching package: 'Hmisc'
## The following object is masked from 'package:psych':
## 
##     describe
## The following objects are masked from 'package:base':
## 
##     format.pval, round.POSIXt, trunc.POSIXt, units
library(psych) #KMO
library(Hmisc) # correlation matrix
cat("\014")  # cleans screen

rm(list=ls(all=TRUE))  # remove variables in working memory
setwd("C:/Users/Erik Ernesto Vazquez/Downloads")  # sets working directory
MainStudy<-read.csv("DataSetPretest.csv", header=T)  # reads raw data from Qualtrics

MainStudy<-subset(MainStudy,MainStudy$Q23>0) ## Valid responses

## Reliability of Background Atmoshpherics measures urban/street
MainStudyMelt1BA<-melt(MainStudy,id.vars=c("ResponseId","Q13_1","Q33_1"),
                     measure.vars=c("Q13_1","Q33_1"),
                     variable.name="BA", value.name="Item1")
MainStudyMelt2BA<-melt(MainStudy,id.vars=c("ResponseId","Q13_4","Q33_4"),
                     measure.vars=c("Q13_4","Q13_4"),
                     variable.name="BA", value.name="Item2")
MainStudyMelt3BA<-melt(MainStudy,id.vars=c("ResponseId","Q13_5","Q33_5"),
                     measure.vars=c("Q13_5","Q13_5"),
                     variable.name="BA", value.name="Item3")
cronbach(cbind(MainStudyMelt1BA$Item1,MainStudyMelt2BA$Item2,MainStudyMelt3BA$Item3)) ## Cronbach 0.72
## $sample.size
## [1] 424
## 
## $number.of.items
## [1] 3
## 
## $alpha
## [1] 0.7204019
cronbach(cbind(MainStudyMelt2BA$Item2,MainStudyMelt3BA$Item3)) ## Cronbach 0.8786
## $sample.size
## [1] 424
## 
## $number.of.items
## [1] 2
## 
## $alpha
## [1] 0.8786803
## The photo above has urban/street aesthetics (4)
## The background style of the photo above is urban/street (5) 


## Reliability of Background Atmoshpherics measures prof/studio
MainStudyMelt1BA<-melt(MainStudy,id.vars=c("ResponseId","Q13_2","Q33_2"),
                       measure.vars=c("Q13_2","Q33_2"),
                       variable.name="BA", value.name="Item1")
MainStudyMelt2BA<-melt(MainStudy,id.vars=c("ResponseId","Q13_3","Q33_3"),
                       measure.vars=c("Q13_3","Q13_3"),
                       variable.name="BA", value.name="Item2")
MainStudyMelt3BA<-melt(MainStudy,id.vars=c("ResponseId","Q13_6","Q33_6"),
                       measure.vars=c("Q13_6","Q13_6"),
                       variable.name="BA", value.name="Item3")
cronbach(cbind(MainStudyMelt1BA$Item1,MainStudyMelt2BA$Item2,MainStudyMelt3BA$Item3)) ## Cronbach 0.77
## $sample.size
## [1] 424
## 
## $number.of.items
## [1] 3
## 
## $alpha
## [1] 0.7728367
cronbach(cbind(MainStudyMelt2BA$Item2,MainStudyMelt3BA$Item3)) ## Cronbach 0.85 
## $sample.size
## [1] 424
## 
## $number.of.items
## [1] 2
## 
## $alpha
## [1] 0.8514981
## The photo above has studio/professional aesthetics (3)
## The background style of the photo above is studio/professional (6)

## The highest from the both BA measures is that of urban/street, so, 
## we will evaluate using those measures

## Reliability of Model Commoness measures
MainStudyMelt1MC<-melt(MainStudy,id.vars=c("ResponseId","Q17_1","Q37_1","Q40_1"),
                     measure.vars=c("Q17_1","Q37_1","Q40_1"),
                     variable.name="MC", value.name="Item1")
MainStudyMelt2MC<-melt(MainStudy,id.vars=c("ResponseId","Q17_2","Q37_2","Q40_2"),
                     measure.vars=c("Q17_2","Q37_2","Q40_2"),
                     variable.name="MC", value.name="Item2")
MainStudyMelt3MC<-melt(MainStudy,id.vars=c("ResponseId","Q17_3","Q37_3","Q40_3"),
                     measure.vars=c("Q17_3","Q37_3","Q40_3"),
                     variable.name="MC", value.name="Item3")
MainStudyMelt4MC<-melt(MainStudy,id.vars=c("ResponseId","Q17_6","Q37_6","Q40_6"),
                     measure.vars=c("Q17_6","Q37_6","Q40_6"),
                     variable.name="MC", value.name="Item4")
cronbach(cbind(MainStudyMelt1MC$Item1,MainStudyMelt2MC$Item2,MainStudyMelt3MC$Item3,MainStudyMelt4MC$Item4)) ## Cronbach 0.855
## $sample.size
## [1] 636
## 
## $number.of.items
## [1] 4
## 
## $alpha
## [1] 0.8558307
cronbach(cbind(MainStudy$Q19_1,MainStudy$Q19_2,MainStudy$Q19_3,MainStudy$Q19_4)) ## Authenticity Cronbach .92
## $sample.size
## [1] 212
## 
## $number.of.items
## [1] 4
## 
## $alpha
## [1] 0.928113
cronbach(cbind(MainStudy$Q18_1,MainStudy$Q18_2,MainStudy$Q18_3)) ## Purchase Intent .95
## $sample.size
## [1] 212
## 
## $number.of.items
## [1] 3
## 
## $alpha
## [1] 0.9592214
## Averages
MainStudy$BackgroundUrbanPhotoUrban<-(MainStudy$Q13_4+MainStudy$Q13_5)/2
MainStudy$BackgroundUrbanPhotoStudio<-(MainStudy$Q33_4+MainStudy$Q33_5)/2
MainStudy$ModelCommonessPhotoCommon<-(MainStudy$Q17_1+MainStudy$Q17_2+MainStudy$Q17_3+MainStudy$Q17_6)/4
MainStudy$ModelCommonessPhotoThin<-(MainStudy$Q37_1+MainStudy$Q37_2+MainStudy$Q37_3+MainStudy$Q37_6)/4
MainStudy$ModelCommonessPhotoOW<-(MainStudy$Q40_1+MainStudy$Q40_2+MainStudy$Q40_3+MainStudy$Q40_6)/4

summary(MainStudy)
##             StartDate               EndDate        Status 
##  10/10/2017 18:12:  3   10/10/2017 20:55:  3   Min.   :0  
##  10/10/2017 18:18:  3   10/10/2017 20:56:  3   1st Qu.:0  
##  10/10/2017 20:50:  3   10/11/2017 2:53 :  3   Median :0  
##  10/10/2017 20:51:  3   10/10/2017 18:15:  2   Mean   :0  
##  10/11/2017 2:45 :  3   10/10/2017 18:21:  2   3rd Qu.:0  
##  10/10/2017 19:05:  2   10/10/2017 19:12:  2   Max.   :0  
##  (Other)         :195   (Other)         :197              
##            IPAddress      Progress   Duration..in.seconds.    Finished
##  103.25.44.2    :  7   Min.   :100   Min.   : 120.0        Min.   :1  
##  37.187.147.158 :  3   1st Qu.:100   1st Qu.: 191.5        1st Qu.:1  
##  103.25.44.30   :  2   Median :100   Median : 255.0        Median :1  
##  117.213.36.33  :  2   Mean   :100   Mean   : 384.2        Mean   :1  
##  157.50.22.36   :  2   3rd Qu.:100   3rd Qu.: 346.2        3rd Qu.:1  
##  101.100.169.163:  1   Max.   :100   Max.   :8576.0        Max.   :1  
##  (Other)        :195                                                  
##            RecordedDate             ResponseId  RecipientLastName
##  10/10/2017 20:55:  3   R_0ieuzoFFIvgBtCN:  1   Mode:logical     
##  10/10/2017 20:56:  3   R_0In7CgSbEOgdst3:  1   NA's:212         
##  10/11/2017 2:53 :  3   R_0kffRK83bUuFDwt:  1                    
##  10/10/2017 18:15:  2   R_10wSeDmahwyPdns:  1                    
##  10/10/2017 18:21:  2   R_12f1jrwrXArmrrl:  1                    
##  10/10/2017 19:12:  2   R_12GsZl8WqhIwMvn:  1                    
##  (Other)         :197   (Other)          :206                    
##  RecipientFirstName RecipientEmail ExternalReference LocationLatitude
##  Mode:logical       Mode:logical   Mode:logical      Min.   : 1.00   
##  NA's:212           NA's:212       NA's:212          1st Qu.:13.08   
##                                                      Median :28.67   
##                                                      Mean   :26.62   
##                                                      3rd Qu.:39.15   
##                                                      Max.   :56.74   
##                                                                      
##  LocationLongitude  DistributionChannel UserLanguage       Q1   
##  Min.   :-157.839   anonymous:212         :  4       Min.   :2  
##  1st Qu.: -84.308                       EN:208       1st Qu.:2  
##  Median :   2.339                                    Median :2  
##  Mean   :  -6.852                                    Mean   :2  
##  3rd Qu.:  77.621                                    3rd Qu.:2  
##  Max.   : 121.061                                    Max.   :2  
##                                                                 
##        Q2        Q13_1           Q13_2           Q13_3      
##  Min.   :2   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.:2   1st Qu.:2.000   1st Qu.:3.000   1st Qu.:3.000  
##  Median :2   Median :4.000   Median :4.000   Median :4.000  
##  Mean   :2   Mean   :4.222   Mean   :4.415   Mean   :4.627  
##  3rd Qu.:2   3rd Qu.:6.000   3rd Qu.:6.000   3rd Qu.:6.250  
##  Max.   :2   Max.   :9.000   Max.   :9.000   Max.   :9.000  
##                                                             
##      Q13_4           Q13_5           Q13_6       Q27_First.Click 
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   : 0.024  
##  1st Qu.:3.000   1st Qu.:2.000   1st Qu.:3.000   1st Qu.: 2.138  
##  Median :4.000   Median :4.000   Median :5.000   Median : 5.896  
##  Mean   :4.236   Mean   :4.217   Mean   :4.953   Mean   : 8.682  
##  3rd Qu.:6.000   3rd Qu.:6.000   3rd Qu.:7.000   3rd Qu.:11.356  
##  Max.   :9.000   Max.   :9.000   Max.   :9.000   Max.   :66.995  
##                                                                  
##  Q27_Last.Click    Q27_Page.Submit  Q27_Click.Count     Q33_1      
##  Min.   :  2.284   Min.   : 15.71   Min.   : 1.00   Min.   :1.000  
##  1st Qu.: 14.226   1st Qu.: 17.53   1st Qu.: 6.00   1st Qu.:3.000  
##  Median : 24.482   Median : 27.85   Median : 8.00   Median :6.000  
##  Mean   : 31.290   Mean   : 36.28   Mean   :10.77   Mean   :5.741  
##  3rd Qu.: 38.674   3rd Qu.: 41.22   3rd Qu.:11.00   3rd Qu.:8.000  
##  Max.   :453.643   Max.   :455.13   Max.   :58.00   Max.   :9.000  
##                                                                    
##      Q33_2           Q33_3           Q33_4           Q33_5     
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.00  
##  1st Qu.:2.000   1st Qu.:2.000   1st Qu.:3.000   1st Qu.:3.00  
##  Median :3.500   Median :4.000   Median :6.000   Median :6.00  
##  Mean   :3.995   Mean   :4.156   Mean   :5.599   Mean   :5.83  
##  3rd Qu.:5.000   3rd Qu.:6.000   3rd Qu.:8.000   3rd Qu.:9.00  
##  Max.   :9.000   Max.   :9.000   Max.   :9.000   Max.   :9.00  
##                                                                
##      Q33_6       Q28_First.Click   Q28_Last.Click    Q28_Page.Submit 
##  Min.   :1.000   Min.   :  0.025   Min.   :  2.421   Min.   : 15.65  
##  1st Qu.:2.000   1st Qu.:  2.418   1st Qu.: 13.430   1st Qu.: 17.38  
##  Median :4.000   Median :  6.284   Median : 21.818   Median : 24.54  
##  Mean   :4.198   Mean   :  8.879   Mean   : 27.655   Mean   : 32.06  
##  3rd Qu.:6.000   3rd Qu.:  9.578   3rd Qu.: 34.772   3rd Qu.: 36.60  
##  Max.   :9.000   Max.   :337.450   Max.   :344.416   Max.   :345.63  
##                                                                      
##  Q28_Click.Count     Q17_1           Q17_2           Q17_3      
##  Min.   : 1.00   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.: 6.00   1st Qu.:3.000   1st Qu.:3.000   1st Qu.:3.000  
##  Median : 7.00   Median :5.000   Median :4.000   Median :4.000  
##  Mean   :10.66   Mean   :5.024   Mean   :4.514   Mean   :4.349  
##  3rd Qu.:11.00   3rd Qu.:7.000   3rd Qu.:6.000   3rd Qu.:6.000  
##  Max.   :55.00   Max.   :9.000   Max.   :9.000   Max.   :9.000  
##                                                                 
##      Q17_4          Q17_5           Q17_6       Q29_First.Click  
##  Min.   :1.00   Min.   :1.000   Min.   :1.000   Min.   :  0.160  
##  1st Qu.:3.75   1st Qu.:5.000   1st Qu.:3.000   1st Qu.:  2.392  
##  Median :5.00   Median :8.000   Median :5.000   Median :  6.074  
##  Mean   :5.25   Mean   :6.778   Mean   :4.844   Mean   :  8.495  
##  3rd Qu.:7.00   3rd Qu.:9.000   3rd Qu.:7.000   3rd Qu.:  9.069  
##  Max.   :9.00   Max.   :9.000   Max.   :9.000   Max.   :119.381  
##                                                                  
##  Q29_Last.Click    Q29_Page.Submit   Q29_Click.Count     Q37_1      
##  Min.   :  2.119   Min.   :  15.70   Min.   : 1.00   Min.   :1.000  
##  1st Qu.: 15.516   1st Qu.:  17.82   1st Qu.: 6.00   1st Qu.:3.000  
##  Median : 24.754   Median :  27.47   Median : 7.00   Median :5.000  
##  Mean   : 30.910   Mean   :  43.14   Mean   :10.12   Mean   :5.241  
##  3rd Qu.: 35.372   3rd Qu.:  37.77   3rd Qu.:10.00   3rd Qu.:8.000  
##  Max.   :563.095   Max.   :1716.94   Max.   :38.00   Max.   :9.000  
##                                                                     
##      Q37_2           Q37_3           Q37_4           Q37_5      
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.:3.000   1st Qu.:3.000   1st Qu.:3.000   1st Qu.:4.000  
##  Median :5.000   Median :5.000   Median :4.000   Median :8.000  
##  Mean   :4.882   Mean   :4.689   Mean   :4.642   Mean   :6.472  
##  3rd Qu.:7.000   3rd Qu.:7.000   3rd Qu.:6.000   3rd Qu.:9.000  
##  Max.   :9.000   Max.   :9.000   Max.   :9.000   Max.   :9.000  
##                                                                 
##      Q37_6       Q30_First.Click   Q30_Last.Click   Q30_Page.Submit 
##  Min.   :1.000   Min.   :  0.000   Min.   :  0.00   Min.   : 15.68  
##  1st Qu.:3.000   1st Qu.:  2.288   1st Qu.: 12.62   1st Qu.: 18.34  
##  Median :5.000   Median :  5.284   Median : 25.51   Median : 27.72  
##  Mean   :5.113   Mean   :  8.083   Mean   : 29.85   Mean   : 33.89  
##  3rd Qu.:7.000   3rd Qu.:  9.014   3rd Qu.: 34.98   3rd Qu.: 37.38  
##  Max.   :9.000   Max.   :286.460   Max.   :342.58   Max.   :344.11  
##                                                                     
##  Q30_Click.Count     Q40_1           Q40_2           Q40_3      
##  Min.   : 0.00   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.: 6.00   1st Qu.:3.000   1st Qu.:2.000   1st Qu.:3.000  
##  Median : 7.00   Median :4.000   Median :4.000   Median :4.000  
##  Mean   :10.45   Mean   :4.538   Mean   :3.915   Mean   :4.269  
##  3rd Qu.:10.00   3rd Qu.:6.000   3rd Qu.:5.000   3rd Qu.:6.000  
##  Max.   :55.00   Max.   :9.000   Max.   :9.000   Max.   :9.000  
##                                                                 
##      Q40_4           Q40_5           Q40_6       Q31_First.Click  
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :  0.000  
##  1st Qu.:4.000   1st Qu.:4.000   1st Qu.:3.000   1st Qu.:  2.219  
##  Median :7.000   Median :6.000   Median :4.000   Median :  6.423  
##  Mean   :6.127   Mean   :5.632   Mean   :4.146   Mean   :  9.606  
##  3rd Qu.:8.000   3rd Qu.:8.000   3rd Qu.:5.250   3rd Qu.: 10.302  
##  Max.   :9.000   Max.   :9.000   Max.   :9.000   Max.   :391.058  
##                                                                   
##  Q31_Last.Click   Q31_Page.Submit  Q31_Click.Count     Q19_1      
##  Min.   :  0.00   Min.   : 15.65   Min.   : 0.00   Min.   :1.000  
##  1st Qu.: 16.29   1st Qu.: 19.41   1st Qu.: 6.00   1st Qu.:3.000  
##  Median : 27.67   Median : 30.70   Median : 8.00   Median :4.000  
##  Mean   : 32.27   Mean   : 36.89   Mean   :10.68   Mean   :4.028  
##  3rd Qu.: 38.96   3rd Qu.: 41.97   3rd Qu.:11.00   3rd Qu.:5.000  
##  Max.   :396.40   Max.   :397.78   Max.   :56.00   Max.   :9.000  
##                                                                   
##      Q19_2           Q19_3           Q19_4           Q18_1      
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.:2.000   1st Qu.:3.000   1st Qu.:2.000   1st Qu.:3.000  
##  Median :4.000   Median :4.000   Median :4.000   Median :5.000  
##  Mean   :4.019   Mean   :4.462   Mean   :3.972   Mean   :5.274  
##  3rd Qu.:5.000   3rd Qu.:6.000   3rd Qu.:5.000   3rd Qu.:8.000  
##  Max.   :9.000   Max.   :9.000   Max.   :9.000   Max.   :9.000  
##                                                                 
##      Q18_2           Q18_3            Q20             Q21      
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   : 2.0  
##  1st Qu.:3.000   1st Qu.:3.000   1st Qu.:2.000   1st Qu.:11.0  
##  Median :5.000   Median :5.000   Median :3.000   Median :12.0  
##  Mean   :5.108   Mean   :5.005   Mean   :3.519   Mean   :11.3  
##  3rd Qu.:7.000   3rd Qu.:7.000   3rd Qu.:5.000   3rd Qu.:12.0  
##  Max.   :9.000   Max.   :9.000   Max.   :9.000   Max.   :15.0  
##                                                                
##       Q22          Q23             Q24          Q24_6_TEXT       Q25     
##  2      :74   Min.   :1.000   Min.   :1.000          :178   1990   : 16  
##  1      :68   1st Qu.:1.000   1st Qu.:1.000   Asian  :  8   1991   : 16  
##  3      :44   Median :1.000   Median :3.000   Indian :  8   1992   : 16  
##  4      :12   Mean   :1.052   Mean   :3.269   asian  :  3   1989   : 14  
##  5      : 6   3rd Qu.:1.000   3rd Qu.:5.000   indian :  3   1985   : 11  
##  6      : 4   Max.   :2.000   Max.   :6.000   India  :  2   1983   : 10  
##  (Other): 4                                   (Other): 10   (Other):129  
##           Q26         Q26_8_TEXT  BackgroundUrbanPhotoUrban
##  1,4,6      : 18           :199   Min.   :1.000            
##  2,3,4,6    : 16   Twitter :  3   1st Qu.:2.500            
##  4          : 14   twitter :  2   Median :4.000            
##  4,6        : 13   Whatsapp:  2   Mean   :4.226            
##  1,2,3,4,5,6: 12   Ravelry :  1   3rd Qu.:5.500            
##  1,2,3,4,6  : 11   tumblr  :  1   Max.   :9.000            
##  (Other)    :128   (Other) :  4                            
##  BackgroundUrbanPhotoStudio ModelCommonessPhotoCommon
##  Min.   :1.000              Min.   :1.000            
##  1st Qu.:3.500              1st Qu.:3.250            
##  Median :5.500              Median :4.750            
##  Mean   :5.715              Mean   :4.683            
##  3rd Qu.:8.500              3rd Qu.:6.000            
##  Max.   :9.000              Max.   :9.000            
##                                                      
##  ModelCommonessPhotoThin ModelCommonessPhotoOW
##  Min.   :1.000           Min.   :1.000        
##  1st Qu.:3.500           1st Qu.:3.000        
##  Median :5.250           Median :4.000        
##  Mean   :4.981           Mean   :4.217        
##  3rd Qu.:6.500           3rd Qu.:5.250        
##  Max.   :9.000           Max.   :8.750        
## 
## Mainipulation Check / Pretest 1 
t.test(MainStudy$BackgroundUrbanPhotoUrban,MainStudy$BackgroundUrbanPhotoStudio,paired=T) ## significant difference between the two backgrounds
## 
##  Paired t-test
## 
## data:  MainStudy$BackgroundUrbanPhotoUrban and MainStudy$BackgroundUrbanPhotoStudio
## t = -6.3464, df = 211, p-value = 1.325e-09
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.950461 -1.025954
## sample estimates:
## mean of the differences 
##               -1.488208
t.test(MainStudy$ModelCommonessPhotoCommon,MainStudy$ModelCommonessPhotoThin,paired=T) ## significant difference between the thin model and normal model
## 
##  Paired t-test
## 
## data:  MainStudy$ModelCommonessPhotoCommon and MainStudy$ModelCommonessPhotoThin
## t = -3.118, df = 211, p-value = 0.002075
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.4869742 -0.1097239
## sample estimates:
## mean of the differences 
##              -0.2983491
t.test(MainStudy$ModelCommonessPhotoCommon,MainStudy$ModelCommonessPhotoOW,paired=T) ## significant difference between the overweight model and normal model
## 
##  Paired t-test
## 
## data:  MainStudy$ModelCommonessPhotoCommon and MainStudy$ModelCommonessPhotoOW
## t = 3.2736, df = 211, p-value = 0.001241
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.1853058 0.7462980
## sample estimates:
## mean of the differences 
##               0.4658019
# VALIDITY all variables
validity<-cbind(MainStudy$Q13_4,MainStudy$Q13_5,
                MainStudy$Q17_1,MainStudy$Q17_2,MainStudy$Q17_3,MainStudy$Q17_4,
                MainStudy$Q19_1,MainStudy$Q19_2,MainStudy$Q19_3,MainStudy$Q19_4,
                MainStudy$Q18_1,MainStudy$Q18_2,MainStudy$Q18_3)
factanal(validity,4,rotation="varimax") ## 4 factors explain more than 70% of the variance
## 
## Call:
## factanal(x = validity, factors = 4, rotation = "varimax")
## 
## Uniquenesses:
##  [1] 0.005 0.362 0.684 0.460 0.005 0.869 0.126 0.269 0.320 0.102 0.116
## [12] 0.083 0.133
## 
## Loadings:
##       Factor1 Factor2 Factor3 Factor4
##  [1,]  0.132           0.987         
##  [2,]  0.227           0.765         
##  [3,]          0.471           0.292 
##  [4,]  0.161   0.305           0.647 
##  [5,]  0.217   0.211           0.950 
##  [6,]          0.251          -0.236 
##  [7,]  0.881   0.210   0.178   0.146 
##  [8,]  0.780   0.176   0.157   0.259 
##  [9,]  0.679   0.447   0.102         
## [10,]  0.893   0.233   0.166   0.131 
## [11,]  0.356   0.856           0.153 
## [12,]  0.353   0.871           0.186 
## [13,]  0.377   0.836           0.158 
## 
##                Factor1 Factor2 Factor3 Factor4
## SS loadings      3.191   2.946   1.669   1.659
## Proportion Var   0.245   0.227   0.128   0.128
## Cumulative Var   0.245   0.472   0.600   0.728
## 
## Test of the hypothesis that 4 factors are sufficient.
## The chi square statistic is 50.24 on 32 degrees of freedom.
## The p-value is 0.0212
KMO(validity)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = validity)
## Overall MSA =  0.85
## MSA for each item = 
##  [1] 0.61 0.61 0.91 0.80 0.78 0.57 0.86 0.89 0.93 0.86 0.89 0.86 0.90
summary(prcomp(validity)) ## 4 components explain more than 80% of the variance
## Importance of components%s:
##                           PC1    PC2    PC3     PC4     PC5     PC6
## Standard deviation     5.5267 3.1664 2.6467 2.39744 1.89055 1.77853
## Proportion of Variance 0.4598 0.1509 0.1055 0.08653 0.05381 0.04762
## Cumulative Proportion  0.4598 0.6108 0.7162 0.80274 0.85655 0.90417
##                            PC7     PC8     PC9    PC10    PC11   PC12
## Standard deviation     1.23423 1.06517 1.04831 0.95885 0.86186 0.7199
## Proportion of Variance 0.02293 0.01708 0.01654 0.01384 0.01118 0.0078
## Cumulative Proportion  0.92710 0.94418 0.96072 0.97456 0.98575 0.9936
##                           PC13
## Standard deviation     0.65460
## Proportion of Variance 0.00645
## Cumulative Proportion  1.00000
screeplot(prcomp(validity),type="lines")

biplot(prcomp(validity,scale.=T),cex=0.8,xlabs=rep(".",nrow(validity)))

rcorr(as.matrix(validity))
##       [,1] [,2] [,3]  [,4]  [,5]  [,6]  [,7]  [,8] [,9] [,10] [,11] [,12]
##  [1,] 1.00 0.78 0.08  0.10  0.09  0.10  0.31  0.27 0.22  0.30  0.08  0.09
##  [2,] 0.78 1.00 0.02  0.08  0.10  0.02  0.32  0.35 0.20  0.33  0.04  0.06
##  [3,] 0.08 0.02 1.00  0.41  0.40  0.06  0.22  0.18 0.37  0.24  0.47  0.49
##  [4,] 0.10 0.08 0.41  1.00  0.72 -0.06  0.33  0.34 0.35  0.29  0.42  0.44
##  [5,] 0.09 0.10 0.40  0.72  1.00 -0.18  0.38  0.46 0.34  0.37  0.40  0.44
##  [6,] 0.10 0.02 0.06 -0.06 -0.18  1.00 -0.03 -0.07 0.08  0.00  0.18  0.12
##  [7,] 0.31 0.32 0.22  0.33  0.38 -0.03  1.00  0.77 0.74  0.89  0.52  0.52
##  [8,] 0.27 0.35 0.18  0.34  0.46 -0.07  0.77  1.00 0.67  0.80  0.46  0.46
##  [9,] 0.22 0.20 0.37  0.35  0.34  0.08  0.74  0.67 1.00  0.72  0.65  0.63
## [10,] 0.30 0.33 0.24  0.29  0.37  0.00  0.89  0.80 0.72  1.00  0.53  0.54
## [11,] 0.08 0.04 0.47  0.42  0.40  0.18  0.52  0.46 0.65  0.53  1.00  0.90
## [12,] 0.09 0.06 0.49  0.44  0.44  0.12  0.52  0.46 0.63  0.54  0.90  1.00
## [13,] 0.13 0.09 0.47  0.41  0.41  0.17  0.53  0.51 0.65  0.56  0.87  0.89
##       [,13]
##  [1,]  0.13
##  [2,]  0.09
##  [3,]  0.47
##  [4,]  0.41
##  [5,]  0.41
##  [6,]  0.17
##  [7,]  0.53
##  [8,]  0.51
##  [9,]  0.65
## [10,]  0.56
## [11,]  0.87
## [12,]  0.89
## [13,]  1.00
## 
## n= 212 
## 
## 
## P
##       [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  
##  [1,]        0.0000 0.2474 0.1635 0.1734 0.1429 0.0000 0.0000 0.0012
##  [2,] 0.0000        0.7273 0.2537 0.1639 0.7462 0.0000 0.0000 0.0030
##  [3,] 0.2474 0.7273        0.0000 0.0000 0.4000 0.0015 0.0075 0.0000
##  [4,] 0.1635 0.2537 0.0000        0.0000 0.3553 0.0000 0.0000 0.0000
##  [5,] 0.1734 0.1639 0.0000 0.0000        0.0087 0.0000 0.0000 0.0000
##  [6,] 0.1429 0.7462 0.4000 0.3553 0.0087        0.6433 0.3058 0.2241
##  [7,] 0.0000 0.0000 0.0015 0.0000 0.0000 0.6433        0.0000 0.0000
##  [8,] 0.0000 0.0000 0.0075 0.0000 0.0000 0.3058 0.0000        0.0000
##  [9,] 0.0012 0.0030 0.0000 0.0000 0.0000 0.2241 0.0000 0.0000       
## [10,] 0.0000 0.0000 0.0004 0.0000 0.0000 0.9499 0.0000 0.0000 0.0000
## [11,] 0.2234 0.5187 0.0000 0.0000 0.0000 0.0095 0.0000 0.0000 0.0000
## [12,] 0.2140 0.3791 0.0000 0.0000 0.0000 0.0735 0.0000 0.0000 0.0000
## [13,] 0.0564 0.2101 0.0000 0.0000 0.0000 0.0157 0.0000 0.0000 0.0000
##       [,10]  [,11]  [,12]  [,13] 
##  [1,] 0.0000 0.2234 0.2140 0.0564
##  [2,] 0.0000 0.5187 0.3791 0.2101
##  [3,] 0.0004 0.0000 0.0000 0.0000
##  [4,] 0.0000 0.0000 0.0000 0.0000
##  [5,] 0.0000 0.0000 0.0000 0.0000
##  [6,] 0.9499 0.0095 0.0735 0.0157
##  [7,] 0.0000 0.0000 0.0000 0.0000
##  [8,] 0.0000 0.0000 0.0000 0.0000
##  [9,] 0.0000 0.0000 0.0000 0.0000
## [10,]        0.0000 0.0000 0.0000
## [11,] 0.0000        0.0000 0.0000
## [12,] 0.0000 0.0000        0.0000
## [13,] 0.0000 0.0000 0.0000
# VALIDITY without purchase intent
validity<-cbind(MainStudy$Q13_4,MainStudy$Q13_5,
                MainStudy$Q17_1,MainStudy$Q17_2,MainStudy$Q17_3,
                MainStudy$Q19_1,MainStudy$Q19_2,MainStudy$Q19_4)
factanal(validity,3,rotation="varimax") ## 3 factors explain more than 70% of the variance
## 
## Call:
## factanal(x = validity, factors = 3, rotation = "varimax")
## 
## Uniquenesses:
## [1] 0.381 0.005 0.778 0.304 0.253 0.154 0.286 0.064
## 
## Loadings:
##      Factor1 Factor2 Factor3
## [1,]  0.178           0.766 
## [2,]  0.176           0.982 
## [3,]  0.152   0.446         
## [4,]  0.137   0.822         
## [5,]  0.222   0.834         
## [6,]  0.876   0.228   0.165 
## [7,]  0.760   0.301   0.214 
## [8,]  0.934   0.191   0.164 
## 
##                Factor1 Factor2 Factor3
## SS loadings      2.371   1.750   1.655
## Proportion Var   0.296   0.219   0.207
## Cumulative Var   0.296   0.515   0.722
## 
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 16.33 on 7 degrees of freedom.
## The p-value is 0.0223
KMO(validity)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = validity)
## Overall MSA =  0.73
## MSA for each item = 
## [1] 0.60 0.61 0.81 0.69 0.72 0.77 0.86 0.74
summary(prcomp(validity)) ## 3 components explain more than 80% of the variance
## Importance of components%s:
##                           PC1    PC2    PC3     PC4     PC5     PC6    PC7
## Standard deviation     4.0236 2.8915 2.3136 1.88315 1.15895 1.05199 0.9147
## Proportion of Variance 0.4354 0.2248 0.1440 0.09537 0.03612 0.02976 0.0225
## Cumulative Proportion  0.4354 0.6603 0.8042 0.89957 0.93570 0.96546 0.9880
##                            PC8
## Standard deviation     0.66917
## Proportion of Variance 0.01204
## Cumulative Proportion  1.00000
screeplot(prcomp(validity),type="lines")

biplot(prcomp(validity,scale.=T),cex=0.8,xlabs=rep(".",nrow(validity)))

rcorr(as.matrix(validity))
##      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,] 1.00 0.78 0.08 0.10 0.09 0.31 0.27 0.30
## [2,] 0.78 1.00 0.02 0.08 0.10 0.32 0.35 0.33
## [3,] 0.08 0.02 1.00 0.41 0.40 0.22 0.18 0.24
## [4,] 0.10 0.08 0.41 1.00 0.72 0.33 0.34 0.29
## [5,] 0.09 0.10 0.40 0.72 1.00 0.38 0.46 0.37
## [6,] 0.31 0.32 0.22 0.33 0.38 1.00 0.77 0.89
## [7,] 0.27 0.35 0.18 0.34 0.46 0.77 1.00 0.80
## [8,] 0.30 0.33 0.24 0.29 0.37 0.89 0.80 1.00
## 
## n= 212 
## 
## 
## P
##      [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]  
## [1,]        0.0000 0.2474 0.1635 0.1734 0.0000 0.0000 0.0000
## [2,] 0.0000        0.7273 0.2537 0.1639 0.0000 0.0000 0.0000
## [3,] 0.2474 0.7273        0.0000 0.0000 0.0015 0.0075 0.0004
## [4,] 0.1635 0.2537 0.0000        0.0000 0.0000 0.0000 0.0000
## [5,] 0.1734 0.1639 0.0000 0.0000        0.0000 0.0000 0.0000
## [6,] 0.0000 0.0000 0.0015 0.0000 0.0000        0.0000 0.0000
## [7,] 0.0000 0.0000 0.0075 0.0000 0.0000 0.0000        0.0000
## [8,] 0.0000 0.0000 0.0004 0.0000 0.0000 0.0000 0.0000