library(tidyverse)
library(ggfortify)
library(MASS)
1
gospels <- read.csv("https://goo.gl/mdBVVe")
row.names(gospels) <- gospels$word
PCA <- prcomp(gospels[,2:5])
summary(PCA)
## Importance of components%s:
## PC1 PC2 PC3 PC4
## Standard deviation 0.003482 0.001599 0.0008725 0.0007001
## Proportion of Variance 0.761020 0.160420 0.0477900 0.0307700
## Cumulative Proportion 0.761020 0.921440 0.9692300 1.0000000
autoplot(PCA,
shape = FALSE,
loadings = TRUE,
label = TRUE,
loadings.label = TRUE)+
theme_bw()
predict(PCA, data.frame(John = 0.05, Luke = 0.01, Mark = 0.02, Matthew = 0.02))
## PC1 PC2 PC3 PC4
## [1,] -0.05281351 -0.01686337 0.006094607 0.002708408
2.
lev <- read.csv("http://hsequantling.wikispaces.com/file/view/Levshina_DutchCausCx.txt/567799791/Levshina_DutchCausCx.txt", sep = "\t")
MCA <- mca(lev[,-1])
lev <- cbind(lev, MCA$rs)
lev %>%
ggplot(aes(`1`, `2`, color = Aux))+
geom_point()+
stat_ellipse()+
theme_bw()