Dimension reduction in unsupervised learning refers to the process of reducing the number of input variables (features) in a dataset while retaining as much relevant information as possible. In other words it is a way of converting the higher dimensions dataset into lesser dimensions dataset ensuring that it provides similar information.
Why Use Dimension Reduction?
Types of Dimension Reduction Techniques
knitr::include_graphics("/Users/ashutoshverma/Downloads/Semester First folder/Unsupervised Learning/dimensionality-reduction-technique.png")
For this assignment i have focused on performing PCA (Principal Component Analysis) & t-SNE techniques on a data set. For data set i have used World Development Indicators database available on World banks’s official website. Link to the dataset : https://databank.worldbank.org/source/world-development-indicators#
Features of the dataset selected
Originally the dataset contained data related to world development indicators covering various areas Economic Policies , External Debt , Education , Environment etc. (1496 Variables) for 266 countries for time period 1960-2023. For for this assignment i have selected 18 variables for 2023.
wdi <- read.xlsx("/Users/ashutoshverma/Downloads/World_Development_Indicator.xlsm")#read the input file
colnames(wdi)#get the name of columns in the input file
## [1] "Time"
## [2] "Time.Code"
## [3] "Country.Name"
## [4] "Country.Code"
## [5] "Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP)"
## [6] "Exports.of.goods.and.services.(%.of.GDP)"
## [7] "External.balance.on.goods.and.services.(%.of.GDP)"
## [8] "Final.consumption.expenditure.(%.of.GDP)"
## [9] "General.government.final.consumption.expenditure.(%.of.GDP)"
## [10] "Gross.capital.formation.(%.of.GDP)"
## [11] "Gross.domestic.savings.(%.of.GDP)"
## [12] "Gross.fixed.capital.formation.(%.of.GDP)"
## [13] "Gross.national.expenditure.(%.of.GDP)"
## [14] "Gross.national.expenditure.deflator.(base.year.varies.by.country)"
## [15] "Gross.savings.(%.of.GDP)"
## [16] "Gross.savings.(%.of.GNI)"
## [17] "Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP)"
## [18] "Imports.of.goods.and.services.(%.of.GDP)"
## [19] "Industry.(including.construction),.value.added.(%.of.GDP)"
## [20] "Manufacturing,.value.added.(%.of.GDP)"
## [21] "Services,.value.added.(%.of.GDP)"
## [22] "Trade.(%.of.GDP)"
We can see the file contains extra columns such as “Time” , “Time.Code” , “Country.Code”. I removed these three columns to keep the data easy to handle.
# Remove the specified columns using column names . I dont think i will need these for any analysis so getting rid of them
wdi <- wdi[, !(names(wdi) %in% c("Time", "Time.Code", "Country.Code"))]
head(wdi)#check first 5 entries of the data set
## Country.Name Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP)
## 1 Afghanistan 34.5208917527827
## 2 Albania 16.2225675343538
## 3 Algeria 13.086784145579
## 4 American Samoa <NA>
## 5 Andorra 0.47849213558896
## 6 Angola 14.9021524183832
## Exports.of.goods.and.services.(%.of.GDP)
## 1 16.7751362822863
## 2 38.6650817896799
## 3 23.6195363708424
## 4 <NA>
## 5 <NA>
## 6 40.8567793904075
## External.balance.on.goods.and.services.(%.of.GDP)
## 1 -33.7230707114777
## 2 -5.16352101892789
## 3 3.55615854611284
## 4 <NA>
## 5 <NA>
## 6 14.6718701718861
## Final.consumption.expenditure.(%.of.GDP)
## 1 118.571747189003
## 2 82.2528072478475
## 3 58.7188952438211
## 4 <NA>
## 5 <NA>
## 6 61.5348797704301
## General.government.final.consumption.expenditure.(%.of.GDP)
## 1 21.1902114344589
## 2 12.0464697906067
## 3 17.9279465789317
## 4 <NA>
## 5 <NA>
## 6 5.17486195152652
## Gross.capital.formation.(%.of.GDP) Gross.domestic.savings.(%.of.GDP)
## 1 15.2 -18.5717471890027
## 2 22.9107180604133 17.7471927521525
## 3 37.724946210066 41.2811047561789
## 4 <NA> <NA>
## 5 <NA> <NA>
## 6 23.7932500575225 38.4651202295699
## Gross.fixed.capital.formation.(%.of.GDP)
## 1 15.1513235151073
## 2 24.0498902560405
## 3 32.8153081859397
## 4 <NA>
## 5 <NA>
## 6 23.7932500575225
## Gross.national.expenditure.(%.of.GDP)
## 1 133.771747189003
## 2 105.163525308261
## 3 96.4438414538872
## 4 <NA>
## 5 <NA>
## 6 85.3281298279526
## Gross.national.expenditure.deflator.(base.year.varies.by.country)
## 1 126.82960126154
## 2 133.981548734979
## 3 308.090901788823
## 4 <NA>
## 5 <NA>
## 6 4069.14184740003
## Gross.savings.(%.of.GDP) Gross.savings.(%.of.GNI)
## 1 <NA> <NA>
## 2 21.9664584876914 22.2505983429017
## 3 40.5777787869868 41.1738760660909
## 4 <NA> <NA>
## 5 <NA> <NA>
## 6 28.3837613800852 31.366558244779
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP)
## 1 97.3815357619115
## 2 70.2063374572408
## 3 40.7909486648895
## 4 <NA>
## 5 <NA>
## 6 56.3600178190649
## Imports.of.goods.and.services.(%.of.GDP)
## 1 50.498206993764
## 2 43.8286028086077
## 3 20.0633778247296
## 4 <NA>
## 5 <NA>
## 6 26.1849092185214
## Industry.(including.construction),.value.added.(%.of.GDP)
## 1 13.5231032701819
## 2 23.0184724953671
## 3 37.7570495314503
## 4 <NA>
## 5 12.4282261796617
## 6 45.2629187172157
## Manufacturing,.value.added.(%.of.GDP) Services,.value.added.(%.of.GDP)
## 1 7.60664995853586 46.5489009688383
## 2 6.87772585101551 47.9574813038329
## 3 9.29539942964952 45.6157814802809
## 4 <NA> <NA>
## 5 3.39743699615492 78.3110227448023
## 6 7.99574282011019 39.7932678112576
## Trade.(%.of.GDP)
## 1 67.2733432760503
## 2 82.4936845982876
## 3 43.682914195572
## 4 <NA>
## 5 <NA>
## 6 67.0416886089289
One of important checks that was mentioned in the class in order for a dataset to be considered for dimension reduction was to ensure that variables are not highly correlated (<60%). In order to perfrom correlation between variables we have to ensure that we dont have any NA values.
# Count rows with at least one NA value
sum(!complete.cases(wdi))
## [1] 163
Based on above output we can see that there are 163 such rows which have one or more NA value in it. Instead of replacing these NA with mean or median values i decided to drop these rows off as mean or median values cannot rightly predict the values related to development indicator variables.
#remove rows having NA to get clean data for analysis
wdi<- na.omit(wdi)
# Count rows with at least one NA value
sum(!complete.cases(wdi))
## [1] 0
All rows with NA values have been dropped. Now in order to perform correlation we need to ensure that variables are of numeric data type.
str(wdi)#check data type of variables
## 'data.frame': 103 obs. of 19 variables:
## $ Country.Name : chr "Albania" "Algeria" "Angola" "Argentina" ...
## $ Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) : chr "16.2225675343538" "13.086784145579" "14.9021524183832" "5.92985376183283" ...
## $ Exports.of.goods.and.services.(%.of.GDP) : chr "38.6650817896799" "23.6195363708424" "40.8567793904075" "12.7492457826544" ...
## $ External.balance.on.goods.and.services.(%.of.GDP) : chr "-5.16352101892789" "3.55615854611284" "14.6718701718861" "-1.14202056813496" ...
## $ Final.consumption.expenditure.(%.of.GDP) : chr "82.2528072478475" "58.7188952438211" "61.5348797704301" "82.3366500981434" ...
## $ General.government.final.consumption.expenditure.(%.of.GDP) : chr "12.0464697906067" "17.9279465789317" "5.17486195152652" "16.3874689950096" ...
## $ Gross.capital.formation.(%.of.GDP) : chr "22.9107180604133" "37.724946210066" "23.7932500575225" "19.3715390134256" ...
## $ Gross.domestic.savings.(%.of.GDP) : chr "17.7471927521525" "41.2811047561789" "38.4651202295699" "17.6633499018566" ...
## $ Gross.fixed.capital.formation.(%.of.GDP) : chr "24.0498902560405" "32.8153081859397" "23.7932500575225" "18.5700907686492" ...
## $ Gross.national.expenditure.(%.of.GDP) : chr "105.163525308261" "96.4438414538872" "85.3281298279526" "101.708189111569" ...
## $ Gross.national.expenditure.deflator.(base.year.varies.by.country): chr "133.981548734979" "308.090901788823" "4069.14184740003" "25012.2668205438" ...
## $ Gross.savings.(%.of.GDP) : chr "21.9664584876914" "40.5777787869868" "28.3837613800852" "15.8917417806538" ...
## $ Gross.savings.(%.of.GNI) : chr "22.2505983429017" "41.1738760660909" "31.366558244779" "16.2269268248294" ...
## $ Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) : chr "70.2063374572408" "40.7909486648895" "56.3600178190649" "65.9491811031337" ...
## $ Imports.of.goods.and.services.(%.of.GDP) : chr "43.8286028086077" "20.0633778247296" "26.1849092185214" "13.8912663507893" ...
## $ Industry.(including.construction),.value.added.(%.of.GDP) : chr "23.0184724953671" "37.7570495314503" "45.2629187172157" "25.0563816101503" ...
## $ Manufacturing,.value.added.(%.of.GDP) : chr "6.87772585101551" "9.29539942964952" "7.99574282011019" "16.3174987404154" ...
## $ Services,.value.added.(%.of.GDP) : chr "47.9574813038329" "45.6157814802809" "39.7932678112576" "53.1486935707399" ...
## $ Trade.(%.of.GDP) : chr "82.4936845982876" "43.682914195572" "67.0416886089289" "26.6405121334437" ...
## - attr(*, "na.action")= 'omit' Named int [1:163] 1 4 5 7 10 13 17 21 22 23 ...
## ..- attr(*, "names")= chr [1:163] "1" "4" "5" "7" ...
We can see that variables are of “Character” data type.
# Convert all columns except "Country.Name" to numeric
numeric_data <- wdi %>%
mutate(across(-Country.Name, ~ as.numeric(gsub(",", "", as.character(.)))))
# Recheck the structure of the data
str(numeric_data)
## 'data.frame': 103 obs. of 19 variables:
## $ Country.Name : chr "Albania" "Algeria" "Angola" "Argentina" ...
## $ Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) : num 16.22 13.09 14.9 5.93 8.48 ...
## $ Exports.of.goods.and.services.(%.of.GDP) : num 38.7 23.6 40.9 12.7 59.5 ...
## $ External.balance.on.goods.and.services.(%.of.GDP) : num -5.16 3.56 14.67 -1.14 -0.81 ...
## $ Final.consumption.expenditure.(%.of.GDP) : num 82.3 58.7 61.5 82.3 79.5 ...
## $ General.government.final.consumption.expenditure.(%.of.GDP) : num 12.05 17.93 5.17 16.39 14.15 ...
## $ Gross.capital.formation.(%.of.GDP) : num 22.9 37.7 23.8 19.4 21.3 ...
## $ Gross.domestic.savings.(%.of.GDP) : num 17.7 41.3 38.5 17.7 20.5 ...
## $ Gross.fixed.capital.formation.(%.of.GDP) : num 24 32.8 23.8 18.6 20.9 ...
## $ Gross.national.expenditure.(%.of.GDP) : num 105.2 96.4 85.3 101.7 100.8 ...
## $ Gross.national.expenditure.deflator.(base.year.varies.by.country): num 134 308 4069 25012 140 ...
## $ Gross.savings.(%.of.GDP) : num 22 40.6 28.4 15.9 19 ...
## $ Gross.savings.(%.of.GNI) : num 22.3 41.2 31.4 16.2 19.5 ...
## $ Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) : num 70.2 40.8 56.4 65.9 65.4 ...
## $ Imports.of.goods.and.services.(%.of.GDP) : num 43.8 20.1 26.2 13.9 60.3 ...
## $ Industry.(including.construction),.value.added.(%.of.GDP) : num 23 37.8 45.3 25.1 23.4 ...
## $ Manufacturing,.value.added.(%.of.GDP) : num 6.88 9.3 8 16.32 10.56 ...
## $ Services,.value.added.(%.of.GDP) : num 48 45.6 39.8 53.1 59.4 ...
## $ Trade.(%.of.GDP) : num 82.5 43.7 67 26.6 119.7 ...
## - attr(*, "na.action")= 'omit' Named int [1:163] 1 4 5 7 10 13 17 21 22 23 ...
## ..- attr(*, "names")= chr [1:163] "1" "4" "5" "7" ...
Based on above result correlation matrix can be now calculated.
# Select only numeric columns (excluding "Country.Name")
numeric_columns <- numeric_data %>% select(-Country.Name)
# Calculate correlation matrix
correlation_matrix <- cor(numeric_columns, use = "complete.obs")
# View the correlation matrix
head(correlation_matrix)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 1.00000000
## Exports.of.goods.and.services.(%.of.GDP) -0.49379310
## External.balance.on.goods.and.services.(%.of.GDP) -0.40994284
## Final.consumption.expenditure.(%.of.GDP) 0.31581494
## General.government.final.consumption.expenditure.(%.of.GDP) -0.42316056
## Gross.capital.formation.(%.of.GDP) 0.07790321
## Exports.of.goods.and.services.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.4937931
## Exports.of.goods.and.services.(%.of.GDP) 1.0000000
## External.balance.on.goods.and.services.(%.of.GDP) 0.5131565
## Final.consumption.expenditure.(%.of.GDP) -0.4243638
## General.government.final.consumption.expenditure.(%.of.GDP) 0.1447155
## Gross.capital.formation.(%.of.GDP) -0.0510922
## External.balance.on.goods.and.services.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.4099428
## Exports.of.goods.and.services.(%.of.GDP) 0.5131565
## External.balance.on.goods.and.services.(%.of.GDP) 1.0000000
## Final.consumption.expenditure.(%.of.GDP) -0.8866930
## General.government.final.consumption.expenditure.(%.of.GDP) -0.2108651
## Gross.capital.formation.(%.of.GDP) -0.0404394
## Final.consumption.expenditure.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.3158149
## Exports.of.goods.and.services.(%.of.GDP) -0.4243638
## External.balance.on.goods.and.services.(%.of.GDP) -0.8866930
## Final.consumption.expenditure.(%.of.GDP) 1.0000000
## General.government.final.consumption.expenditure.(%.of.GDP) 0.2447532
## Gross.capital.formation.(%.of.GDP) -0.4103576
## General.government.final.consumption.expenditure.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.42316056
## Exports.of.goods.and.services.(%.of.GDP) 0.14471552
## External.balance.on.goods.and.services.(%.of.GDP) -0.21086510
## Final.consumption.expenditure.(%.of.GDP) 0.24475315
## General.government.final.consumption.expenditure.(%.of.GDP) 1.00000000
## Gross.capital.formation.(%.of.GDP) -0.09974415
## Gross.capital.formation.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.07790321
## Exports.of.goods.and.services.(%.of.GDP) -0.05109220
## External.balance.on.goods.and.services.(%.of.GDP) -0.04043940
## Final.consumption.expenditure.(%.of.GDP) -0.41035762
## General.government.final.consumption.expenditure.(%.of.GDP) -0.09974415
## Gross.capital.formation.(%.of.GDP) 1.00000000
## Gross.domestic.savings.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.3158149
## Exports.of.goods.and.services.(%.of.GDP) 0.4243638
## External.balance.on.goods.and.services.(%.of.GDP) 0.8866930
## Final.consumption.expenditure.(%.of.GDP) -1.0000000
## General.government.final.consumption.expenditure.(%.of.GDP) -0.2447532
## Gross.capital.formation.(%.of.GDP) 0.4103576
## Gross.fixed.capital.formation.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.046996893
## Exports.of.goods.and.services.(%.of.GDP) -0.018268948
## External.balance.on.goods.and.services.(%.of.GDP) -0.008808552
## Final.consumption.expenditure.(%.of.GDP) -0.390882553
## General.government.final.consumption.expenditure.(%.of.GDP) -0.086609499
## Gross.capital.formation.(%.of.GDP) 0.899295909
## Gross.national.expenditure.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.38469199
## Exports.of.goods.and.services.(%.of.GDP) -0.49023928
## External.balance.on.goods.and.services.(%.of.GDP) -0.99132566
## Final.consumption.expenditure.(%.of.GDP) 0.89102675
## General.government.final.consumption.expenditure.(%.of.GDP) 0.21842617
## Gross.capital.formation.(%.of.GDP) 0.04832933
## Gross.national.expenditure.deflator.(base.year.varies.by.country)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.04535453
## Exports.of.goods.and.services.(%.of.GDP) -0.11965039
## External.balance.on.goods.and.services.(%.of.GDP) -0.01948175
## Final.consumption.expenditure.(%.of.GDP) 0.08168604
## General.government.final.consumption.expenditure.(%.of.GDP) -0.03083415
## Gross.capital.formation.(%.of.GDP) -0.13792877
## Gross.savings.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.08113728
## Exports.of.goods.and.services.(%.of.GDP) 0.08527140
## External.balance.on.goods.and.services.(%.of.GDP) 0.37741085
## Final.consumption.expenditure.(%.of.GDP) -0.67516921
## General.government.final.consumption.expenditure.(%.of.GDP) -0.23093095
## Gross.capital.formation.(%.of.GDP) 0.69735727
## Gross.savings.(%.of.GNI)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.09508484
## Exports.of.goods.and.services.(%.of.GDP) 0.16063551
## External.balance.on.goods.and.services.(%.of.GDP) 0.45927582
## Final.consumption.expenditure.(%.of.GDP) -0.74480500
## General.government.final.consumption.expenditure.(%.of.GDP) -0.26409116
## Gross.capital.formation.(%.of.GDP) 0.69076241
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.5293935
## Exports.of.goods.and.services.(%.of.GDP) -0.4946055
## External.balance.on.goods.and.services.(%.of.GDP) -0.7801651
## Final.consumption.expenditure.(%.of.GDP) 0.8733558
## General.government.final.consumption.expenditure.(%.of.GDP) -0.2557972
## Gross.capital.formation.(%.of.GDP) -0.3537929
## Imports.of.goods.and.services.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.38319950
## Exports.of.goods.and.services.(%.of.GDP) 0.92042731
## External.balance.on.goods.and.services.(%.of.GDP) 0.13680394
## Final.consumption.expenditure.(%.of.GDP) -0.08593029
## General.government.final.consumption.expenditure.(%.of.GDP) 0.26306222
## Gross.capital.formation.(%.of.GDP) -0.04054959
## Industry.(including.construction),.value.added.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.09569294
## Exports.of.goods.and.services.(%.of.GDP) -0.14906210
## External.balance.on.goods.and.services.(%.of.GDP) 0.25275537
## Final.consumption.expenditure.(%.of.GDP) -0.40365065
## General.government.final.consumption.expenditure.(%.of.GDP) -0.16905830
## Gross.capital.formation.(%.of.GDP) 0.35008062
## Manufacturing,.value.added.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.109604816
## Exports.of.goods.and.services.(%.of.GDP) -0.008524538
## External.balance.on.goods.and.services.(%.of.GDP) 0.231277241
## Final.consumption.expenditure.(%.of.GDP) -0.236826490
## General.government.final.consumption.expenditure.(%.of.GDP) -0.209129487
## Gross.capital.formation.(%.of.GDP) 0.074081037
## Services,.value.added.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.68359926
## Exports.of.goods.and.services.(%.of.GDP) 0.44838807
## External.balance.on.goods.and.services.(%.of.GDP) 0.14885155
## Final.consumption.expenditure.(%.of.GDP) 0.03918809
## General.government.final.consumption.expenditure.(%.of.GDP) 0.35871302
## Gross.capital.formation.(%.of.GDP) -0.33534362
## Trade.(%.of.GDP)
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.45147880
## Exports.of.goods.and.services.(%.of.GDP) 0.98270609
## External.balance.on.goods.and.services.(%.of.GDP) 0.34534969
## Final.consumption.expenditure.(%.of.GDP) -0.27270761
## General.government.final.consumption.expenditure.(%.of.GDP) 0.20372728
## Gross.capital.formation.(%.of.GDP) -0.04714049
For ease of viewing below is the screenshot of correlation matrix.
knitr::include_graphics("/Users/ashutoshverma/Desktop/Correlation Matrix.png")
Based on above result we can see for the majority correlation value is
less that 0.6(or 60%). Hence we can proceed ahead with this dataset for
performing dimension reduction.
Principal Component Analysis (PCA) Technique
PCA is a linear dimension reduction technique that transforms high-dimensional data into a lower-dimensional space by identifying directions (called principal components) that maximize variance in the data.
Steps of PCA
Standardize the Data: Ensure all features have mean 0 and standard deviation 1. This is important because PCA is sensitive to the scale of the features.
Compute the Covariance Matrix: Measure how the variables are related to each other. This matrix is 𝑛×𝑛where 𝑛is the number of features.
Calculate Eigenvectors and Eigenvalues: The eigenvectors represent the directions of maximum variance (principal components), and eigenvalues indicate the magnitude of variance in those directions.
Choose the Top 𝑘Principal Components: Select the top components based on their eigenvalues. These components explain the most variance in the dataset.
Project the Data: Transform the original dataset into the new space defined by the selected principal components.
Note : In R we have inbuilt function prcomp to perform PCA.
# Perform PCA
pca_result <- prcomp(numeric_columns, center = TRUE, scale. = TRUE)
pca_result
## Standard deviations (1, .., p=18):
## [1] 2.584215e+00 2.083590e+00 1.440654e+00 1.143879e+00 1.076671e+00
## [6] 9.537928e-01 8.350575e-01 6.287249e-01 5.018562e-01 3.118655e-01
## [11] 2.539715e-01 1.063182e-01 9.211591e-02 3.973715e-02 1.244755e-14
## [16] 3.659873e-15 2.533730e-15 1.484538e-15
##
## Rotation (n x k) = (18 x 18):
## PC1
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.15170942
## Exports.of.goods.and.services.(%.of.GDP) 0.19968010
## External.balance.on.goods.and.services.(%.of.GDP) 0.31819862
## Final.consumption.expenditure.(%.of.GDP) -0.37374754
## General.government.final.consumption.expenditure.(%.of.GDP) -0.05830388
## Gross.capital.formation.(%.of.GDP) 0.18403698
## Gross.domestic.savings.(%.of.GDP) 0.37374754
## Gross.fixed.capital.formation.(%.of.GDP) 0.18210620
## Gross.national.expenditure.(%.of.GDP) -0.31775329
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.04568053
## Gross.savings.(%.of.GDP) 0.29542727
## Gross.savings.(%.of.GNI) 0.31833198
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.34285388
## Imports.of.goods.and.services.(%.of.GDP) 0.08553529
## Industry.(including.construction),.value.added.(%.of.GDP) 0.17882365
## Manufacturing,.value.added.(%.of.GDP) 0.12239145
## Services,.value.added.(%.of.GDP) -0.01270183
## Trade.(%.of.GDP) 0.14968404
## PC2
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.29069917
## Exports.of.goods.and.services.(%.of.GDP) 0.35954729
## External.balance.on.goods.and.services.(%.of.GDP) 0.11511903
## Final.consumption.expenditure.(%.of.GDP) 0.01414393
## General.government.final.consumption.expenditure.(%.of.GDP) 0.20647757
## Gross.capital.formation.(%.of.GDP) -0.24005974
## Gross.domestic.savings.(%.of.GDP) -0.01414393
## Gross.fixed.capital.formation.(%.of.GDP) -0.22092967
## Gross.national.expenditure.(%.of.GDP) -0.10400849
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.01133551
## Gross.savings.(%.of.GDP) -0.21266056
## Gross.savings.(%.of.GNI) -0.19064108
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.09088670
## Imports.of.goods.and.services.(%.of.GDP) 0.36253882
## Industry.(including.construction),.value.added.(%.of.GDP) -0.28515336
## Manufacturing,.value.added.(%.of.GDP) -0.13773793
## Services,.value.added.(%.of.GDP) 0.39415473
## Trade.(%.of.GDP) 0.36829873
## PC3
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -5.694624e-03
## Exports.of.goods.and.services.(%.of.GDP) -1.284733e-01
## External.balance.on.goods.and.services.(%.of.GDP) 3.344832e-01
## Final.consumption.expenditure.(%.of.GDP) -1.110799e-01
## General.government.final.consumption.expenditure.(%.of.GDP) -2.287461e-01
## Gross.capital.formation.(%.of.GDP) -4.480988e-01
## Gross.domestic.savings.(%.of.GDP) 1.110799e-01
## Gross.fixed.capital.formation.(%.of.GDP) -4.438990e-01
## Gross.national.expenditure.(%.of.GDP) -3.447268e-01
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 2.343665e-01
## Gross.savings.(%.of.GDP) -1.659715e-01
## Gross.savings.(%.of.GNI) -1.415761e-01
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -9.295668e-05
## Imports.of.goods.and.services.(%.of.GDP) -3.006186e-01
## Industry.(including.construction),.value.added.(%.of.GDP) 9.058866e-02
## Manufacturing,.value.added.(%.of.GDP) 1.767965e-01
## Services,.value.added.(%.of.GDP) -1.838151e-02
## Trade.(%.of.GDP) -2.126376e-01
## PC4
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.434492511
## Exports.of.goods.and.services.(%.of.GDP) -0.296377489
## External.balance.on.goods.and.services.(%.of.GDP) -0.030904696
## Final.consumption.expenditure.(%.of.GDP) -0.012058458
## General.government.final.consumption.expenditure.(%.of.GDP) 0.541268691
## Gross.capital.formation.(%.of.GDP) 0.090039662
## Gross.domestic.savings.(%.of.GDP) 0.012058458
## Gross.fixed.capital.formation.(%.of.GDP) 0.070004616
## Gross.national.expenditure.(%.of.GDP) 0.031613586
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.178675016
## Gross.savings.(%.of.GDP) 0.047303279
## Gross.savings.(%.of.GNI) 0.002338038
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.285127234
## Imports.of.goods.and.services.(%.of.GDP) -0.327987355
## Industry.(including.construction),.value.added.(%.of.GDP) -0.034404901
## Manufacturing,.value.added.(%.of.GDP) -0.103336874
## Services,.value.added.(%.of.GDP) 0.281971393
## Trade.(%.of.GDP) -0.317396569
## PC5
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.209574214
## Exports.of.goods.and.services.(%.of.GDP) -0.117667439
## External.balance.on.goods.and.services.(%.of.GDP) 0.119817985
## Final.consumption.expenditure.(%.of.GDP) -0.152362628
## General.government.final.consumption.expenditure.(%.of.GDP) -0.258351132
## Gross.capital.formation.(%.of.GDP) 0.071452257
## Gross.domestic.savings.(%.of.GDP) 0.152362628
## Gross.fixed.capital.formation.(%.of.GDP) 0.044632215
## Gross.national.expenditure.(%.of.GDP) -0.131314327
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.322038460
## Gross.savings.(%.of.GDP) -0.006648352
## Gross.savings.(%.of.GNI) 0.004975932
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.022952503
## Imports.of.goods.and.services.(%.of.GDP) -0.190377014
## Industry.(including.construction),.value.added.(%.of.GDP) -0.430693922
## Manufacturing,.value.added.(%.of.GDP) -0.640015066
## Services,.value.added.(%.of.GDP) 0.175567684
## Trade.(%.of.GDP) -0.154509572
## PC6
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.004282157
## Exports.of.goods.and.services.(%.of.GDP) 0.037435766
## External.balance.on.goods.and.services.(%.of.GDP) -0.050619474
## Final.consumption.expenditure.(%.of.GDP) -0.023882365
## General.government.final.consumption.expenditure.(%.of.GDP) -0.302160589
## Gross.capital.formation.(%.of.GDP) 0.171145646
## Gross.domestic.savings.(%.of.GDP) 0.023882365
## Gross.fixed.capital.formation.(%.of.GDP) 0.085997121
## Gross.national.expenditure.(%.of.GDP) 0.059036944
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.844465045
## Gross.savings.(%.of.GDP) 0.117683297
## Gross.savings.(%.of.GNI) 0.122801487
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.128617991
## Imports.of.goods.and.services.(%.of.GDP) 0.066261188
## Industry.(including.construction),.value.added.(%.of.GDP) -0.237701642
## Manufacturing,.value.added.(%.of.GDP) -0.130909934
## Services,.value.added.(%.of.GDP) 0.155216756
## Trade.(%.of.GDP) 0.051853747
## PC7
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.35358493
## Exports.of.goods.and.services.(%.of.GDP) 0.08916646
## External.balance.on.goods.and.services.(%.of.GDP) 0.03738434
## Final.consumption.expenditure.(%.of.GDP) -0.04673493
## General.government.final.consumption.expenditure.(%.of.GDP) 0.39360780
## Gross.capital.formation.(%.of.GDP) -0.02412002
## Gross.domestic.savings.(%.of.GDP) 0.04673493
## Gross.fixed.capital.formation.(%.of.GDP) -0.11744485
## Gross.national.expenditure.(%.of.GDP) -0.06319560
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.28704504
## Gross.savings.(%.of.GDP) -0.11110998
## Gross.savings.(%.of.GNI) -0.09035377
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.23376908
## Imports.of.goods.and.services.(%.of.GDP) 0.08588431
## Industry.(including.construction),.value.added.(%.of.GDP) 0.27168646
## Manufacturing,.value.added.(%.of.GDP) -0.51035699
## Services,.value.added.(%.of.GDP) -0.42516054
## Trade.(%.of.GDP) 0.08943064
## PC8
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.079728077
## Exports.of.goods.and.services.(%.of.GDP) 0.004055053
## External.balance.on.goods.and.services.(%.of.GDP) 0.093392733
## Final.consumption.expenditure.(%.of.GDP) -0.150266644
## General.government.final.consumption.expenditure.(%.of.GDP) -0.034146225
## Gross.capital.formation.(%.of.GDP) 0.242603314
## Gross.domestic.savings.(%.of.GDP) 0.150266644
## Gross.fixed.capital.formation.(%.of.GDP) 0.465027071
## Gross.national.expenditure.(%.of.GDP) -0.043820593
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.079606229
## Gross.savings.(%.of.GDP) -0.564626712
## Gross.savings.(%.of.GNI) -0.482785347
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.134313199
## Imports.of.goods.and.services.(%.of.GDP) -0.037855953
## Industry.(including.construction),.value.added.(%.of.GDP) -0.131409757
## Manufacturing,.value.added.(%.of.GDP) 0.247095413
## Services,.value.added.(%.of.GDP) -0.072697996
## Trade.(%.of.GDP) -0.015715078
## PC9
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.554986161
## Exports.of.goods.and.services.(%.of.GDP) -0.008114635
## External.balance.on.goods.and.services.(%.of.GDP) 0.017187503
## Final.consumption.expenditure.(%.of.GDP) -0.001475826
## General.government.final.consumption.expenditure.(%.of.GDP) 0.347734659
## Gross.capital.formation.(%.of.GDP) -0.080412410
## Gross.domestic.savings.(%.of.GDP) 0.001475826
## Gross.fixed.capital.formation.(%.of.GDP) -0.083214431
## Gross.national.expenditure.(%.of.GDP) -0.041645303
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.043773819
## Gross.savings.(%.of.GDP) 0.167092788
## Gross.savings.(%.of.GNI) 0.171642080
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.190060840
## Imports.of.goods.and.services.(%.of.GDP) -0.017193591
## Industry.(including.construction),.value.added.(%.of.GDP) -0.541903948
## Manufacturing,.value.added.(%.of.GDP) 0.406295404
## Services,.value.added.(%.of.GDP) 0.031148224
## Trade.(%.of.GDP) -0.012580781
## PC10
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.018836114
## Exports.of.goods.and.services.(%.of.GDP) -0.032270393
## External.balance.on.goods.and.services.(%.of.GDP) -0.149236584
## Final.consumption.expenditure.(%.of.GDP) -0.143876937
## General.government.final.consumption.expenditure.(%.of.GDP) -0.072759775
## Gross.capital.formation.(%.of.GDP) 0.621645593
## Gross.domestic.savings.(%.of.GDP) 0.143876937
## Gross.fixed.capital.formation.(%.of.GDP) -0.681750774
## Gross.national.expenditure.(%.of.GDP) 0.151863099
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.056821505
## Gross.savings.(%.of.GDP) -0.158892153
## Gross.savings.(%.of.GNI) -0.034050103
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.119850298
## Imports.of.goods.and.services.(%.of.GDP) 0.030725616
## Industry.(including.construction),.value.added.(%.of.GDP) -0.016254384
## Manufacturing,.value.added.(%.of.GDP) 0.100101387
## Services,.value.added.(%.of.GDP) 0.010505973
## Trade.(%.of.GDP) -0.003088057
## PC11
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.4675004664
## Exports.of.goods.and.services.(%.of.GDP) 0.0029012187
## External.balance.on.goods.and.services.(%.of.GDP) 0.0066112541
## Final.consumption.expenditure.(%.of.GDP) 0.0021484594
## General.government.final.consumption.expenditure.(%.of.GDP) -0.0073009728
## Gross.capital.formation.(%.of.GDP) -0.0401610563
## Gross.domestic.savings.(%.of.GDP) -0.0021484594
## Gross.fixed.capital.formation.(%.of.GDP) -0.0471900441
## Gross.national.expenditure.(%.of.GDP) -0.0176387321
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.0142335621
## Gross.savings.(%.of.GDP) 0.0612057018
## Gross.savings.(%.of.GNI) 0.0200073557
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.0170812497
## Imports.of.goods.and.services.(%.of.GDP) 0.0003373102
## Industry.(including.construction),.value.added.(%.of.GDP) -0.5002545613
## Manufacturing,.value.added.(%.of.GDP) -0.0106456898
## Services,.value.added.(%.of.GDP) -0.7226104083
## Trade.(%.of.GDP) 0.0017459011
## PC12
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.014501795
## Exports.of.goods.and.services.(%.of.GDP) 0.165017940
## External.balance.on.goods.and.services.(%.of.GDP) 0.793444662
## Final.consumption.expenditure.(%.of.GDP) 0.203008138
## General.government.final.consumption.expenditure.(%.of.GDP) 0.105620729
## Gross.capital.formation.(%.of.GDP) 0.236103525
## Gross.domestic.savings.(%.of.GDP) -0.203008138
## Gross.fixed.capital.formation.(%.of.GDP) -0.021604791
## Gross.national.expenditure.(%.of.GDP) 0.339885854
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.004055379
## Gross.savings.(%.of.GDP) -0.056219160
## Gross.savings.(%.of.GNI) 0.114521100
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.177731165
## Imports.of.goods.and.services.(%.of.GDP) -0.170922549
## Industry.(including.construction),.value.added.(%.of.GDP) -0.005096417
## Manufacturing,.value.added.(%.of.GDP) -0.016139892
## Services,.value.added.(%.of.GDP) -0.014929268
## Trade.(%.of.GDP) 0.009252275
## PC13
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.034416934
## Exports.of.goods.and.services.(%.of.GDP) 0.034015062
## External.balance.on.goods.and.services.(%.of.GDP) 0.103799309
## Final.consumption.expenditure.(%.of.GDP) -0.015211294
## General.government.final.consumption.expenditure.(%.of.GDP) 0.001923498
## Gross.capital.formation.(%.of.GDP) 0.092798034
## Gross.domestic.savings.(%.of.GDP) 0.015211294
## Gross.fixed.capital.formation.(%.of.GDP) -0.047072574
## Gross.national.expenditure.(%.of.GDP) 0.029533386
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.001689043
## Gross.savings.(%.of.GDP) 0.657357080
## Gross.savings.(%.of.GNI) -0.735706815
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.026235233
## Imports.of.goods.and.services.(%.of.GDP) -0.008017432
## Industry.(including.construction),.value.added.(%.of.GDP) 0.003793276
## Manufacturing,.value.added.(%.of.GDP) 0.016312757
## Services,.value.added.(%.of.GDP) 0.008966879
## Trade.(%.of.GDP) 0.014798535
## PC14
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.005250478
## Exports.of.goods.and.services.(%.of.GDP) -0.006585050
## External.balance.on.goods.and.services.(%.of.GDP) -0.021783849
## Final.consumption.expenditure.(%.of.GDP) -0.273134066
## General.government.final.consumption.expenditure.(%.of.GDP) 0.396365470
## Gross.capital.formation.(%.of.GDP) 0.113015438
## Gross.domestic.savings.(%.of.GDP) 0.273134066
## Gross.fixed.capital.formation.(%.of.GDP) -0.005587409
## Gross.national.expenditure.(%.of.GDP) -0.242905420
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.001913087
## Gross.savings.(%.of.GDP) -0.021908965
## Gross.savings.(%.of.GNI) 0.022818807
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.787451721
## Imports.of.goods.and.services.(%.of.GDP) 0.002321425
## Industry.(including.construction),.value.added.(%.of.GDP) -0.004381411
## Manufacturing,.value.added.(%.of.GDP) 0.009989815
## Services,.value.added.(%.of.GDP) 0.011070352
## Trade.(%.of.GDP) -0.002500464
## PC15
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 2.444510e-15
## Exports.of.goods.and.services.(%.of.GDP) -1.293202e-02
## External.balance.on.goods.and.services.(%.of.GDP) 4.403631e-03
## Final.consumption.expenditure.(%.of.GDP) -4.136468e-01
## General.government.final.consumption.expenditure.(%.of.GDP) 2.332675e-14
## Gross.capital.formation.(%.of.GDP) -3.661278e-01
## Gross.domestic.savings.(%.of.GDP) 3.919471e-01
## Gross.fixed.capital.formation.(%.of.GDP) -3.405224e-15
## Gross.national.expenditure.(%.of.GDP) 7.355004e-01
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 8.134514e-16
## Gross.savings.(%.of.GDP) -4.048843e-15
## Gross.savings.(%.of.GNI) 5.580629e-15
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 4.403590e-14
## Imports.of.goods.and.services.(%.of.GDP) 8.132502e-03
## Industry.(including.construction),.value.added.(%.of.GDP) -1.163570e-15
## Manufacturing,.value.added.(%.of.GDP) 6.932779e-16
## Services,.value.added.(%.of.GDP) 2.177004e-16
## Trade.(%.of.GDP) 3.242971e-03
## PC16
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 1.549641e-15
## Exports.of.goods.and.services.(%.of.GDP) -1.626624e-02
## External.balance.on.goods.and.services.(%.of.GDP) -6.304585e-04
## Final.consumption.expenditure.(%.of.GDP) -7.002008e-01
## General.government.final.consumption.expenditure.(%.of.GDP) 5.878052e-15
## Gross.capital.formation.(%.of.GDP) 5.680079e-03
## Gross.domestic.savings.(%.of.GDP) -7.126987e-01
## Gross.fixed.capital.formation.(%.of.GDP) 6.728359e-16
## Gross.national.expenditure.(%.of.GDP) -1.141050e-02
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -1.138143e-16
## Gross.savings.(%.of.GDP) -4.032211e-15
## Gross.savings.(%.of.GNI) 4.680198e-15
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 7.377832e-15
## Imports.of.goods.and.services.(%.of.GDP) -1.686223e-02
## Industry.(including.construction),.value.added.(%.of.GDP) 3.684712e-16
## Manufacturing,.value.added.(%.of.GDP) 8.582098e-17
## Services,.value.added.(%.of.GDP) 5.903164e-16
## Trade.(%.of.GDP) 3.267531e-02
## PC17
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -3.891789e-16
## Exports.of.goods.and.services.(%.of.GDP) -2.200697e-01
## External.balance.on.goods.and.services.(%.of.GDP) -8.422694e-02
## Final.consumption.expenditure.(%.of.GDP) 2.755279e-02
## General.government.final.consumption.expenditure.(%.of.GDP) -4.698911e-15
## Gross.capital.formation.(%.of.GDP) -4.062772e-05
## Gross.domestic.savings.(%.of.GDP) 2.764218e-02
## Gross.fixed.capital.formation.(%.of.GDP) -8.505532e-16
## Gross.national.expenditure.(%.of.GDP) 8.161549e-05
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -1.692855e-16
## Gross.savings.(%.of.GDP) -1.512876e-15
## Gross.savings.(%.of.GNI) 2.292063e-15
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -9.691217e-15
## Imports.of.goods.and.services.(%.of.GDP) -5.605369e-01
## Industry.(including.construction),.value.added.(%.of.GDP) -1.137825e-15
## Manufacturing,.value.added.(%.of.GDP) 3.223657e-17
## Services,.value.added.(%.of.GDP) -1.375594e-15
## Trade.(%.of.GDP) 7.929378e-01
## PC18
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -7.807942e-16
## Exports.of.goods.and.services.(%.of.GDP) -7.904967e-01
## External.balance.on.goods.and.services.(%.of.GDP) 2.740378e-01
## Final.consumption.expenditure.(%.of.GDP) 1.350466e-02
## General.government.final.consumption.expenditure.(%.of.GDP) -2.053819e-15
## Gross.capital.formation.(%.of.GDP) 5.884046e-03
## Gross.domestic.savings.(%.of.GDP) 5.579489e-04
## Gross.fixed.capital.formation.(%.of.GDP) -4.009069e-17
## Gross.national.expenditure.(%.of.GDP) -1.182024e-02
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -7.358132e-17
## Gross.savings.(%.of.GDP) 6.644472e-15
## Gross.savings.(%.of.GNI) -7.512073e-15
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -2.267380e-15
## Imports.of.goods.and.services.(%.of.GDP) 5.184427e-01
## Industry.(including.construction),.value.added.(%.of.GDP) 4.515171e-16
## Manufacturing,.value.added.(%.of.GDP) -4.552111e-16
## Services,.value.added.(%.of.GDP) -3.178864e-16
## Trade.(%.of.GDP) 1.757224e-01
# View PCA summary
summary(pca_result)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 2.584 2.0836 1.4407 1.14388 1.0767 0.95379 0.83506
## Proportion of Variance 0.371 0.2412 0.1153 0.07269 0.0644 0.05054 0.03874
## Cumulative Proportion 0.371 0.6122 0.7275 0.80019 0.8646 0.91513 0.95387
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 0.62872 0.50186 0.3119 0.25397 0.10632 0.09212 0.03974
## Proportion of Variance 0.02196 0.01399 0.0054 0.00358 0.00063 0.00047 0.00009
## Cumulative Proportion 0.97583 0.98983 0.9952 0.99881 0.99944 0.99991 1.00000
## PC15 PC16 PC17 PC18
## Standard deviation 1.245e-14 3.66e-15 2.534e-15 1.485e-15
## Proportion of Variance 0.000e+00 0.00e+00 0.000e+00 0.000e+00
## Cumulative Proportion 1.000e+00 1.00e+00 1.000e+00 1.000e+00
# Get PCA loadings (contributions of variables to each principal component)
pca_result$rotation
## PC1
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.15170942
## Exports.of.goods.and.services.(%.of.GDP) 0.19968010
## External.balance.on.goods.and.services.(%.of.GDP) 0.31819862
## Final.consumption.expenditure.(%.of.GDP) -0.37374754
## General.government.final.consumption.expenditure.(%.of.GDP) -0.05830388
## Gross.capital.formation.(%.of.GDP) 0.18403698
## Gross.domestic.savings.(%.of.GDP) 0.37374754
## Gross.fixed.capital.formation.(%.of.GDP) 0.18210620
## Gross.national.expenditure.(%.of.GDP) -0.31775329
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.04568053
## Gross.savings.(%.of.GDP) 0.29542727
## Gross.savings.(%.of.GNI) 0.31833198
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.34285388
## Imports.of.goods.and.services.(%.of.GDP) 0.08553529
## Industry.(including.construction),.value.added.(%.of.GDP) 0.17882365
## Manufacturing,.value.added.(%.of.GDP) 0.12239145
## Services,.value.added.(%.of.GDP) -0.01270183
## Trade.(%.of.GDP) 0.14968404
## PC2
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.29069917
## Exports.of.goods.and.services.(%.of.GDP) 0.35954729
## External.balance.on.goods.and.services.(%.of.GDP) 0.11511903
## Final.consumption.expenditure.(%.of.GDP) 0.01414393
## General.government.final.consumption.expenditure.(%.of.GDP) 0.20647757
## Gross.capital.formation.(%.of.GDP) -0.24005974
## Gross.domestic.savings.(%.of.GDP) -0.01414393
## Gross.fixed.capital.formation.(%.of.GDP) -0.22092967
## Gross.national.expenditure.(%.of.GDP) -0.10400849
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.01133551
## Gross.savings.(%.of.GDP) -0.21266056
## Gross.savings.(%.of.GNI) -0.19064108
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.09088670
## Imports.of.goods.and.services.(%.of.GDP) 0.36253882
## Industry.(including.construction),.value.added.(%.of.GDP) -0.28515336
## Manufacturing,.value.added.(%.of.GDP) -0.13773793
## Services,.value.added.(%.of.GDP) 0.39415473
## Trade.(%.of.GDP) 0.36829873
## PC3
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -5.694624e-03
## Exports.of.goods.and.services.(%.of.GDP) -1.284733e-01
## External.balance.on.goods.and.services.(%.of.GDP) 3.344832e-01
## Final.consumption.expenditure.(%.of.GDP) -1.110799e-01
## General.government.final.consumption.expenditure.(%.of.GDP) -2.287461e-01
## Gross.capital.formation.(%.of.GDP) -4.480988e-01
## Gross.domestic.savings.(%.of.GDP) 1.110799e-01
## Gross.fixed.capital.formation.(%.of.GDP) -4.438990e-01
## Gross.national.expenditure.(%.of.GDP) -3.447268e-01
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 2.343665e-01
## Gross.savings.(%.of.GDP) -1.659715e-01
## Gross.savings.(%.of.GNI) -1.415761e-01
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -9.295668e-05
## Imports.of.goods.and.services.(%.of.GDP) -3.006186e-01
## Industry.(including.construction),.value.added.(%.of.GDP) 9.058866e-02
## Manufacturing,.value.added.(%.of.GDP) 1.767965e-01
## Services,.value.added.(%.of.GDP) -1.838151e-02
## Trade.(%.of.GDP) -2.126376e-01
## PC4
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.434492511
## Exports.of.goods.and.services.(%.of.GDP) -0.296377489
## External.balance.on.goods.and.services.(%.of.GDP) -0.030904696
## Final.consumption.expenditure.(%.of.GDP) -0.012058458
## General.government.final.consumption.expenditure.(%.of.GDP) 0.541268691
## Gross.capital.formation.(%.of.GDP) 0.090039662
## Gross.domestic.savings.(%.of.GDP) 0.012058458
## Gross.fixed.capital.formation.(%.of.GDP) 0.070004616
## Gross.national.expenditure.(%.of.GDP) 0.031613586
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.178675016
## Gross.savings.(%.of.GDP) 0.047303279
## Gross.savings.(%.of.GNI) 0.002338038
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.285127234
## Imports.of.goods.and.services.(%.of.GDP) -0.327987355
## Industry.(including.construction),.value.added.(%.of.GDP) -0.034404901
## Manufacturing,.value.added.(%.of.GDP) -0.103336874
## Services,.value.added.(%.of.GDP) 0.281971393
## Trade.(%.of.GDP) -0.317396569
## PC5
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.209574214
## Exports.of.goods.and.services.(%.of.GDP) -0.117667439
## External.balance.on.goods.and.services.(%.of.GDP) 0.119817985
## Final.consumption.expenditure.(%.of.GDP) -0.152362628
## General.government.final.consumption.expenditure.(%.of.GDP) -0.258351132
## Gross.capital.formation.(%.of.GDP) 0.071452257
## Gross.domestic.savings.(%.of.GDP) 0.152362628
## Gross.fixed.capital.formation.(%.of.GDP) 0.044632215
## Gross.national.expenditure.(%.of.GDP) -0.131314327
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.322038460
## Gross.savings.(%.of.GDP) -0.006648352
## Gross.savings.(%.of.GNI) 0.004975932
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.022952503
## Imports.of.goods.and.services.(%.of.GDP) -0.190377014
## Industry.(including.construction),.value.added.(%.of.GDP) -0.430693922
## Manufacturing,.value.added.(%.of.GDP) -0.640015066
## Services,.value.added.(%.of.GDP) 0.175567684
## Trade.(%.of.GDP) -0.154509572
## PC6
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.004282157
## Exports.of.goods.and.services.(%.of.GDP) 0.037435766
## External.balance.on.goods.and.services.(%.of.GDP) -0.050619474
## Final.consumption.expenditure.(%.of.GDP) -0.023882365
## General.government.final.consumption.expenditure.(%.of.GDP) -0.302160589
## Gross.capital.formation.(%.of.GDP) 0.171145646
## Gross.domestic.savings.(%.of.GDP) 0.023882365
## Gross.fixed.capital.formation.(%.of.GDP) 0.085997121
## Gross.national.expenditure.(%.of.GDP) 0.059036944
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.844465045
## Gross.savings.(%.of.GDP) 0.117683297
## Gross.savings.(%.of.GNI) 0.122801487
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.128617991
## Imports.of.goods.and.services.(%.of.GDP) 0.066261188
## Industry.(including.construction),.value.added.(%.of.GDP) -0.237701642
## Manufacturing,.value.added.(%.of.GDP) -0.130909934
## Services,.value.added.(%.of.GDP) 0.155216756
## Trade.(%.of.GDP) 0.051853747
## PC7
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.35358493
## Exports.of.goods.and.services.(%.of.GDP) 0.08916646
## External.balance.on.goods.and.services.(%.of.GDP) 0.03738434
## Final.consumption.expenditure.(%.of.GDP) -0.04673493
## General.government.final.consumption.expenditure.(%.of.GDP) 0.39360780
## Gross.capital.formation.(%.of.GDP) -0.02412002
## Gross.domestic.savings.(%.of.GDP) 0.04673493
## Gross.fixed.capital.formation.(%.of.GDP) -0.11744485
## Gross.national.expenditure.(%.of.GDP) -0.06319560
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.28704504
## Gross.savings.(%.of.GDP) -0.11110998
## Gross.savings.(%.of.GNI) -0.09035377
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.23376908
## Imports.of.goods.and.services.(%.of.GDP) 0.08588431
## Industry.(including.construction),.value.added.(%.of.GDP) 0.27168646
## Manufacturing,.value.added.(%.of.GDP) -0.51035699
## Services,.value.added.(%.of.GDP) -0.42516054
## Trade.(%.of.GDP) 0.08943064
## PC8
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.079728077
## Exports.of.goods.and.services.(%.of.GDP) 0.004055053
## External.balance.on.goods.and.services.(%.of.GDP) 0.093392733
## Final.consumption.expenditure.(%.of.GDP) -0.150266644
## General.government.final.consumption.expenditure.(%.of.GDP) -0.034146225
## Gross.capital.formation.(%.of.GDP) 0.242603314
## Gross.domestic.savings.(%.of.GDP) 0.150266644
## Gross.fixed.capital.formation.(%.of.GDP) 0.465027071
## Gross.national.expenditure.(%.of.GDP) -0.043820593
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.079606229
## Gross.savings.(%.of.GDP) -0.564626712
## Gross.savings.(%.of.GNI) -0.482785347
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.134313199
## Imports.of.goods.and.services.(%.of.GDP) -0.037855953
## Industry.(including.construction),.value.added.(%.of.GDP) -0.131409757
## Manufacturing,.value.added.(%.of.GDP) 0.247095413
## Services,.value.added.(%.of.GDP) -0.072697996
## Trade.(%.of.GDP) -0.015715078
## PC9
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.554986161
## Exports.of.goods.and.services.(%.of.GDP) -0.008114635
## External.balance.on.goods.and.services.(%.of.GDP) 0.017187503
## Final.consumption.expenditure.(%.of.GDP) -0.001475826
## General.government.final.consumption.expenditure.(%.of.GDP) 0.347734659
## Gross.capital.formation.(%.of.GDP) -0.080412410
## Gross.domestic.savings.(%.of.GDP) 0.001475826
## Gross.fixed.capital.formation.(%.of.GDP) -0.083214431
## Gross.national.expenditure.(%.of.GDP) -0.041645303
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.043773819
## Gross.savings.(%.of.GDP) 0.167092788
## Gross.savings.(%.of.GNI) 0.171642080
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.190060840
## Imports.of.goods.and.services.(%.of.GDP) -0.017193591
## Industry.(including.construction),.value.added.(%.of.GDP) -0.541903948
## Manufacturing,.value.added.(%.of.GDP) 0.406295404
## Services,.value.added.(%.of.GDP) 0.031148224
## Trade.(%.of.GDP) -0.012580781
## PC10
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.018836114
## Exports.of.goods.and.services.(%.of.GDP) -0.032270393
## External.balance.on.goods.and.services.(%.of.GDP) -0.149236584
## Final.consumption.expenditure.(%.of.GDP) -0.143876937
## General.government.final.consumption.expenditure.(%.of.GDP) -0.072759775
## Gross.capital.formation.(%.of.GDP) 0.621645593
## Gross.domestic.savings.(%.of.GDP) 0.143876937
## Gross.fixed.capital.formation.(%.of.GDP) -0.681750774
## Gross.national.expenditure.(%.of.GDP) 0.151863099
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.056821505
## Gross.savings.(%.of.GDP) -0.158892153
## Gross.savings.(%.of.GNI) -0.034050103
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -0.119850298
## Imports.of.goods.and.services.(%.of.GDP) 0.030725616
## Industry.(including.construction),.value.added.(%.of.GDP) -0.016254384
## Manufacturing,.value.added.(%.of.GDP) 0.100101387
## Services,.value.added.(%.of.GDP) 0.010505973
## Trade.(%.of.GDP) -0.003088057
## PC11
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -0.4675004664
## Exports.of.goods.and.services.(%.of.GDP) 0.0029012187
## External.balance.on.goods.and.services.(%.of.GDP) 0.0066112541
## Final.consumption.expenditure.(%.of.GDP) 0.0021484594
## General.government.final.consumption.expenditure.(%.of.GDP) -0.0073009728
## Gross.capital.formation.(%.of.GDP) -0.0401610563
## Gross.domestic.savings.(%.of.GDP) -0.0021484594
## Gross.fixed.capital.formation.(%.of.GDP) -0.0471900441
## Gross.national.expenditure.(%.of.GDP) -0.0176387321
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.0142335621
## Gross.savings.(%.of.GDP) 0.0612057018
## Gross.savings.(%.of.GNI) 0.0200073557
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.0170812497
## Imports.of.goods.and.services.(%.of.GDP) 0.0003373102
## Industry.(including.construction),.value.added.(%.of.GDP) -0.5002545613
## Manufacturing,.value.added.(%.of.GDP) -0.0106456898
## Services,.value.added.(%.of.GDP) -0.7226104083
## Trade.(%.of.GDP) 0.0017459011
## PC12
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.014501795
## Exports.of.goods.and.services.(%.of.GDP) 0.165017940
## External.balance.on.goods.and.services.(%.of.GDP) 0.793444662
## Final.consumption.expenditure.(%.of.GDP) 0.203008138
## General.government.final.consumption.expenditure.(%.of.GDP) 0.105620729
## Gross.capital.formation.(%.of.GDP) 0.236103525
## Gross.domestic.savings.(%.of.GDP) -0.203008138
## Gross.fixed.capital.formation.(%.of.GDP) -0.021604791
## Gross.national.expenditure.(%.of.GDP) 0.339885854
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.004055379
## Gross.savings.(%.of.GDP) -0.056219160
## Gross.savings.(%.of.GNI) 0.114521100
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.177731165
## Imports.of.goods.and.services.(%.of.GDP) -0.170922549
## Industry.(including.construction),.value.added.(%.of.GDP) -0.005096417
## Manufacturing,.value.added.(%.of.GDP) -0.016139892
## Services,.value.added.(%.of.GDP) -0.014929268
## Trade.(%.of.GDP) 0.009252275
## PC13
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.034416934
## Exports.of.goods.and.services.(%.of.GDP) 0.034015062
## External.balance.on.goods.and.services.(%.of.GDP) 0.103799309
## Final.consumption.expenditure.(%.of.GDP) -0.015211294
## General.government.final.consumption.expenditure.(%.of.GDP) 0.001923498
## Gross.capital.formation.(%.of.GDP) 0.092798034
## Gross.domestic.savings.(%.of.GDP) 0.015211294
## Gross.fixed.capital.formation.(%.of.GDP) -0.047072574
## Gross.national.expenditure.(%.of.GDP) 0.029533386
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 0.001689043
## Gross.savings.(%.of.GDP) 0.657357080
## Gross.savings.(%.of.GNI) -0.735706815
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.026235233
## Imports.of.goods.and.services.(%.of.GDP) -0.008017432
## Industry.(including.construction),.value.added.(%.of.GDP) 0.003793276
## Manufacturing,.value.added.(%.of.GDP) 0.016312757
## Services,.value.added.(%.of.GDP) 0.008966879
## Trade.(%.of.GDP) 0.014798535
## PC14
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 0.005250478
## Exports.of.goods.and.services.(%.of.GDP) -0.006585050
## External.balance.on.goods.and.services.(%.of.GDP) -0.021783849
## Final.consumption.expenditure.(%.of.GDP) -0.273134066
## General.government.final.consumption.expenditure.(%.of.GDP) 0.396365470
## Gross.capital.formation.(%.of.GDP) 0.113015438
## Gross.domestic.savings.(%.of.GDP) 0.273134066
## Gross.fixed.capital.formation.(%.of.GDP) -0.005587409
## Gross.national.expenditure.(%.of.GDP) -0.242905420
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -0.001913087
## Gross.savings.(%.of.GDP) -0.021908965
## Gross.savings.(%.of.GNI) 0.022818807
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 0.787451721
## Imports.of.goods.and.services.(%.of.GDP) 0.002321425
## Industry.(including.construction),.value.added.(%.of.GDP) -0.004381411
## Manufacturing,.value.added.(%.of.GDP) 0.009989815
## Services,.value.added.(%.of.GDP) 0.011070352
## Trade.(%.of.GDP) -0.002500464
## PC15
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 2.444510e-15
## Exports.of.goods.and.services.(%.of.GDP) -1.293202e-02
## External.balance.on.goods.and.services.(%.of.GDP) 4.403631e-03
## Final.consumption.expenditure.(%.of.GDP) -4.136468e-01
## General.government.final.consumption.expenditure.(%.of.GDP) 2.332675e-14
## Gross.capital.formation.(%.of.GDP) -3.661278e-01
## Gross.domestic.savings.(%.of.GDP) 3.919471e-01
## Gross.fixed.capital.formation.(%.of.GDP) -3.405224e-15
## Gross.national.expenditure.(%.of.GDP) 7.355004e-01
## Gross.national.expenditure.deflator.(base.year.varies.by.country) 8.134514e-16
## Gross.savings.(%.of.GDP) -4.048843e-15
## Gross.savings.(%.of.GNI) 5.580629e-15
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 4.403590e-14
## Imports.of.goods.and.services.(%.of.GDP) 8.132502e-03
## Industry.(including.construction),.value.added.(%.of.GDP) -1.163570e-15
## Manufacturing,.value.added.(%.of.GDP) 6.932779e-16
## Services,.value.added.(%.of.GDP) 2.177004e-16
## Trade.(%.of.GDP) 3.242971e-03
## PC16
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) 1.549641e-15
## Exports.of.goods.and.services.(%.of.GDP) -1.626624e-02
## External.balance.on.goods.and.services.(%.of.GDP) -6.304585e-04
## Final.consumption.expenditure.(%.of.GDP) -7.002008e-01
## General.government.final.consumption.expenditure.(%.of.GDP) 5.878052e-15
## Gross.capital.formation.(%.of.GDP) 5.680079e-03
## Gross.domestic.savings.(%.of.GDP) -7.126987e-01
## Gross.fixed.capital.formation.(%.of.GDP) 6.728359e-16
## Gross.national.expenditure.(%.of.GDP) -1.141050e-02
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -1.138143e-16
## Gross.savings.(%.of.GDP) -4.032211e-15
## Gross.savings.(%.of.GNI) 4.680198e-15
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) 7.377832e-15
## Imports.of.goods.and.services.(%.of.GDP) -1.686223e-02
## Industry.(including.construction),.value.added.(%.of.GDP) 3.684712e-16
## Manufacturing,.value.added.(%.of.GDP) 8.582098e-17
## Services,.value.added.(%.of.GDP) 5.903164e-16
## Trade.(%.of.GDP) 3.267531e-02
## PC17
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -3.891789e-16
## Exports.of.goods.and.services.(%.of.GDP) -2.200697e-01
## External.balance.on.goods.and.services.(%.of.GDP) -8.422694e-02
## Final.consumption.expenditure.(%.of.GDP) 2.755279e-02
## General.government.final.consumption.expenditure.(%.of.GDP) -4.698911e-15
## Gross.capital.formation.(%.of.GDP) -4.062772e-05
## Gross.domestic.savings.(%.of.GDP) 2.764218e-02
## Gross.fixed.capital.formation.(%.of.GDP) -8.505532e-16
## Gross.national.expenditure.(%.of.GDP) 8.161549e-05
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -1.692855e-16
## Gross.savings.(%.of.GDP) -1.512876e-15
## Gross.savings.(%.of.GNI) 2.292063e-15
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -9.691217e-15
## Imports.of.goods.and.services.(%.of.GDP) -5.605369e-01
## Industry.(including.construction),.value.added.(%.of.GDP) -1.137825e-15
## Manufacturing,.value.added.(%.of.GDP) 3.223657e-17
## Services,.value.added.(%.of.GDP) -1.375594e-15
## Trade.(%.of.GDP) 7.929378e-01
## PC18
## Agriculture,.forestry,.and.fishing,.value.added.(%.of.GDP) -7.807942e-16
## Exports.of.goods.and.services.(%.of.GDP) -7.904967e-01
## External.balance.on.goods.and.services.(%.of.GDP) 2.740378e-01
## Final.consumption.expenditure.(%.of.GDP) 1.350466e-02
## General.government.final.consumption.expenditure.(%.of.GDP) -2.053819e-15
## Gross.capital.formation.(%.of.GDP) 5.884046e-03
## Gross.domestic.savings.(%.of.GDP) 5.579489e-04
## Gross.fixed.capital.formation.(%.of.GDP) -4.009069e-17
## Gross.national.expenditure.(%.of.GDP) -1.182024e-02
## Gross.national.expenditure.deflator.(base.year.varies.by.country) -7.358132e-17
## Gross.savings.(%.of.GDP) 6.644472e-15
## Gross.savings.(%.of.GNI) -7.512073e-15
## Households.and.NPISHs.final.consumption.expenditure.(%.of.GDP) -2.267380e-15
## Imports.of.goods.and.services.(%.of.GDP) 5.184427e-01
## Industry.(including.construction),.value.added.(%.of.GDP) 4.515171e-16
## Manufacturing,.value.added.(%.of.GDP) -4.552111e-16
## Services,.value.added.(%.of.GDP) -3.178864e-16
## Trade.(%.of.GDP) 1.757224e-01
#loadings refer to the coefficients (or weights) that define the contribution of each original variable (feature) to the principal components.
Interpretation
Based on above results from loading we can see that how each original feature contributes to the principal component. For PC1, the loadings are as follows:(taking first 3 values)
Agriculture, forestry, and fishing, value added (% of GDP): -0.1517
This feature has a negative loading on PC1. A negative value indicates an inverse relationship with the principal component. If PC1 increases, the value for agriculture, forestry, and fishing as a percentage of GDP would tend to decrease, and vice versa.
Exports of goods and services (% of GDP): 0.1997
This feature has a positive loading on PC1. A positive value indicates a direct relationship with the principal component. If PC1 increases, the value of exports of goods and services as a percentage of GDP would also tend to increase, and vice versa.
External balance on goods and services (% of GDP): 0.3182
This feature also has a positive loading on PC1, with a stronger magnitude than exports. This means that external balance on goods and services has a greater influence on PC1 compared to exports. If PC1 increases, the external balance as a percentage of GDP tends to increase as well.
Visualizing PCA
# Plot the variance explained by each principal component
explained_variance <- pca_result$sdev^2 / sum(pca_result$sdev^2) * 100
barplot(explained_variance, main = "Variance Explained by Principal Components",
xlab = "Principal Component", ylab = "Percentage of Variance", col = "steelblue")
# Biplot for PCA
biplot(pca_result, scale = 0, cex = 0.5)
Interpretation of Biplot
The x-axis and y-axis in a biplot correspond to the first two principal components (PC1 and PC2). Based on arrow direction and length we can interpret:
Arrows with longer length indicate stronger contributions to the principal component.(In the plot we can see : Services value added , Import of goods , Trade have higher contribution to principal component).
Also arrows which are pointing downward (negative direction of PC1), the variable has a negative correlation with that principal component (In the plot we can see : Agriculture , National expenditure , final consumption has a negative correlation with that principal component.).
t-SNE Technique
t-SNE is a non-linear dimension reduction technique designed primarily for visualization of high-dimensional data in 2D or 3D space. Unlike PCA, it preserves local relationships rather than maximizing variance.
Steps of t-SNE
Compute Pairwise Similarities in High Dimensions: t-SNE calculates probabilities that points are neighbors in high-dimensional space using a Gaussian distribution.
Define Low-Dimensional Pairwise Similarities: This distribution assigns higher probabilities to close points, ensuring better separation. Minimize the KL Divergence:
Minimize the KL Divergence: t-SNE optimizes the positions of points in the lower-dimensional space to minimize the Kullback-Leibler (KL) divergence between the high-dimensional and low-dimensional similarity distributions.
#Prepare data for t-SNE
# Remove the "Country.Name" column as t-SNE requires only numeric data
tsne_input <- numeric_columns
# Run t-SNE
# Set a random seed for reproducibility
set.seed(42)
# Perform t-SNE (Here performing it for 2 dimensions)
tsne_result <- Rtsne(as.matrix(tsne_input), dims = 2, perplexity = 30, verbose = TRUE, max_iter = 500)
## Performing PCA
## Read the 103 x 18 data matrix successfully!
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.00 seconds (sparsity = 0.970308)!
## Learning embedding...
## Iteration 50: error is 50.675359 (50 iterations in 0.01 seconds)
## Iteration 100: error is 50.492930 (50 iterations in 0.01 seconds)
## Iteration 150: error is 51.284187 (50 iterations in 0.01 seconds)
## Iteration 200: error is 51.109574 (50 iterations in 0.01 seconds)
## Iteration 250: error is 48.977678 (50 iterations in 0.01 seconds)
## Iteration 300: error is 1.369714 (50 iterations in 0.00 seconds)
## Iteration 350: error is 0.578178 (50 iterations in 0.00 seconds)
## Iteration 400: error is 0.155347 (50 iterations in 0.00 seconds)
## Iteration 450: error is 0.126394 (50 iterations in 0.00 seconds)
## Iteration 500: error is 0.112426 (50 iterations in 0.00 seconds)
## Fitting performed in 0.05 seconds.
Visualizing t-SNE
# View the t-SNE results
# Install and load plotly if not already installed
if (!requireNamespace("plotly", quietly = TRUE)) {
install.packages("plotly")
}
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
# 2D t-SNE Visualization
tsne_data <- data.frame(
X = tsne_result$Y[, 1],
Y = tsne_result$Y[, 2],
Country = numeric_data$Country.Name
)
plot_ly(
tsne_data,
x = ~X, y = ~Y,
color = ~Country,
type = "scatter",
mode = "markers+text",
text = ~Country
) %>%
layout(
title = "t-SNE Visualization in 2D",
xaxis = list(title = "t-SNE Dimension 1"),
yaxis = list(title = "t-SNE Dimension 2")
)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
Interpretation of t-SNE plot
The t-SNE method maps high-dimensional data to two dimensions (in this case, the x and y axes of the plot). The goal is to keep similar data points together and separate dissimilar points.
Each point in the 2D plot represents an observation (in this case, a country). If there are any patterns in the data (such as countries with similar economic indicators), they will tend to cluster together.
The x and y axes represent the first two dimensions (or components) that capture the most variance in the data. These axes do not have direct physical meanings as they are derived from the relationships between all the original features.
Countries that are close to each other on the plot are more similar to each other based on the features used for t-SNE.Points that are far apart indicate countries with more distinct differences in their economic data.
In the above plot we can see countries such as Germany and Finland has more similarities in their economic data as they are closely placed to each other. On the other hand Poland is not that much similar to Germany or to Finland.
Comparison of PCA & t- SNE
I think we cannot directly compare PCA and t-SNE for concluding which one is better. Selection of technique for Dimension reduction depends on what we want to do. PCA is better for reducing dimensions while maintaining the variance (i.e., the data’s important information). It can be further used for subsequent analysis and modeling tasks however t-SNE is better for visualizing high-dimensional data and finding underlying patterns (such as clusters or groupings), but it is not as useful for further machine learning tasks due to its non-linear nature and computational complexity.
So if we just want to get a rough idea of how countries are related in terms of their economic data i will prefer t-SNE on the other hand if i want to perform additional analysis and get deeper insight i will go for PCA.