Principal Component Analysis in R Programming | How to Apply PCA | Step-by-Step Tutorial & Example

Publicado el: 28 junio 2023
en el canal de: Statistics Globe
30,758
688

This video explains how to apply a Principal Component Analysis (PCA) in R. More details: https://statisticsglobe.com/principal...

The video is presented by Cansu Kebabci, a data scientist and statistician at Statistics Globe. Find more information about Cansu here: https://statisticsglobe.com/cansu-keb...

In the video, Cansu explains the steps and application of the Principal Component Analysis in R. Watch the video to learn more on this topic!

Here can you find the first part of this series:

Introduction to Principal Component Analysis (Pt. 1 - Theory):    • Introduction to Principal Component A...  

Links to the tutorials mentioned in the video:

Can PCA be Used for Categorical Variables? (Alternatives & Example): https://statisticsglobe.com/pca-categ...

PCA Using Correlation & Covariance Matrix (Examples): https://statisticsglobe.com/pca-corre...

Biplot of PCA in R (Examples): https://statisticsglobe.com/biplot-pca-r

R code of this video:

install.packages("MASS")
install.packages("factoextra")
install.packages("ggplot2")

Load Libraries
library(MASS)
library(factoextra)
library(ggplot2)


Import biopsy data
data(biopsy)
dim(biopsy)

Structure of Data
str(biopsy)
summary(biopsy)


Delete Cases with Missingness
biopsy_nomiss <- na.omit(biopsy)

Exclude Categorical Data
biopsy_sample <- biopsy_nomiss[,-c(1,11)]


Run PCA
biopsy_pca <- prcomp(biopsy_sample,
scale = TRUE)

Summary of Analysis
summary(biopsy_pca)


Elements of PCA object
names(biopsy_pca)

Std Dev of Components
biopsy_pca$sdev

Eigenvectors
biopsy_pca$rotation

Std Dev and Mean of Variables
biopsy_pca$center
biopsy_pca$scale

Principal Component Scores
biopsy_pca$x


Scree Plot of Variance
fviz_eig(biopsy_pca,
addlabels = TRUE,
ylim = c(0, 70))

Biplot with Default Settings
fviz_pca_biplot(biopsy_pca)

Biplot with Labeled Variables
fviz_pca_biplot(biopsy_pca,
label="var")

Biplot with Colored Groups
fviz_pca_biplot(biopsy_pca,
label="var",
habillage = biopsy_nomiss$class)

Biplot with Customized Colored Groups and Variables
fviz_pca_biplot(biopsy_pca,
label="var",
habillage = biopsy_nomiss$class,
col.var = "black") +
scale_color_manual(values=c("orange", "purple"))


Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – R Programming Group for Discussions & Questions:   / statisticsglobe  
Facebook – Python Programming Group for Discussions & Questions:   / statisticsglobepython  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – R Programming Group for Discussions & Questions:   / 12555223  
LinkedIn – Python Programming Group for Discussions & Questions:   / 12673534  
Twitter:   / joachimschork  
Instagram:   / statisticsglobecom  
TikTok:   / statisticsglobe  


En esta página del sitio puede ver el video en línea Principal Component Analysis in R Programming | How to Apply PCA | Step-by-Step Tutorial & Example de Duración hora minuto segunda en buena calidad , que subió el usuario Statistics Globe 28 junio 2023, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 30,758 veces y le gustó 688 a los espectadores. Disfruta viendo!