setwd("C:/Clase 1206")
library(rio)
data1=import("Youth unemployment rate (ages 15-24).csv")
data1
## name slug %
## 1 Djibouti djibouti 79.9
## 2 South Africa south-africa 64.2
## 3 Eswatini eswatini 50.9
## 4 Libya libya 50.5
## 5 Kosovo kosovo 48.8
## 6 Costa Rica costa-rica 45.4
## 7 Congo, Republic of the congo-republic-of-the 42.3
## 8 Curacao curacao 42.2
## 9 Botswana botswana 41.2
## 10 Saint Vincent and the Grenadines saint-vincent-and-the-grenadines 41.1
## 11 New Caledonia new-caledonia 41.0
## 12 Jordan jordan 40.5
## 13 Namibia namibia 40.4
## 14 West Bank west-bank 39.6
## 15 Gaza Strip gaza-strip 39.6
## 16 French Polynesia french-polynesia 38.9
## 17 Saint Lucia saint-lucia 38.7
## 18 Gabon gabon 38.4
## 19 Tunisia tunisia 38.3
## 20 Lesotho lesotho 37.4
## 21 Greece greece 36.9
## 22 Spain spain 36.9
## 23 Armenia armenia 36.1
## 24 Haiti haiti 35.7
## 25 Sudan sudan 35.6
## 26 Somalia somalia 34.7
## 27 Cabo Verde cabo-verde 34.3
## 28 North Macedonia north-macedonia 34.1
## 29 Uruguay uruguay 32.9
## 30 Bosnia and Herzegovina bosnia-and-herzegovina 32.9
## 31 Algeria algeria 31.9
## 32 Brazil brazil 31.9
## 33 Montenegro montenegro 31.6
## 34 Italy italy 30.9
## 35 Bahamas, The bahamas-the 30.8
## 36 Barbados barbados 30.6
## 37 Suriname suriname 30.5
## 38 Serbia serbia 30.4
## 39 Panama panama 30.0
## 40 Guyana guyana 29.9
## 41 Argentina argentina 29.9
## 42 Lebanon lebanon 29.6
## 43 Bermuda bermuda 29.3
## 44 Saudi Arabia saudi-arabia 28.8
## 45 Georgia georgia 28.3
## 46 India india 28.3
## 47 Albania albania 27.8
## 48 San Marino san-marino 27.4
## 49 Morocco morocco 27.2
## 50 Iraq iraq 27.2
## 51 Iran iran 27.2
## 52 Virgin Islands virgin-islands 27.0
## 53 Nauru nauru 26.6
## 54 Monaco monaco 26.6
## 55 Colombia colombia 26.4
## 56 Syria syria 26.2
## 57 Sri Lanka sri-lanka 26.1
## 58 Jamaica jamaica 26.1
## 59 Zambia zambia 26.1
## 60 Marshall Islands marshall-islands 26.0
## 61 Yemen yemen 25.5
## 62 Kuwait kuwait 25.5
## 63 Mauritius mauritius 25.3
## 64 Sweden sweden 24.5
## 65 Turkey (Turkiye) turkey-turkiye 24.3
## 66 Egypt egypt 24.3
## 67 Croatia croatia 23.6
## 68 Brunei brunei 23.4
## 69 Portugal portugal 23.1
## 70 Mauritania mauritania 23.0
## 71 Sao Tome and Principe sao-tome-and-principe 22.9
## 72 Kiribati kiribati 22.5
## 73 Comoros comoros 21.7
## 74 Slovakia slovakia 21.5
## 75 Chile chile 21.4
## 76 South Sudan south-sudan 21.0
## 77 Mongolia mongolia 21.0
## 78 Dominican Republic dominican-republic 20.6
## 79 Tuvalu tuvalu 20.6
## 80 Romania romania 20.6
## 81 Afghanistan afghanistan 20.2
## 82 France france 20.1
## 83 Samoa samoa 19.7
## 84 Nigeria nigeria 19.6
## 85 Belgium belgium 19.6
## 86 Belize belize 19.3
## 87 Kyrgyzstan kyrgyzstan 19.3
## 88 Lithuania lithuania 19.0
## 89 Micronesia, Federated States of micronesia-federated-states-of 18.9
## 90 Bhutan bhutan 18.8
## 91 Angola angola 18.5
## 92 Puerto Rico puerto-rico 18.5
## 93 Equatorial Guinea equatorial-guinea 18.3
## 94 Finland finland 18.1
## 95 Fiji fiji 18.1
## 96 Maldives maldives 17.7
## 97 Tajikistan tajikistan 17.4
## 98 Ireland ireland 17.4
## 99 Bolivia bolivia 17.4
## 100 Mali mali 17.3
## 101 Estonia estonia 17.1
## 102 Russia russia 16.9
## 103 Ukraine ukraine 16.5
## 104 Seychelles seychelles 16.5
## 105 Azerbaijan azerbaijan 16.5
## 106 Paraguay paraguay 16.3
## 107 Indonesia indonesia 16.1
## 108 Uzbekistan uzbekistan 16.0
## 109 Jersey jersey 15.8
## 110 Guernsey guernsey 15.8
## 111 Malaysia malaysia 15.6
## 112 Honduras honduras 15.5
## 113 Latvia latvia 15.5
## 114 Gambia, The gambia-the 15.5
## 115 Guam guam 15.3
## 116 Luxembourg luxembourg 15.2
## 117 Hong Kong hong-kong 15.0
## 118 Venezuela venezuela 14.9
## 119 Bangladesh bangladesh 14.7
## 120 Oman oman 14.6
## 121 Eritrea eritrea 14.6
## 122 Bulgaria bulgaria 14.2
## 123 Ecuador ecuador 14.2
## 124 Canada canada 14.0
## 125 Slovenia slovenia 13.9
## 126 Cayman Islands cayman-islands 13.8
## 127 Timor-Leste timor-leste 13.8
## 128 Kenya kenya 13.8
## 129 El Salvador el-salvador 13.7
## 130 Hungary hungary 13.5
## 131 Poland poland 13.4
## 132 Iceland iceland 13.4
## 133 United Kingdom united-kingdom 13.2
## 134 Norway norway 13.0
## 135 Guinea-Bissau guinea-bissau 12.8
## 136 Trinidad and Tobago trinidad-and-tobago 12.7
## 137 Central African Republic central-african-republic 11.8
## 138 Cyprus cyprus 11.8
## 139 Nicaragua nicaragua 11.6
## 140 New Zealand new-zealand 11.4
## 141 Austria austria 11.4
## 142 China china 11.4
## 143 Belarus belarus 11.3
## 144 Peru peru 11.2
## 145 Tonga tonga 11.1
## 146 Turkmenistan turkmenistan 11.0
## 147 Sierra Leone sierra-leone 10.8
## 148 Australia australia 10.8
## 149 United Arab Emirates united-arab-emirates 10.7
## 150 Isle of Man isle-of-man 10.1
## 151 Denmark denmark 10.1
## 152 Congo, Democratic Republic of the congo-democratic-republic-of-the 10.1
## 153 Malawi malawi 9.9
## 154 Bahrain bahrain 9.9
## 155 Malta malta 9.8
## 156 Togo togo 9.7
## 157 Netherlands netherlands 9.6
## 158 Ghana ghana 9.6
## 159 United States united-states 9.6
## 160 Nepal nepal 9.5
## 161 Pakistan pakistan 9.4
## 162 Macau macau 9.2
## 163 Switzerland switzerland 9.1
## 164 Singapore singapore 9.1
## 165 Israel israel 8.8
## 166 Moldova moldova 8.6
## 167 Guinea guinea 8.2
## 168 Mozambique mozambique 8.1
## 169 Mexico mexico 8.1
## 170 Korea, South korea-south 7.8
## 171 Burkina Faso burkina-faso 7.7
## 172 Czechia czechia 7.6
## 173 Cuba cuba 7.4
## 174 Zimbabwe zimbabwe 7.3
## 175 Philippines philippines 7.3
## 176 Guatemala guatemala 7.2
## 177 Vietnam vietnam 7.2
## 178 Germany germany 7.0
## 179 Thailand thailand 7.0
## 180 Cameroon cameroon 6.6
## 181 Burma burma 6.4
## 182 Korea, North korea-north 6.1
## 183 Ethiopia ethiopia 5.7
## 184 Cote d'Ivoire cote-divoire 5.7
## 185 Palau palau 5.6
## 186 Vanuatu vanuatu 5.4
## 187 Papua New Guinea papua-new-guinea 5.3
## 188 Senegal senegal 5.0
## 189 Madagascar madagascar 4.8
## 190 Tanzania tanzania 4.6
## 191 Japan japan 4.4
## 192 Uganda uganda 4.3
## 193 Benin benin 3.9
## 194 Kazakhstan kazakhstan 3.7
## 195 Burundi burundi 3.4
## 196 Laos laos 3.3
## 197 Liberia liberia 3.2
## 198 Rwanda rwanda 2.9
## 199 Chad chad 2.4
## 200 Solomon Islands solomon-islands 1.9
## 201 Cambodia cambodia 1.8
## 202 Qatar qatar 1.1
## 203 Niger niger 1.0
## date_of_information ranking region
## 1 2021 1 Africa
## 2 2021 2 Africa
## 3 2021 3 Africa
## 4 2021 4 Africa
## 5 2020 5 Europe
## 6 2021 6 Central America and the Caribbean
## 7 2021 7 Africa
## 8 2020 8 Central America and the Caribbean
## 9 2021 9 Africa
## 10 2021 10 Central America and the Caribbean
## 11 2021 11 Australia and Oceania
## 12 2021 12 Middle East
## 13 2021 13 Africa
## 14 2021 14 Middle East
## 15 2021 15 Middle East
## 16 2021 16 Australia and Oceania
## 17 2021 17 Central America and the Caribbean
## 18 2021 18 Africa
## 19 2021 19 Africa
## 20 2021 20 Africa
## 21 2021 21 Europe
## 22 2021 22 Europe
## 23 2021 23 Middle East
## 24 2021 24 Central America and the Caribbean
## 25 2021 25 Africa
## 26 2021 26 Africa
## 27 2021 27 Africa
## 28 2021 28 Europe
## 29 2021 29 South America
## 30 2021 30 Europe
## 31 2021 31 Africa
## 32 2021 32 South America
## 33 2021 33 Europe
## 34 2021 34 Europe
## 35 2021 35 Central America and the Caribbean
## 36 2021 36 Central America and the Caribbean
## 37 2021 37 South America
## 38 2021 38 Europe
## 39 2021 39 Central America and the Caribbean
## 40 2021 40 South America
## 41 2021 41 South America
## 42 2021 42 Middle East
## 43 2014 43 North America
## 44 2021 44 Middle East
## 45 2021 45 Middle East
## 46 2021 46 South Asia
## 47 2021 47 Europe
## 48 2016 48 Europe
## 49 2021 49 Africa
## 50 2021 50 Middle East
## 51 2021 51 Middle East
## 52 2021 52 Central America and the Caribbean
## 53 2013 53 Australia and Oceania
## 54 2016 54 Europe
## 55 2021 55 South America
## 56 2021 56 Middle East
## 57 2021 57 South Asia
## 58 2021 58 Central America and the Caribbean
## 59 2021 59 Africa
## 60 2019 60 Australia and Oceania
## 61 2021 61 Middle East
## 62 2021 62 Middle East
## 63 2021 63 Africa
## 64 2021 64 Europe
## 65 2021 65 Middle East
## 66 2021 66 Africa
## 67 2021 67 Europe
## 68 2021 68 East and Southeast Asia
## 69 2021 69 Europe
## 70 2021 70 Africa
## 71 2021 71 Africa
## 72 2019 72 Australia and Oceania
## 73 2021 73 Africa
## 74 2021 74 Europe
## 75 2021 75 South America
## 76 2021 76 Africa
## 77 2021 77 East and Southeast Asia
## 78 2021 78 Central America and the Caribbean
## 79 2016 79 Australia and Oceania
## 80 2021 80 Europe
## 81 2021 81 South Asia
## 82 2021 82 Europe
## 83 2021 83 Australia and Oceania
## 84 2021 84 Africa
## 85 2021 85 Europe
## 86 2021 86 Central America and the Caribbean
## 87 2021 87 Central Asia
## 88 2021 88 Europe
## 89 2014 89 Australia and Oceania
## 90 2021 90 South Asia
## 91 2021 91 Africa
## 92 2021 92 Central America and the Caribbean
## 93 2021 93 Africa
## 94 2021 94 Europe
## 95 2021 95 Australia and Oceania
## 96 2021 96 South Asia
## 97 2021 97 Central Asia
## 98 2021 98 Europe
## 99 2021 99 South America
## 100 2021 100 Africa
## 101 2021 101 Europe
## 102 2021 102 Central Asia
## 103 2021 103 Europe
## 104 2020 104 Africa
## 105 2021 105 Middle East
## 106 2021 106 South America
## 107 2021 107 East and Southeast Asia
## 108 2021 108 Central Asia
## 109 2021 109 Europe
## 110 2021 110 Europe
## 111 2021 111 East and Southeast Asia
## 112 2021 112 Central America and the Caribbean
## 113 2021 113 Europe
## 114 2021 114 Africa
## 115 2021 115 Australia and Oceania
## 116 2021 116 Europe
## 117 2021 117 East and Southeast Asia
## 118 2021 118 South America
## 119 2021 119 South Asia
## 120 2021 120 Middle East
## 121 2021 121 Africa
## 122 2021 122 Europe
## 123 2021 123 South America
## 124 2021 124 North America
## 125 2021 125 Europe
## 126 2015 126 Central America and the Caribbean
## 127 2021 127 East and Southeast Asia
## 128 2021 128 Africa
## 129 2021 129 Central America and the Caribbean
## 130 2021 130 Europe
## 131 2021 131 Europe
## 132 2021 132 Europe
## 133 2021 133 Europe
## 134 2021 134 Europe
## 135 2021 135 Africa
## 136 2021 136 Central America and the Caribbean
## 137 2021 137 Africa
## 138 2021 138 Europe
## 139 2021 139 Central America and the Caribbean
## 140 2021 140 Australia and Oceania
## 141 2021 141 Europe
## 142 2021 142 East and Southeast Asia
## 143 2021 143 Europe
## 144 2021 144 South America
## 145 2021 145 Australia and Oceania
## 146 2021 146 Central Asia
## 147 2021 147 Africa
## 148 2021 148 Australia and Oceania
## 149 2021 149 Middle East
## 150 2011 150 Europe
## 151 2021 151 Europe
## 152 2021 152 Africa
## 153 2021 153 Africa
## 154 2021 154 Middle East
## 155 2021 155 Europe
## 156 2021 156 Africa
## 157 2021 157 Europe
## 158 2021 158 Africa
## 159 2021 159 North America
## 160 2021 160 South Asia
## 161 2021 161 South Asia
## 162 2021 162 East and Southeast Asia
## 163 2021 163 Europe
## 164 2021 164 East and Southeast Asia
## 165 2021 165 Middle East
## 166 2021 166 Europe
## 167 2021 167 Africa
## 168 2021 168 Africa
## 169 2021 169 North America
## 170 2021 170 East and Southeast Asia
## 171 2021 171 Africa
## 172 2021 172 Europe
## 173 2021 173 Central America and the Caribbean
## 174 2021 174 Africa
## 175 2021 175 East and Southeast Asia
## 176 2021 176 Central America and the Caribbean
## 177 2021 177 East and Southeast Asia
## 178 2021 178 Europe
## 179 2021 179 East and Southeast Asia
## 180 2021 180 Africa
## 181 2021 181 East and Southeast Asia
## 182 2021 182 East and Southeast Asia
## 183 2021 183 Africa
## 184 2021 184 Africa
## 185 2014 185 Australia and Oceania
## 186 2021 186 Australia and Oceania
## 187 2021 187 East and Southeast Asia
## 188 2021 188 Africa
## 189 2021 189 Africa
## 190 2021 190 Africa
## 191 2021 191 East and Southeast Asia
## 192 2021 192 Africa
## 193 2021 193 Africa
## 194 2021 194 Central Asia
## 195 2021 195 Africa
## 196 2021 196 East and Southeast Asia
## 197 2021 197 Africa
## 198 2021 198 Africa
## 199 2021 199 Africa
## 200 2021 200 Australia and Oceania
## 201 2021 201 East and Southeast Asia
## 202 2021 202 Middle East
## 203 2021 203 Africa
data1$date_of_information= as.numeric(data1$date_of_information)
data1$ranking= as.numeric(data1$ranking)
str(data1)
## 'data.frame': 203 obs. of 6 variables:
## $ name : chr "Djibouti" "South Africa" "Eswatini" "Libya" ...
## $ slug : chr "djibouti" "south-africa" "eswatini" "libya" ...
## $ % : num 79.9 64.2 50.9 50.5 48.8 45.4 42.3 42.2 41.2 41.1 ...
## $ date_of_information: num 2021 2021 2021 2021 2020 ...
## $ ranking : num 1 2 3 4 5 6 7 8 9 10 ...
## $ region : chr "Africa" "Africa" "Africa" "Africa" ...
dontselect=c("name","slug","region")
select=setdiff(names(data1),dontselect)
Data1=data1[,select]
# usaremos:
library(magrittr)
head(Data1,10)%>%
rmarkdown::paged_table()
library(polycor)
corMatrix=polycor::hetcor(Data1)$correlations
round(corMatrix,2)
## % date_of_information ranking
## % 1.00 -0.01 -0.94
## date_of_information -0.01 1.00 0.04
## ranking -0.94 0.04 1.00
library(psych)
##
## Attaching package: 'psych'
## The following object is masked from 'package:polycor':
##
## polyserial
psych::KMO(corMatrix)
## Kaiser-Meyer-Olkin factor adequacy
## Call: psych::KMO(r = corMatrix)
## Overall MSA = 0.5
## MSA for each item =
## % date_of_information ranking
## 0.50 0.11 0.50
cortest.bartlett(corMatrix,n=nrow(Data1))$p.value>0.05
## [1] FALSE
library(matrixcalc)
is.singular.matrix(corMatrix)
## [1] FALSE
fa.parallel(Data1, fa = 'fa',correct = T,plot = F)
## Parallel analysis suggests that the number of factors = 1 and the number of components = NA
library(GPArotation)
##
## Attaching package: 'GPArotation'
## The following objects are masked from 'package:psych':
##
## equamax, varimin
resfa <- fa(Data1,
nfactors = 1,
cor = 'mixed',
rotate = "varimax", #oblimin?
fm="minres")
print(resfa$loadings)
##
## Loadings:
## MR1
## % -0.939
## date_of_information
## ranking 0.999
##
## MR1
## SS loadings 1.883
## Proportion Var 0.628
print(resfa$loadings,cutoff = 0.5)
##
## Loadings:
## MR1
## % -0.939
## date_of_information
## ranking 0.999
##
## MR1
## SS loadings 1.883
## Proportion Var 0.628
fa.diagram(resfa,main = "Resultados del EFA")
sort(resfa$communality)
## date_of_information % ranking
## 0.00273411 0.88155674 0.99827559