Package 'economiccomplexity'

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

Help Index


Balassa Index

Description

balassa_index() computes the Balassa Index for a bipartite relation between countries and products.

Usage

balassa_index(
  data,
  discrete = TRUE,
  cutoff = 1,
  country = "country",
  product = "product",
  value = "value"
)

Arguments

data

(Type: data.frame, matrix or dgCMatrix) a dataset such as galactic_federation containing countries, products and exported values.

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 TRUE.

cutoff

(Type: numeric) the cutoff to use for discretization. By default this is set to 1.

country

(Type: character) the column with the countries. By default this is set to "country". Used only if the input is a data.frame.

product

(Type: character) the column with the products. By default this is set to "product". Used only if the input is a data.frame.

value

(Type: character) the column with the metric for country-product pairs. By default this is set to "value". Used only if the input is a data.frame.

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
bi[1:5, 1:5]

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: dgCMatrix) the output from balassa_index()) or an equivalent arrangement.

method

(Type: character) one of these methods: fitness, reflections or eigenvalues. By default this is set to "fitness".

iterations

(Type: numeric) the number of iterations to use. By default this is set to 20.

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 1.

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
co$complexity_index_country[1:5]
co$complexity_index_product[1:5]

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: dgCMatrix) the output from balassa_index()) or an equivalent arrangement.

proximity_product

(Type: dgCMatrix) the output from proximity()) or an equivalent arrangement.

complexity_index_product

(Type: numeric) the output from complexity_measures()) or an equivalent arrangement.

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
co$complexity_outlook_index[1:5]
co$complexity_outlook_gain[1:5, 1:5]

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: dgCMatrix) the output from balassa_index()) or an equivalent arrangement.

proximity_product

(Type: dgCMatrix) the output from proximity()) or an equivalent arrangement.

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
d[1:5, 1:5]

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: dgCMatrix) the output from balassa_index()) or an equivalent arrangement.

proximity_product

(Type: dgCMatrix) the output from proximity()) or an equivalent arrangement.

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
d[1:5, 1:5]

Example outputs of the functions within the package

Description

List of different computations obtained by using the functions within the package

Usage

economiccomplexity_output

Format

Lists of vectors, matrices and graphs.

Examples

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 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 "country". Used only if the input is a data.frame.

product

(Type: character) the column with the products. By default this is set to "product". Used only if the input is a data.frame.

value

(Type: character) the column with the metric for country-product pairs. By default this is set to "value". Used only if the input is a data.frame.

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
pl$productivity_level_country[1:5]
pl$productivity_level_product[1:5]

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: dgCMatrix) the output from proximity()) or an equivalent arrangement.

proximity_product

(Type: dgCMatrix) the output from proximity()) or an equivalent arrangement.

avg_links

average number of connections for the projections. By default this is set to 5.

tolerance

tolerance for proximity variation on each iteration until obtaining the desired average number of connections. By default this is set to 0.05.

compute

(Type: character) the proximity to compute. By default this is "both" (both projections) but it can also be "country" or "product".

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
igraph::E(net$network_country)[1:5]
igraph::E(net$network_product)[1:5]

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: dgCMatrix) the output from balassa_index()) or an equivalent arrangement.

compute

(Type: character) the proximity to compute. By default this is "both" (both proximity matrices) but it can also be "country" or "product".

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
pro$proximity_country[1:5, 1:5]
pro$proximity_product[1:5, 1:5]

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 summarises the per-capita GDP of different countries. The unit is year 2000 USD.

Usage

world_gdp_avg_1998_to_2000

Format

A data frame with 240 rows and 2 columns.

Examples

world_gdp_avg_1998_to_2000

World Trade Averages for the Period 1998-2000

Description

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.

Usage

world_trade_avg_1998_to_2000

Format

A data frame with 124,336 rows and 3 columns.

Examples

world_trade_avg_1998_to_2000