## load the data
#question1
datao<-read.csv("C:/Users/Ashwini Khandelwal/Downloads/move_au.csv")
View(datao)
library(factoextra)
data<-datao[5:10]
res.pca <- prcomp(data, scale = TRUE)
fviz_eig(res.pca)
library(factoextra)
# Eigenvalues
eig.val <- get_eigenvalue(res.pca)
eig.val
# Results for Variables
res.var <- get_pca_var(res.pca)
res.var$coord # Coordinates
res.var$contrib # Contributions to the PCs
res.var$cos2 # Quality of representation
# Results for individuals
res.ind <- get_pca_ind(res.pca)
res.ind$coord # Coordinates
res.ind$contrib # Contributions to the PCs
res.ind$cos2
fit <- factanal(data, 3, rotation="varimax")
print(fit, digits=2, cutoff=.3, sort=TRUE)
# plot factor 1 by factor 2
load <- fit$loadings[,1:2]
plot(load,type="n") # set up plot
text(load,labels=names(data),cex=.7)
library(psych)
fit <- factor.pa(data, nfactors=3)
fit # print results
#install.packages("nFactors")
library(nFactors)
ev <- eigen(cor(data)) # get eigenvalues
ev$vectors
ap <- parallel(subject=nrow(data),var=ncol(data),
rep=100,cent=.05)
nS <- nScree(x=ev$values, aparallel=ap$eigen$qevpea)
plotnScree(nS)
boxplot(ev$vectors)
a<-ev$vectors[,1]
View(a)
data1<-head(datao)
data1$a<-a
data1
library(lubridate)
data1$date<-as.Date(data1$date,format="%Y-%m-%d")
plot(data1$date, data1$a, main = "Main title",
xlab = "X axis title", ylab = "Y axis title",
pch = 19, frame = FALSE)
ggplot(data1, aes(x=data1$country_region, y=data1$a)) +
geom_boxplot(notch=TRUE)