library(readxl)
MockJuryData <- read_excel("q2.mockjury.xlsx")
MockJuryData
## # A tibble: 114 × 12
##    Seriousness exciting  calm independent sincere  warm sociable  kind
##          <dbl>    <dbl> <dbl>       <dbl>   <dbl> <dbl>    <dbl> <dbl>
##  1           8        6     9           9       8     5        9     9
##  2           8        9     5           9       3     5        9     4
##  3           5        3     4           6       3     6        4     2
##  4           3        3     6           9       8     8        9     9
##  5           9        1     1           5       1     8        9     4
##  6           9        1     5           7       5     8        9     5
##  7           4        5     6           7       6     7        7     5
##  8           4        4     9           2       9     6        2     9
##  9           5        4     8           8       7     1        1     5
## 10           2        6     8           7       5     7        9     7
## # ℹ 104 more rows
## # ℹ 4 more variables: intelligent <dbl>, strong <dbl>, sophisticated <dbl>,
## #   happy <dbl>
sd(MockJuryData$exciting)
## [1] 2.315125
sd(MockJuryData$calm)
## [1] 2.390921
sd(MockJuryData$independent)
## [1] 2.494288
sd(MockJuryData$sincere)
## [1] 2.622144
sd(MockJuryData$warm)
## [1] 2.47454
sd(MockJuryData$sociable)
## [1] 2.366855
sd(MockJuryData$kind)
## [1] 2.472092
sd(MockJuryData$intelligent)
## [1] 2.818929
sd(MockJuryData$strong)
## [1] 2.327148
sd(MockJuryData$sophisticated)
## [1] 2.450519
sd(MockJuryData$happy)
## [1] 2.52872
cor(MockJuryData[2:12])
##                 exciting       calm independent    sincere       warm
## exciting      1.00000000 0.23232431  0.12893165 0.09299070 0.11004167
## calm          0.23232431 1.00000000  0.07755421 0.09539183 0.10491309
## independent   0.12893165 0.07755421  1.00000000 0.17205280 0.23147890
## sincere       0.09299070 0.09539183  0.17205280 1.00000000 0.25597536
## warm          0.11004167 0.10491309  0.23147890 0.25597536 1.00000000
## sociable      0.14394846 0.06765546  0.23688237 0.10716869 0.07320244
## kind          0.18306899 0.28665593  0.13071587 0.23273282 0.59844198
## intelligent   0.03629112 0.16569424  0.25619321 0.14404676 0.38405692
## strong        0.07443421 0.11976147  0.30684230 0.23722931 0.32088399
## sophisticated 0.18156088 0.05909193  0.23611019 0.22376381 0.41301777
## happy         0.14873671 0.25486558  0.35227716 0.17680470 0.44125842
##                  sociable        kind intelligent     strong sophisticated
## exciting       0.14394846  0.18306899  0.03629112 0.07443421    0.18156088
## calm           0.06765546  0.28665593  0.16569424 0.11976147    0.05909193
## independent    0.23688237  0.13071587  0.25619321 0.30684230    0.23611019
## sincere        0.10716869  0.23273282  0.14404676 0.23722931    0.22376381
## warm           0.07320244  0.59844198  0.38405692 0.32088399    0.41301777
## sociable       1.00000000 -0.05432932  0.12408572 0.25748952    0.09166722
## kind          -0.05432932  1.00000000  0.39620062 0.13555675    0.45417616
## intelligent    0.12408572  0.39620062  1.00000000 0.35999488    0.39114793
## strong         0.25748952  0.13555675  0.35999488 1.00000000    0.37314294
## sophisticated  0.09166722  0.45417616  0.39114793 0.37314294    1.00000000
## happy          0.13023305  0.38492036  0.41753727 0.40972581    0.45495424
##                   happy
## exciting      0.1487367
## calm          0.2548656
## independent   0.3522772
## sincere       0.1768047
## warm          0.4412584
## sociable      0.1302331
## kind          0.3849204
## intelligent   0.4175373
## strong        0.4097258
## sophisticated 0.4549542
## happy         1.0000000
MockJuryData.pc <- princomp(MockJuryData[,-1], cor = T)
summary(MockJuryData.pc, loadings = T)
## Importance of components:
##                           Comp.1    Comp.2    Comp.3     Comp.4     Comp.5
## Standard deviation     1.8648888 1.1392656 1.0756243 0.95764457 0.91220521
## Proportion of Variance 0.3161646 0.1179933 0.1051789 0.08337119 0.07564712
## Cumulative Proportion  0.3161646 0.4341578 0.5393367 0.62270791 0.69835503
##                            Comp.6     Comp.7     Comp.8     Comp.9    Comp.10
## Standard deviation     0.85845354 0.83309871 0.76456831 0.72978205 0.68495750
## Proportion of Variance 0.06699477 0.06309577 0.05314225 0.04841653 0.04265153
## Cumulative Proportion  0.76534980 0.82844557 0.88158782 0.93000435 0.97265587
##                           Comp.11
## Standard deviation     0.54843907
## Proportion of Variance 0.02734413
## Cumulative Proportion  1.00000000
## 
## Loadings:
##               Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9
## exciting       0.157         0.674  0.183  0.548         0.197  0.155  0.307
## calm           0.182 -0.122  0.627 -0.289 -0.572                      -0.126
## independent    0.266  0.402                0.102  0.760 -0.305              
## sincere        0.224                0.822 -0.425                0.189       
## warm           0.383 -0.242 -0.156  0.121               -0.359 -0.423  0.382
## sociable       0.139  0.631  0.154               -0.537 -0.451        -0.235
## kind           0.361 -0.477                             -0.311              
## intelligent    0.352        -0.197 -0.325 -0.121 -0.183         0.754  0.239
## strong         0.324  0.350 -0.182        -0.165 -0.152  0.533 -0.246  0.442
## sophisticated  0.374        -0.155         0.357 -0.133  0.335  0.111 -0.582
## happy          0.395               -0.260         0.182  0.169 -0.319 -0.300
##               Comp.10 Comp.11
## exciting       0.163         
## calm          -0.251   0.249 
## independent   -0.264         
## sincere        0.178         
## warm                   0.532 
## sociable                     
## kind          -0.219  -0.691 
## intelligent    0.200   0.104 
## strong        -0.279  -0.259 
## sophisticated -0.370   0.281 
## happy          0.711  -0.126
plot(1:length(MockJuryData.pc$sdev), MockJuryData.pc$sdev^2,
     xlab = "Principal Component",
     ylab = "Variance Explained (EigenValue Size)",
     type = "b")

biplot(MockJuryData.pc, xlabs = MockJuryData$Seriousness, xlim=c(-0.25,0.25), ylim=c(-0.25,0.25), 
       cex = 0.8, col = c("black", "maroon"))

par(pty="s")
plot(MockJuryData.pc$scores[,1],
     MockJuryData.pc$scores[,2],
     ylim=range(MockJuryData.pc$scores[,1]),
     xlab="PC 1", ylab="PC 2", type ='n', lwd=2)
seriousness_level <- cut(MockJuryData$Seriousness, 
                   breaks = c(0, 3, 6, 8, 10), 
                   labels = c("Low", "Moderately Serious", "Serious", "Very Serious"))
colors <- c("darkblue", "lightseagreen", "maroon3", "mediumpurple1")[as.numeric(seriousness_level)]
text(MockJuryData.pc$scores[,1], 
     MockJuryData.pc$scores[,2], 
     labels = seriousness_level, 
     cex=0.7, lwd=2,
     col = colors)

library(readxl)
MockJuryMR <- read_excel("MJq2.xlsx")
MockJuryMR <- lm(Seriousness ~ exciting + calm + independent + sincere + warm + 
                   sociable + kind + intelligent + strong + sophisticated + happy, data = MockJuryMR)
summary(MockJuryMR)
## 
## Call:
## lm(formula = Seriousness ~ exciting + calm + independent + sincere + 
##     warm + sociable + kind + intelligent + strong + sophisticated + 
##     happy, data = MockJuryMR)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.4788 -1.4433 -0.2642  1.4562  6.1742 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    4.491887   0.893533   5.027 2.14e-06 ***
## exciting       0.179157   0.090266   1.985   0.0499 *  
## calm           0.037693   0.091016   0.414   0.6796    
## independent   -0.088603   0.088009  -1.007   0.3164    
## sincere       -0.120838   0.079841  -1.513   0.1332    
## warm          -0.069092   0.108158  -0.639   0.5244    
## sociable       0.005445   0.088981   0.061   0.9513    
## kind          -0.188807   0.114217  -1.653   0.1014    
## intelligent   -0.123693   0.084158  -1.470   0.1447    
## strong         0.221480   0.103080   2.149   0.0340 *  
## sophisticated  0.128905   0.102116   1.262   0.2097    
## happy          0.121161   0.100718   1.203   0.2318    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.089 on 102 degrees of freedom
## Multiple R-squared:  0.1877, Adjusted R-squared:  0.1001 
## F-statistic: 2.143 on 11 and 102 DF,  p-value: 0.02349