Main Functions

This page documents the main functions available in GravityGE.jl.

All Main Functions

The core gravity model implementation with general equilibrium effects.

GravityGE.gravityGEMethod
gravityGE(
    trade_data::DataFrame;
    theta=4.0,
    beta_hat_name=nothing,
    a_hat_name=nothing,
    multiplicative=false,
    tol = 1e-8,
    max_iter = 1_000_000,
    crit = 1.0
)

Solve a one-sector Armington-CES gravity model with general equilibrium closure.

Arguments

  • trade_data::DataFrame: A DataFrame containing trade flows and (optionally) trade frictions and productivity. It must contain the columns "orig", "dest", and "flow".
  • theta::Float64=4.0: Trade elasticity parameter.
  • beta_hat_name::Union{Nothing,String}: (Optional) Column name for bilateral trade frictions in log form. Should be zero on the diagonal.
  • a_hat_name::Union{Nothing,String}: (Optional) Column name for log productivity. Must be positive and match regions along the diagonal.
  • multiplicative::Bool=false: If true, assumes a multiplicative GE closure; otherwise, uses an additive closure.
  • tol::Float64=1e-8: Convergence tolerance.
  • max_iter::Int=1_000_000: Maximum number of iterations for convergence
  • crit::Float64=1.0: Initial convergence criterion.

Returns

A Dict with two elements:

  • :new_trade – a DataFrame with updated bilateral trade flows.
  • :new_welfare – a DataFrame with welfare, nominal wages, and price indexes by region.

Example:

`julia using DataFrames, GravityGE

flows = DataFrame( orig=repeat(string.('A':'Z'), inner=26), dest=repeat(string.('A':'Z'), outer=26), flow=ones(26^2) )

# No change: additive
out = gravityGE(flows; theta=4.0)

`

source