Created
August 2, 2020 23:55
-
-
Save stephen-charlesworth-milliman/935d33affa8a08b18fcf73e1e2483e1f to your computer and use it in GitHub Desktop.
Correspondence analysis simple example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ca fun | |
# from the qualtrics example https://www.qualtrics.com/eng/correspondence-analysis-what-is-it-and-how-can-i-use-it-to-measure-my-brand-part-1-of-2/ | |
library(ca) | |
# this just re-creates their initial table | |
mydata <- data.frame( | |
Brand = c(rep('Butterbeer',3), | |
rep('Squishee', 3), | |
rep('Slurm', 3), | |
rep('Fizzy Lifting Drink', 3), | |
rep('Brawndo', 3)), | |
Attributes = rep(c('Tasty', 'Aesthetic', 'Economic'), 5), | |
Counts = c(5,7,2,18,46,20,19,29,39,12,40,49,3,7,16) | |
) | |
mytable <- xtabs(Counts ~ ., mydata) | |
# Brand on rows | |
# Actual 'work' starts heere | |
prop.table(mytable, 1) # row percentages | |
prop.table(mytable, 2) # column percentages | |
fit <- ca(mytable) | |
print(fit) # basic results | |
summary(fit) # extended results | |
#Principal Normalization Correspondence Analysis (Symmetrical, French Map, Canonical) | |
plot(fit) # symmetric map | |
plot(fit, mass = TRUE, contrib = "absolute", map = | |
"rowgreen", arrows = c(FALSE, TRUE)) # asymmetric map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment