Title: | Computational Methods for Economic Complexity |
---|---|
Description: | A wrapper of different methods from Linear Algebra for the equations introduced in The Atlas of Economic Complexity and related literature. This package provides standard matrix and graph output that can be used seamlessly with other packages. See <doi:10.21105/joss.01866> for a summary of these methods and its evolution in literature. |
Authors: | Mauricio Vargas Sepulveda [aut, cre, cph] , Carlo Bottai [ctb] (improved the eigenvalues calculation), Diego Kozlowski [ctb] (provided initial RCA function used up to v0.2.4), Nico Pintar [rev] (suggested improvements to special cases in eigenvalues calculation), The World Bank [dtc] (World GDP per capita dataset), Open Trade Statistics [dtc] (World Trade dataset) |
Maintainer: | Mauricio Vargas Sepulveda <[email protected]> |
License: | GPL-3 |
Version: | 1.5.0 |
Built: | 2024-10-30 03:16:11 UTC |
Source: | https://github.com/pachadotdev/economiccomplexity |
balassa_index()
computes the Balassa Index for a
bipartite relation between countries and products.
balassa_index( data, discrete = TRUE, cutoff = 1, country = "country", product = "product", value = "value" )
balassa_index( data, discrete = TRUE, cutoff = 1, country = "country", product = "product", value = "value" )
data |
(Type: data.frame, matrix or dgCMatrix) a dataset such as
|
discrete |
(Type: logical) whether converting the Balassa Index to
discrete (0/1) values. Anything below the specified cutoff is converted to 0
and 1 otherwise. By default this is set to |
cutoff |
(Type: numeric) the cutoff to use for discretization.
By default this is set to |
country |
(Type: character) the column with the countries.
By default this is set to |
product |
(Type: character) the column with the products.
By default this is set to |
value |
(Type: character) the column with the metric for
country-product pairs.
By default this is set to |
The current implementation follows (Mariani et al. 2015) to obtain a metric for specialisation. In the context of international trade, if the Balassa Index for a country-product pair is more than 1, it means that country is specialized in that product. If the input for this function is a data.frame instead of a matrix, the function shall aggregate the data and convert the input to a matrix.
A matrix with the Balassa Index.
For more information see:
Mariani M, Vidmer A, Medo M, Zhang Y (2015). “Measuring economic complexity of countries and products: which metric to use?” The European Physical Journal B, 88(11), 293. doi:10.1140/epjb/e2015-60298-7.
and the references therein.
bi <- balassa_index(world_trade_avg_1998_to_2000) # partial view of index bi[1:5, 1:5]
bi <- balassa_index(world_trade_avg_1998_to_2000) # partial view of index bi[1:5, 1:5]
complexity_measures()
computes the Economic Complexity
Index and the Product Complexity Index.
complexity_measures( balassa_index, method = "fitness", iterations = 20, extremality = 1 )
complexity_measures( balassa_index, method = "fitness", iterations = 20, extremality = 1 )
balassa_index |
(Type: dgCMatrix) the output from
|
method |
(Type: character) one of these methods: fitness,
reflections or eigenvalues. By default this is set to |
iterations |
(Type: numeric) the number of iterations to use.
By default this is set to |
extremality |
(Type: numeric) the parameter to use in the fitness
method. The other methods don't use this parameter.
By default this is set to |
The current implementation follows (Mariani et al. 2015) to obtain different alternatives that account for diversification in bipartite relations.
A list of two named numeric vectors.
For more information on this index see:
Mariani M, Vidmer A, Medo M, Zhang Y (2015). “Measuring economic complexity of countries and products: which metric to use?” The European Physical Journal B, 88(11), 293. doi:10.1140/epjb/e2015-60298-7.
and the references therein.
co <- complexity_measures(economiccomplexity_output$balassa_index) # partial view of indexes co$complexity_index_country[1:5] co$complexity_index_product[1:5]
co <- complexity_measures(economiccomplexity_output$balassa_index) # partial view of indexes co$complexity_index_country[1:5] co$complexity_index_product[1:5]
complexity_outlook()
computes the Complexity Outlook
Index and the Complexity Outlook Gain.
complexity_outlook(balassa_index, proximity_product, complexity_index_product)
complexity_outlook(balassa_index, proximity_product, complexity_index_product)
balassa_index |
(Type: dgCMatrix) the output from
|
proximity_product |
(Type: dgCMatrix) the output from
|
complexity_index_product |
(Type: numeric) the output from
|
The current implementation follows (Hausmann et al. 2014) to measure unexploited export oppportunities.
A list of two named numeric vectors.
For more information on this index see:
Hausmann R, Hidalgo C, Bustos S, Coscia M, Simoes A, Yildirim M (2014). The atlas of economic complexity: Mapping paths to prosperity. MIT Press. doi:10.7551/mitpress/9647.001.0001.
and the references therein.
co <- complexity_outlook( economiccomplexity_output$balassa_index, economiccomplexity_output$proximity$proximity_product, economiccomplexity_output$complexity_measures$complexity_index_product ) # partial view of complexity outlook co$complexity_outlook_index[1:5] co$complexity_outlook_gain[1:5, 1:5]
co <- complexity_outlook( economiccomplexity_output$balassa_index, economiccomplexity_output$proximity$proximity_product, economiccomplexity_output$complexity_measures$complexity_index_product ) # partial view of complexity outlook co$complexity_outlook_index[1:5] co$complexity_outlook_gain[1:5, 1:5]
density()
computes the density matrix that
accounts for the weighted proportions of the products connected to
each good that the countries are exporting.
density(balassa_index, proximity_product)
density(balassa_index, proximity_product)
balassa_index |
(Type: dgCMatrix) the output from
|
proximity_product |
(Type: dgCMatrix) the output from
|
The current implementation follows (Hausmann et al. 2014) to measure the oppotunities implied by a country's position.
A matrix.
For more information on this index see:
Hausmann R, Hidalgo C, Bustos S, Coscia M, Simoes A, Yildirim M (2014). The atlas of economic complexity: Mapping paths to prosperity. MIT Press. doi:10.7551/mitpress/9647.001.0001.
and the references therein.
d <- density( economiccomplexity_output$balassa_index, economiccomplexity_output$proximity$proximity_product ) # partial view of the density matrix d[1:5, 1:5]
d <- density( economiccomplexity_output$balassa_index, economiccomplexity_output$proximity$proximity_product ) # partial view of the density matrix d[1:5, 1:5]
distance()
computes the distance matrix that
accounts for the weighted proportions of the products connected to
each good that the countries are not exporting.
distance(balassa_index, proximity_product)
distance(balassa_index, proximity_product)
balassa_index |
(Type: dgCMatrix) the output from
|
proximity_product |
(Type: dgCMatrix) the output from
|
The current implementation follows (Hausmann et al. 2014) to measure the oppotunities implied by a country's position.
A matrix.
For more information on this index see:
Hausmann R, Hidalgo C, Bustos S, Coscia M, Simoes A, Yildirim M (2014). The atlas of economic complexity: Mapping paths to prosperity. MIT Press. doi:10.7551/mitpress/9647.001.0001.
and the references therein.
d <- distance( economiccomplexity_output$balassa_index, economiccomplexity_output$proximity$proximity_product ) # partial view of the distance matrix d[1:5, 1:5]
d <- distance( economiccomplexity_output$balassa_index, economiccomplexity_output$proximity$proximity_product ) # partial view of the distance matrix d[1:5, 1:5]
List of different computations obtained by using the functions within the package
economiccomplexity_output
economiccomplexity_output
Lists of vectors, matrices and graphs.
economiccomplexity_output$balassa_index economiccomplexity_output$complexity_measures$complexity_index_country
economiccomplexity_output$balassa_index economiccomplexity_output$complexity_measures$complexity_index_country
productivity_levels()
computes EXPY and PRODY measures.
productivity_levels( data_exp, data_gdp, country = "country", product = "product", value = "value" )
productivity_levels( data_exp, data_gdp, country = "country", product = "product", value = "value" )
data_exp |
(Type: data.frame, matrix or dgCMatrix) a dataset containing countries, products and exported values. |
data_gdp |
(Type: data.frame, matrix or dgCMatrix) a dataset containing countries and per-capita GDP values. |
country |
(Type: character) the column with the countries.
By default this is set to |
product |
(Type: character) the column with the products.
By default this is set to |
value |
(Type: character) the column with the metric for
country-product pairs.
By default this is set to |
The current implementation follows (Hausmann et al. 2005) to obtain the productivity and income levels associated to exports.
A list of two named numeric vectors.
For more information on prody and its applications see:
Hausmann R, Hwang J, Rodrik D (2005). “What You Export Matters.” Working Paper 11905, National Bureau of Economic Research. doi:10.3386/w11905.
pl <- productivity_levels( world_trade_avg_1998_to_2000, world_gdp_avg_1998_to_2000 ) # partial view of productivity levels pl$productivity_level_country[1:5] pl$productivity_level_product[1:5]
pl <- productivity_levels( world_trade_avg_1998_to_2000, world_gdp_avg_1998_to_2000 ) # partial view of productivity levels pl$productivity_level_country[1:5] pl$productivity_level_product[1:5]
projections()
computes two graphs that are particularly
useful to visualize product-product and country-country similarity.
projections( proximity_country, proximity_product, avg_links = 5, tolerance = 0.05, compute = "both" )
projections( proximity_country, proximity_product, avg_links = 5, tolerance = 0.05, compute = "both" )
proximity_country |
(Type: dgCMatrix) the output from
|
proximity_product |
(Type: dgCMatrix) the output from
|
avg_links |
average number of connections for the projections.
By default this is set to |
tolerance |
tolerance for proximity variation on each iteration until
obtaining the desired average number of connections.
By default this is set to |
compute |
(Type: character) the proximity to compute. By default this is
|
The current implementation follows (Hausmann et al. 2014) to create simplified graphs that correspond to a simplification of the proximity matrices. The result is obtained by iterating and reducing links until the desired average number of links per node is obtained, or a spaning tree after the strongest links is returned when is not possible to return the desired network.
A list of two graphs.
For more information see:
Hausmann R, Hidalgo C, Bustos S, Coscia M, Simoes A, Yildirim M (2014). The atlas of economic complexity: Mapping paths to prosperity. MIT Press. doi:10.7551/mitpress/9647.001.0001.
and the references therein.
net <- projections( economiccomplexity_output$proximity$proximity_country, economiccomplexity_output$proximity$proximity_product, avg_links = 10, tolerance = 0.1 ) # partial view of projections igraph::E(net$network_country)[1:5] igraph::E(net$network_product)[1:5]
net <- projections( economiccomplexity_output$proximity$proximity_country, economiccomplexity_output$proximity$proximity_product, avg_links = 10, tolerance = 0.1 ) # partial view of projections igraph::E(net$network_country)[1:5] igraph::E(net$network_product)[1:5]
proximity()
computes two matrices that account for the
similarity between pairs of countries and pairs of products.
proximity(balassa_index, compute = "both")
proximity(balassa_index, compute = "both")
balassa_index |
(Type: dgCMatrix) the output from
|
compute |
(Type: character) the proximity to compute. By default this is
|
The current implementation follows (Hausmann et al. 2014) to obtain the likelihood that two products "p1" and "p2" are exported by the same country and, conversely, that two countries "c1" and "c2" export the same product.
A list of two matrices.
For more information see:
Hausmann R, Hidalgo C, Bustos S, Coscia M, Simoes A, Yildirim M (2014). The atlas of economic complexity: Mapping paths to prosperity. MIT Press. doi:10.7551/mitpress/9647.001.0001.
and the references therein.
pro <- proximity(economiccomplexity_output$balassa_index) # partial view of proximity matrices pro$proximity_country[1:5, 1:5] pro$proximity_product[1:5, 1:5]
pro <- proximity(economiccomplexity_output$balassa_index) # partial view of proximity matrices pro$proximity_country[1:5, 1:5] pro$proximity_product[1:5, 1:5]
balassa_index()
replaces this function
rca(...)
rca(...)
... |
old parameters |
A data frame that summarises the per-capita GDP of different countries. The unit is year 2000 USD.
world_gdp_avg_1998_to_2000
world_gdp_avg_1998_to_2000
A data frame with 240 rows and 2 columns.
world_gdp_avg_1998_to_2000
world_gdp_avg_1998_to_2000
A data frame that summarises all the products that different countries exported to the rest of the world. This data uses the SITC revision 2 classification with four digits product codes. The unit is year 2000 USD.
world_trade_avg_1998_to_2000
world_trade_avg_1998_to_2000
A data frame with 124,336 rows and 3 columns.
world_trade_avg_1998_to_2000
world_trade_avg_1998_to_2000