Type: | Package |
Title: | Computational Methods for Economic Complexity |
Version: | 2.0.0 |
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. |
License: | Apache License (≥ 2) |
Encoding: | UTF-8 |
LazyData: | true |
Depends: | R (≥ 3.5) |
Imports: | igraph, Rdpack |
Suggests: | testthat (≥ 2.1.0), knitr, ggplot2, ggraph, rmarkdown, covr |
URL: | https://pacha.dev/economiccomplexity/ |
BugReports: | https://github.com/pachadotdev/economiccomplexity/issues/ |
RoxygenNote: | 7.3.2 |
RdMacros: | Rdpack |
VignetteBuilder: | knitr |
LinkingTo: | cpp11, cpp11armadillo |
NeedsCompilation: | yes |
Packaged: | 2024-12-13 03:40:39 UTC; pacha |
Author: | Mauricio Vargas Sepulveda
|
Maintainer: | Mauricio Vargas Sepulveda <m.sepulveda@mail.utoronto.ca> |
Repository: | CRAN |
Date/Publication: | 2024-12-13 04:00:01 UTC |
economiccomplexity: 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.
Author(s)
Maintainer: Mauricio Vargas Sepulveda m.sepulveda@mail.utoronto.ca (ORCID) [copyright holder]
Other contributors:
Carlo Bottai (improved the eigenvalues calculation) [contributor]
Diego Kozlowski (provided initial RCA function used up to v0.2.4) [contributor]
Nico Pintar (suggested improvements to special cases in eigenvalues calculation) [reviewer]
The World Bank (World GDP per capita dataset) [data contributor]
Open Trade Statistics (World Trade dataset) [data contributor]
See Also
Useful links:
Report bugs at https://github.com/pachadotdev/economiccomplexity/issues/
Balassa Index
Description
balassa_index()
computes the Balassa Index for a
bipartite relation between countries and products.
Usage
balassa_index(
trade_data,
discrete = TRUE,
cutoff = 1,
country = "country",
product = "product",
value = "value"
)
Arguments
trade_data |
(Type: data.frame or matrix) 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 |
Details
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.
Value
A matrix with the Balassa Index.
References
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.
Examples
bi <- balassa_index(world_trade_avg_1998_to_2000)
# partial view of index
n <- seq_len(5)
bi[n, n]
Complexity Measures
Description
complexity_measures()
computes the Economic Complexity
Index and the Product Complexity Index.
Usage
complexity_measures(
balassa_index,
method = "fitness",
iterations = 20,
extremality = 1
)
Arguments
balassa_index |
(Type: matrix) 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 |
Details
The current implementation follows (Mariani et al. 2015) to obtain different alternatives that account for diversification in bipartite relations.
Value
A list of two named numeric vectors.
References
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.
Examples
co <- complexity_measures(economiccomplexity_output$balassa_index)
# partial view of indexes
n <- seq_len(5)
co$complexity_index_country[n]
co$complexity_index_product[n]
Complexity Outlook
Description
complexity_outlook()
computes the Complexity Outlook
Index and the Complexity Outlook Gain.
Usage
complexity_outlook(balassa_index, proximity_product, complexity_index_product)
Arguments
balassa_index |
(Type: matrix) the output from
|
proximity_product |
(Type: matrix) the output from
|
complexity_index_product |
(Type: numeric) the output from
|
Details
The current implementation follows (Hausmann et al. 2014) to measure unexploited export oppportunities.
Value
A list of two named numeric vectors.
References
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.
Examples
co <- complexity_outlook(
economiccomplexity_output$balassa_index,
economiccomplexity_output$proximity$proximity_product,
economiccomplexity_output$complexity_measures$complexity_index_product
)
# partial view of complexity outlook
n <- seq_len(5)
co$complexity_outlook_index[n]
co$complexity_outlook_gain[n, n]
country aggregation
Description
country aggregation
Usage
country_aggregation(dataframe, country = "country", value = "value")
country-product aggregation
Description
country-product aggregation
Usage
country_product_aggregation(
dataframe,
country = "country",
product = "product",
value = "value"
)
Dataframe to matrix
Description
Dataframe to matrix
Usage
dataframe_to_matrix(
dataframe,
country = "country",
product = "product",
value = "value"
)
Density
Description
density()
computes the density matrix that
accounts for the weighted proportions of the products connected to
each good that the countries are exporting.
Usage
density(balassa_index, proximity_product)
Arguments
balassa_index |
(Type: matrix) the output from
|
proximity_product |
(Type: matrix) the output from
|
Details
The current implementation follows (Hausmann et al. 2014) to measure the oppotunities implied by a country's position.
Value
A matrix.
References
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.
Examples
d <- density(
economiccomplexity_output$balassa_index,
economiccomplexity_output$proximity$proximity_product
)
# partial view of the density matrix
n <- seq_len(5)
d[n, n]
Distance
Description
distance()
computes the distance matrix that
accounts for the weighted proportions of the products connected to
each good that the countries are not exporting.
Usage
distance(balassa_index, proximity_product)
Arguments
balassa_index |
(Type: matrix) the output from
|
proximity_product |
(Type: matrix) the output from
|
Details
The current implementation follows (Hausmann et al. 2014) to measure the oppotunities implied by a country's position.
Value
A matrix.
References
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.
Examples
d <- distance(
economiccomplexity_output$balassa_index,
economiccomplexity_output$proximity$proximity_product
)
# partial view of the distance matrix
n <- seq_len(5)
d[n, n]
Example Outputs of the Functions within the Package
Description
List of different computations obtained by using the functions within the package.
Usage
data(economiccomplexity_output)
Format
Lists of vectors, matrices, and graphs.
Examples
data(economiccomplexity_output)
economiccomplexity_output$balassa_index
economiccomplexity_output$complexity_measures$complexity_index_country
Productivity Levels
Description
productivity_levels()
computes EXPY and PRODY measures.
Usage
productivity_levels(
data_exp,
data_gdp,
country = "country",
product = "product",
value = "value"
)
Arguments
data_exp |
(Type: data.frame, matrix or matrix) a dataset containing countries, products and exported values. |
data_gdp |
(Type: data.frame, matrix or matrix) 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 |
Details
The current implementation follows (Hausmann et al. 2005) to obtain the productivity and income levels associated to exports.
Value
A list of two named numeric vectors.
References
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.
Examples
pl <- productivity_levels(
world_trade_avg_1998_to_2000,
world_gdp_avg_1998_to_2000
)
# partial view of productivity levels
n <- seq_len(5)
pl$productivity_level_country[n]
pl$productivity_level_product[n]
Projections of a Country-Product Network
Description
projections()
computes two graphs that are particularly
useful to visualize product-product and country-country similarity.
Usage
projections(
proximity_country,
proximity_product,
avg_links = 5,
tolerance = 0.05,
compute = "both"
)
Arguments
proximity_country |
(Type: matrix) the output from
|
proximity_product |
(Type: matrix) 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
|
Details
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.
Value
A list of two graphs.
References
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.
Examples
net <- projections(
economiccomplexity_output$proximity$proximity_country,
economiccomplexity_output$proximity$proximity_product,
avg_links = 10,
tolerance = 0.1
)
# partial view of projections
n <- seq_len(5)
igraph::E(net$network_country)[n]
igraph::E(net$network_product)[n]
Proximity
Description
proximity()
computes two matrices that account for the
similarity between pairs of countries and pairs of products.
Usage
proximity(balassa_index, compute = "both")
Arguments
balassa_index |
(Type: matrix) the output from
|
compute |
(Type: character) the proximity to compute. By default this is
|
Details
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.
Value
A list of two matrices.
References
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.
Examples
pro <- proximity(economiccomplexity_output$balassa_index)
# partial view of proximity matrices
n <- seq_len(5)
pro$proximity_country[n, n]
pro$proximity_product[n, n]
Revealed Comparative Advantage
Description
balassa_index()
replaces this function
Usage
rca(...)
Arguments
... |
old parameters |
World Trade Per-Capita GDP for the Period 1998-2000
Description
A data frame that summarizes the per-capita GDP of different countries. The unit is year 2000 USD.
Usage
data(world_gdp_avg_1998_to_2000)
Format
A data frame with 240 rows and 2 columns.
Examples
data(world_gdp_avg_1998_to_2000)
head(world_gdp_avg_1998_to_2000)
World Trade Averages for the Period 1998-2000
Description
A data frame that summarizes 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.
Usage
data(world_trade_avg_1998_to_2000)
Format
A data frame with 124,336 rows and 3 columns.
Examples
data(world_trade_avg_1998_to_2000)
head(world_trade_avg_1998_to_2000)