You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i = 1
par(mfrow = c(5, 6), mar = c(2,2,2,2))
for (col in mv[2:38]) {
hist(col, main = colnames(mv)[i],col=rainbow(i))
i = i + 1
}
Fitting the model with 30 variables
model <- lm(mvliking ~ ., data=mv[1:31])
summary(model)
Factor Analysis
Pre-factor diagnostics
# Bartlett test of sphericity
bart_spher(mv[,colnames(mv)[2:31]])
# Kaiser-Meyer-Olkin Measure of sampling adequacy
KMOS(mv[,colnames(mv)[2:31]])
Determine the number of factors
# Create a table of results for ease of interpretation
ev <- eigen(cor(mv[,colnames(mv)[2:31]]))$values
e <- data.frame(Eigenvalue = ev, PropOfVar = ev / length(ev), CumPropOfVar = cumsum(ev / length(ev)))
round(e, 4)
Draw a scree plot
p <- ggplot()
p <- p + geom_line(aes(x = 1:length(ev), y = ev))
p <- p + geom_point(aes(x = 1:length(ev), y = ev))
p <- p + geom_hline(yintercept = 1, colour = "red")
p <- p + labs(x = "Number", y = "Eigenvalues", title = "Scree Plot of Eigenvalues")
p <- p + scale_x_continuous(breaks = 1:length(ev), minor_breaks = NULL)
p <- p + theme_bw()
p
Extract solution
Select number of factors
n <- length(which(ev > 1))
Extract and rotate principal components
library(psych)
pc <- principal(mv[,colnames(mv)[2:31]], nfactors = n, rotate="varimax")
Create a factor loadings table; Sort based on uniqueness
Recommendations on which characteristics are most important for determining whether a customer has a favourable perception of the microvan concept, to segment the market, and to determine which segment(s) would be good to target based on the analysis of data.