This repository provides a tool for analyzing trade flows using Gravity Models and Artificial Neural Networks (ANNs) in wood markets. It supports flexible configuration, allowing users to customize input parameters, data selection, and model settings.
This code was developed and tested using Python 3.12.6. To ensure compatibility and reproducibility, it is recommended to use this version.
To set up the project, follow these steps:
-
Clone the repository:
git clone https://github.com/ChristianMorland/trade-model-validation
-
Create a virtual environment:
py -3.12 -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate -
Install required dependencies:
pip install -r requirements.txt
You can customize the program's behavior using the following input parameters:
input_file: Path to the folder containing the input data.
gravity_output_folder: Folder to save outputs of the Gravity Models.
ann_output_folder: Folder to save outputs of the ANN models.
model_analytics_folder: Folder for saving descriptive analytics.
commodity_id: Specific commodity ID to analyze.
traditional_gravity_model: Set to True to apply only the traditional Gravity Model.
two_way_fix_effects_estimation: Set to True to apply Gravity Models with two-way fixed effects.
show_plots: Set to True to display plots during execution.
loop_over_commodities: Set to True to loop through all commodity groups (overwrites commodity_id).
loop_over_batches: Set to True to repeat the analysis multiple times for validation.
number_of_batches: Number of batches for repeated analysis.
random_state: Random seed for reproducibility. If looping over batches, the batch number is used as the seed.
min_year: Minimum year of data to include in the analysis.
max_year: Maximum year of data to include in the analysis.
rhs_list: List of independent variables to use.
grid_search: Set to True to perform a grid search for hyperparameter optimization.
TEST_SIZE: Proportion of data to allocate for the test set.
VAL_SIZE: Proportion of data to allocate for the validation set.
NEURONS_PER_LAYER: Number of nodes in each layer of the ANN.
NUMBER_OF_LAYER: Number of layers in the ANN.
ACTIVATION: Activation function for the ANN (e.g., ReLU, sigmoid).
EPOCH: Number of training epochs for the ANN.
Configure the input parameters in your script or a configuration file.
Run the program with the desired settings to analyze trade flows and generate outputs for Gravity Models and ANNs.