0% found this document useful (0 votes)
34 views

Kanseei Tahapt 2

This document performs a principal component analysis (PCA) on survey data containing responses to 10 variables for 15 individuals. It loads and prepares the data, runs the PCA, and examines the results, including variable coordinates, contributions, and cosines. The analysis identifies the key dimensions in the data and variables most strongly correlated with each dimension.

Uploaded by

ryusrianammar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Kanseei Tahapt 2

This document performs a principal component analysis (PCA) on survey data containing responses to 10 variables for 15 individuals. It loads and prepares the data, runs the PCA, and examines the results, including variable coordinates, contributions, and cosines. The analysis identifies the key dimensions in the data and variables most strongly correlated with each dimension.

Uploaded by

ryusrianammar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Kanseiiiii Tahap 2

Reimundo

2023-11-20

#PCA
library("FactoMineR")

## Warning: package 'FactoMineR' was built under R version 4.1.3

library("factoextra")

## Warning: package 'factoextra' was built under R version 4.1.3

## Loading required package: ggplot2

## Welcome! Want to learn more? See two factoextra-related books at


https://goo.gl/ve3WBa

#Pastikan memanggil package setiap script

library(readxl)

## Warning: package 'readxl' was built under R version 4.1.3

Copy_of_Hasil_Tahap_2_1_ <- read_excel("X:/.Tugas/Semester 5/Kansei/Copy of


Hasil Tahap 2(1).xlsx")
tail(Copy_of_Hasil_Tahap_2_1_)

## # A tibble: 6 x 11
## Sample Menarik Berwarna Artistik Modern Simpel Unik `Memiliki ciri
khas`
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
<dbl>
## 1 10 2.93 3.63 3.17 3 3.13 3.07 3.7

## 2 11 3 3.1 2.53 3.37 2.87 3.13 2.9

## 3 12 3.03 3.3 2.77 3.1 3.8 3.23


2.73
## 4 13 3.43 3.37 3.3 3 2.93 2.97
3.17
## 5 14 3.1 3.3 3.2 2.93 3.1 2.9
2.97
## 6 15 3.4 3.27 3 2.97 2.9 2.63
2.93
## # i 3 more variables: Inovatif <dbl>, `Mudah dibawa` <dbl>,
## # `Ramah lingkungan` <dbl>
library(dplyr)

## Warning: package 'dplyr' was built under R version 4.1.3

##
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':


##
## filter, lag

## The following objects are masked from 'package:base':


##
## intersect, setdiff, setequal, union

Copy_of_Hasil_Tahap_2_1_2 <- Copy_of_Hasil_Tahap_2_1_ %>%


select(-c(Sample))
head(Copy_of_Hasil_Tahap_2_1_2)

## # A tibble: 6 x 10
## Menarik Berwarna Artistik Modern Simpel Unik `Memiliki ciri khas`
Inovatif
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
<dbl>
## 1 3.07 2.9 3.37 3.2 2.87 2.8 2.77
3.3
## 2 3.33 2.63 3.27 2.73 3.2 3.37 3.5
2.53
## 3 3.43 3.07 2.73 3.4 3.03 3.2 3.27
2.83
## 4 2.93 3.13 3.07 3.13 3.37 3.17 3.23
3.13
## 5 2.8 2.6 2.7 3.37 2.5 3.17 3.03
3.03
## 6 2.83 3.23 2.77 3.23 3.4 3.43 3.03
2.83
## # i 2 more variables: `Mudah dibawa` <dbl>, `Ramah lingkungan` <dbl>

library("FactoMineR")
res.pca <- PCA(Copy_of_Hasil_Tahap_2_1_2, graph = FALSE)
print(res.pca)

## **Results for the Principal Component Analysis (PCA)**


## The analysis was performed on 15 individuals, described by 10 variables
## *The results are available in the following objects:
##
## name description
## 1 "$eig" "eigenvalues"
## 2 "$var" "results for the variables"
## 3 "$var$coord" "coord. for the variables"
## 4 "$var$cor" "correlations variables - dimensions"
## 5 "$var$cos2" "cos2 for the variables"
## 6 "$var$contrib" "contributions of the variables"
## 7 "$ind" "results for the individuals"
## 8 "$ind$coord" "coord. for the individuals"
## 9 "$ind$cos2" "cos2 for the individuals"
## 10 "$ind$contrib" "contributions of the individuals"
## 11 "$call" "summary statistics"
## 12 "$call$centre" "mean of the variables"
## 13 "$call$ecart.type" "standard error of the variables"
## 14 "$call$row.w" "weights for the individuals"
## 15 "$call$col.w" "weights for the variables"

library("factoextra")
eig.val <- get_eigenvalue(res.pca)
eig.val

## eigenvalue variance.percent cumulative.variance.percent


## Dim.1 2.54920423 25.4920423 25.49204
## Dim.2 2.00794765 20.0794765 45.57152
## Dim.3 1.40776992 14.0776992 59.64922
## Dim.4 1.23663258 12.3663258 72.01554
## Dim.5 1.02843263 10.2843263 82.29987
## Dim.6 0.77215965 7.7215965 90.02147
## Dim.7 0.46349935 4.6349935 94.65646
## Dim.8 0.35282246 3.5282246 98.18468
## Dim.9 0.13934842 1.3934842 99.57817
## Dim.10 0.04218311 0.4218311 100.00000

library(factoextra)
fviz_eig(res.pca, addlabels = TRUE, ylim = c(0, 50))
var <- get_pca_var(res.pca)
var

## Principal Component Analysis Results for variables


## ===================================================
## Name Description
## 1 "$coord" "Coordinates for the variables"
## 2 "$cor" "Correlations between variables and dimensions"
## 3 "$cos2" "Cos2 for the variables"
## 4 "$contrib" "contributions of the variables"

# Coordinates
head(var$coord)

## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5


## Menarik 0.51408313 0.04440222 -0.102145147 0.220572337 0.759242268
## Berwarna 0.35658282 0.04214075 0.746340999 -0.199475700 0.245824214
## Artistik 0.71641562 -0.02001992 0.295486268 0.439266222 -0.222365997
## Modern -0.80778287 -0.43059008 0.026652693 -0.024021604 0.297602549
## Simpel 0.01785727 0.67278998 0.531854270 -0.410805058 0.009378045
## Unik -0.51703376 0.68993149 0.002821725 0.008439085 0.145275954

# Cos2: quality on the factore map


head(var$cos2)

## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5


## Menarik 0.2642814660 0.0019715569 1.043363e-02 4.865216e-02 5.764488e-01
## Berwarna 0.1271513066 0.0017758428 5.570249e-01 3.979055e-02 6.042954e-02
## Artistik 0.5132513467 0.0004007972 8.731213e-02 1.929548e-01 4.944664e-02
## Modern 0.6525131607 0.1854078187 7.103661e-04 5.770375e-04 8.856728e-02
## Simpel 0.0003188821 0.4526463510 2.828690e-01 1.687608e-01 8.794772e-05
## Unik 0.2673239117 0.4760054580 7.962133e-06 7.121815e-05 2.110510e-02

# Contributions to the principal components


head(var$contrib)

## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5


## Menarik 10.36721431 0.09818766 7.411460e-01 3.934245055 56.051199199
## Berwarna 4.98788229 0.08844069 3.956789e+01 3.217653790 5.875887490
## Artistik 20.13378685 0.01996054 6.202159e+00 15.603245231 4.807960704
## Modern 25.59673926 9.23369781 5.046038e-02 0.046661998 8.611869626
## Simpel 0.01250908 22.54273661 2.009341e+01 13.646801745 0.008551627
## Unik 10.48656315 23.70606908 5.655848e-04 0.005759039 2.052161930

# Coordinates of variables
head(var$coord, 15)

## Dim.1 Dim.2 Dim.3 Dim.4


## Menarik 0.51408313 0.04440222 -0.102145147 0.220572337
## Berwarna 0.35658282 0.04214075 0.746340999 -0.199475700
## Artistik 0.71641562 -0.02001992 0.295486268 0.439266222
## Modern -0.80778287 -0.43059008 0.026652693 -0.024021604
## Simpel 0.01785727 0.67278998 0.531854270 -0.410805058
## Unik -0.51703376 0.68993149 0.002821725 0.008439085
## Memiliki ciri khas 0.07052178 0.51792954 -0.085622693 0.716149578
## Inovatif -0.06428722 -0.76834439 0.467464481 0.206704073
## Mudah dibawa -0.62318158 0.01972932 0.472647003 0.395117330
## Ramah lingkungan 0.57175406 -0.17534673 -0.141994698 -0.272234280
## Dim.5
## Menarik 0.7592422684
## Berwarna 0.2458242141
## Artistik -0.2223659972
## Modern 0.2976025492
## Simpel 0.0093780447
## Unik 0.1452759544
## Memiliki ciri khas 0.0005576919
## Inovatif 0.1056279135
## Mudah dibawa -0.3209283554
## Ramah lingkungan -0.3437945937

fviz_pca_var(res.pca, col.var = "black")


head(var$cos2, 15)

## Dim.1 Dim.2 Dim.3 Dim.4


## Menarik 0.2642814660 0.0019715569 1.043363e-02 4.865216e-02
## Berwarna 0.1271513066 0.0017758428 5.570249e-01 3.979055e-02
## Artistik 0.5132513467 0.0004007972 8.731213e-02 1.929548e-01
## Modern 0.6525131607 0.1854078187 7.103661e-04 5.770375e-04
## Simpel 0.0003188821 0.4526463510 2.828690e-01 1.687608e-01
## Unik 0.2673239117 0.4760054580 7.962133e-06 7.121815e-05
## Memiliki ciri khas 0.0049733211 0.2682510125 7.331246e-03 5.128702e-01
## Inovatif 0.0041328465 0.5903530943 2.185230e-01 4.272657e-02
## Mudah dibawa 0.3883552822 0.0003892462 2.233952e-01 1.561177e-01
## Ramah lingkungan 0.3269027095 0.0307464769 2.016249e-02 7.411150e-02
## Dim.5
## Menarik 5.764488e-01
## Berwarna 6.042954e-02
## Artistik 4.944664e-02
## Modern 8.856728e-02
## Simpel 8.794772e-05
## Unik 2.110510e-02
## Memiliki ciri khas 3.110202e-07
## Inovatif 1.115726e-02
## Mudah dibawa 1.029950e-01
## Ramah lingkungan 1.181947e-01

library("corrplot")
## Warning: package 'corrplot' was built under R version 4.1.3

## corrplot 0.92 loaded

corrplot(var$cos2, is.corr=FALSE)

# Total cos2 of variables on Dim.1 and Dim.2


fviz_cos2(res.pca, choice = "var", axes = 1:2)

You might also like