LAB 9 WORD FILE R STUDIO

docx

School

Durham College *

*We aren’t endorsed by this school

Course

DATA

Subject

Statistics

Date

Apr 3, 2024

Type

docx

Pages

8

Uploaded by JudgeBravery13371

Report
Lab 9: Principal Component Analysis Set-up Firstly, I loaded the Banknotes dataset. Lab Steps 1. Perform PCA using the Banknote dataset without including the “Status” variable. ANS: - library(tidyverse) library(factoextra) library(ISLR2) library(caret) data = mclust::banknote view(mclust::banknote) PCAbanknote <- mclust::banknote %>% select(-Status) %>% prcomp(center = TRUE, scale = TRUE) summary(PCAbanknote) 2. Display the summary and the scree plot for variance explained. ANS :- SCREEE PLOT:-
3. How many Principal Components would you choose to keep in the data? Explain your reasoning. ANS : - I will choose first 5 Principal Components as we get the most significant cumulative threshold variances till this that is approx. 0.96%. 4.Graph a scatter plot which shows the first component on the X-axis, the second component on the Y-axis and colours based on the Status variable ANS :- datadiag <- mclust::banknote %>% mutate(PCA1 = PCAbanknote$x[, "PC1"], PCA2 = PCAbanknote$x[, "PC2"]) ggplot(datadiag, aes(PCA1, PCA2, col = Status)) + geom_point() + theme_bw()
5.What do you notice about this graph? ANS :- The both parts of status i.e. counterfeit and genuine are far apart scattered showing no correlation between them . 6.Display the contributions of each variable to the PCA you just performed. ANS:-
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
7. Which variables contributed the most to PC1 and which to PC2? ANS :- IN [PCA 1] :- The most contributing variable is DIAGONAL(24.350111100) & [PCA 2] :- The most contributing one is LENGTH(66.5032044).
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
.