Food and nutrition security under global trade: a relation-driven agent-based global trade model

This paper addresses the highly relevant and timely issues of global trade and food security by developing an empirically grounded, relation-driven agent-based global trade model. Contrary to most price-driven trade models in the literature, the relation-driven agent-based global trade model focuses on the role of relational factors such as trust, familiarity, trade history and conflicts in countries' trade behaviour. Moreover, the global trade model is linked to a comprehensive nutrition formula to investigate the impact of trade on food and nutrition security, including macro and micronutrients. Preliminary results show that global trade improves the food and nutrition security of countries in Africa, Asia and Latin America. Trade also promotes a healthier and more balanced diet, as countries have access to an increased variety of food. The effect of trade in enhancing nutrition security, with an adequate supply of macro and micronutrients, is universal across nutrients and countries. As researchers call for a holistic and multifactorial approach to food security and climate change (Hammond and Dubé 2012 Proc. Natl Acad. Sci. USA 109, 12 356–12 363. (doi:10.1073/pnas.0913003109)), the paper is one of the first to develop an integrated framework that consists of socio-economic, geopolitical, nutrition, environmental and agri-food systems to tackle these global challenges. Given the ongoing events of Brexit, the US–China trade war and the global COVID-19 pandemic, the paper will provide valuable insights on the role of trade in improving the food and nutrition security across countries.


Background
In 2019, 821.6 million people in the world are hungry and 2 billion people (26.4% of the world's population) are food and nutrition insecure, who lack access to safe, sufficient and nutritious food, according to the State of Food Security and Nutrition [1]. Despite great progress in agri-technology in the last century, hunger is increasing in poor countries, especially during economic slowdowns and downturns. In addition to the degradation of ecosystems and more frequent crop failures due to climate change [2], recent trade disputes and conflicts among countries, and the outbreak of the COVID-19 pandemic have all posed threat to global food supply and food security [3]. As a result, the world is struggling to meet the WHO nutrition target by 2025 or the UN sustainable development goal's nutrition target by 2030.
Food production and supply concerns more than the agri-food systems. They are deeply coupled with the social, economic and geopolitical systems at both local and global scales. Using a large-scale simulation model of land-use change, Brown et al. [4] show that social and behavioural factors can drastically change local land use and cause severe food shortages of up to 56% without climatic disturbances. Hammond and Dubé [5] argue that food and nutrition security is driven by complex underlying systems at both local and regional/global scales. The authors call for a systems approach using transdisciplinary modelling tools such as system dynamics and agent-based modelling.
One important mechanism for food allocation is via trade. In 2013, about 23% of the food produced for human consumption was traded internationally [6], which feeds 2-3 billion people globally and uses 13% of worldwide cropland and pasture [7,8] and the proportion continues to grow annually. As globalization deepens, spatially distant countries become increasingly connected by trade, and so are their agri-food systems, a phenomenon called 'telecoupling'. For example, Challies et al. [9] show how surging pork demand in Germany caused large-scale deforestation in Brazil, as the latter is a major supplier of soya beans, which are used as pig feed in Germany [9]. Similarly, Fuchs et al. [3] discuss how the recent US-China trade war can cause large-scale deforestation in the Amazon, as China switched to Brazil for soya imports. Disputes and conflicts between any two countries can thus lead to a serious disturbance to global trade and food security.

Price versus relation-driven trade models
Conventional trade models are based on the general equilibrium (GE) theory in economics, where trade volumes are expressed as mathematical equations of commodity prices. Solutions to the equations are found (analytically or numerically) by adjusting the prices so that supply equals demand (market clearing) in every sector. One of the common methods to derive numerical solutions is computable general equilibrium (CGE), which is used in models such as global trade analysis project (GTAP) [10]. CGE trade models have been used to evaluate the impact of trade policies such as tariffs and trade liberalization (e.g. [11]). Apart from GE models, partial equilibrium (PE) models are also developed for the agricultural sector, upon which integrated assessment models such as common agricultural policy regionalized impact model (CAPRI) [12] are based. Both CGE and PE models are built upon the key assumptions of equilibrium, price elasticities and the market-clearing condition. However, these theoretical frameworks offer limited possibilities for rigorous testing against historical data and experience [13].
The gravity model of trade, on the other hand, takes an empirical approach, which assumes that trade volume between two countries is proportional to the GDP of the two countries and disproportional to their geographic distance [14,15]. The model has since become one of the most successful empirical models in economics [16,17]. A price mechanism and market clearing, which are central in CGE and most macroeconomic trade theories, are not part of the gravity trade model. There is thus a gap between CGE model, which is based on theory but lacks predictive power, and the gravity model, which has predictive power but lacks theoretical underpinning.
What conventional price-driven trade models like CGE do not consider is other relational factors such as trust, familiarity, conflicts and competition in a trade relationship. For example, evidence shows that countries that share culture, language, religion and institutional structure trade more even after controlling for geographic distance and GDP [18][19][20][21][22][23][24][25]. Trust and familiarity play an important role in trade relationships. Using trade data of 25 countries, Den Butter and Mosch [26] show that trust explains a large fraction of trade volume between any two countries by reducing transaction costs. Deardorff [27] argues that increasing trust and reducing unfamiliarity is crucial in establishing new royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 trade relationships, especially for countries culturally high in uncertainty aversion. Huang [28] shows empirically that transport cost is not the only reason that distant countries trade less. Countries trade also less because they have never traded before and are thus unfamiliar with each other.
For perishable goods such as food and agricultural products, trust, reputation and previous trade relationship is particularly important. Because the conditions of perishable goods are hard to enforce by contract compared with manufactured goods, importers and exporters rely on mutual trust and repeated transactions to assure contractual performance. Macchiavello and Morjaria [29] show the value of long-term relationships based on trust and reputation in rose exports in Kenya. They find that when supply disturbances occur, exporters have incentives to prioritize delivery to buyers with whom they have traded before to protect their reputation. Similarly, research has found that trust, reputation and a previous trade relationship are particularly important for perishable and nonenforceable goods such as foods and agricultural products [30,31].
Trade can also be driven by geopolitical conflicts and competition among countries. For example, China's decision to buy soya from Brazil and not the US is driven by its relationship with the US rather than any 'rational' economic factors. Similarly, Brazil uses soya bean exports to secure land ownership in neighbouring countries, particularly Paraguay and Bolivia, extend political influence in Africa and balance trade with China [32]. Countries may also engage in (irrational) competition with each other for essential foods, especially in a crisis. Timmer [33] shows how, in the 2008 rice crises, countries in Southeast Asia competed to secure rice by hoarding and banning exports, causing spikes in rice price far exceeding what classic economic theory would suggest based on the initial (moderate) fall in supply. Timmer [34] concludes that complex human behaviours, such as loss aversion, time inconsistency and herd behaviour can present significant challenges to a traditional 'economic optimization' approach to trade.
In summary, existing price-driven global trade models are insufficient to fully capture trade relationships among countries. Relational factors such as trust, familiarity, conflicts and competition are just as important. When trust and a previous trade relationship is needed for trade to happen, countries will miss potential trade opportunities if they don't have trust between them [26], leaving the market to not clear in reality. We thus need a relation-driven approach to global trade to complement the price-driven one, which this paper will develop.

Countries as agents
Although trade activities are carried out by individual firms, most economic global trade models such as CGE and gravity models treat countries as the entity of trade. Similarly, many agent-based models (ABMs) of trade and international relations also treat countries as encapsulated agents that interact with each other [22,35,36]. In fact, the question 'what constitutes an agent' remains open in the ABM community. Macal and North [37] summarize four properties most 'agents' in ABM have: (i) autonomy (function independently in their environment), (ii) modularity (identifiable, discrete entity), (iii) sociality (interact with other agents), and (iv) conditionality (have a state that varies over time). Entities that meet the above four criteria have been represented as agents in the ABM literature, ranging from a biological cell to a person to an organization to a country.
Conceptually, it is appropriate to treat countries as agents if the model aims to study country-wise trade relationships, because a country makes decisions on national trade policies and positions, and behaves as a single entity as it sets up trade barriers, joins trade agreements and engages in trade wars [34,35]. Moreover, a country shares common attributes such as GDP per capita, institutional structure, languages and culture, so it can be treated as a single agent when researchers look at the role of these attributes in trade [22,23]. On the other hand, treating countries as a single unit misses the complex behaviour of and interactions between individual firms that carry out the actual trade. Treating countries as agents also miss the internal trade flows between regions in a country. Hence more other studies have been using firm-level and/or regional-level data to study heterogeneous firm behaviour in trade (e.g. [29]) and intra-national trade (e.g. [38]).
Practically, however, most global trade data are available at the country level, including the ones from the UN and OECD, which we use in this study. Although some advanced countries have much more detailed trade data at the regional level, such segregated data are not available for all countries in the world, especially the lower income ones that are more prone to food insecurity. Even more scarce are firm-level transaction data, which are often exclusive, almost always incomplete and vary greatly by countries and sectors. The lack and incompleteness of empirical data at lower than the country level severely restricts the types of empirically grounded agent-based model researchers can develop, royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587

Methods
This paper describes the development of an empirical agent-based model of global food trade to study the impact of trade and climate change on food and nutrition security of countries across the world. The empirical agent-based model is implemented in NetLogo [49]. In this section, we will follow the guidelines of Grimm et al.'s overview, design concepts and details (ODD) protocol [50,51] to describe the model.

Purpose
The purpose of the model is to study the impact of global food trade on food and nutrition security in countries around the world. It will incorporate three main aspects of trade between countries, including a country's wealth, geographic location and its trade relationships with other countries (past and ongoing), and will be used to study food and nutrition security across countries in various scenarios, such as climate change, sustainable intensification, waste reduction and dietary change. As previously discussed, for both conceptual and practical reasons, we choose to represent countries as agents, which we believe is the most suitable for the study and the research questions we will address, as well as the most practical given the data and computational constraints. Each country in the model has a list of attributes (table 1), including geographic location, population size, GDP, production of (multidimensional) food commodities, the country's historic trade relationships with other countries and so on. We include the 165 countries in the world for which complete data of the food supply from the FAO food balance sheet are available. The model is spatially explicit in that the countries are represented spatially at a global scale.
The activities country agents engage in are the production, trade and food intake, which is a multidimensional variable consisting of 91 food commodities, consistent with those used in FAO food balance sheets (FBS) (see §2.4.3). The production of food commodities in each country is exogenous and changes every year depending on the scenarios. Once the production for the year is revealed or completed, countries trade with each other if they have unfulfilled domestic demand or unconsumed domestic supply. A country's food supply is then a combined outcome of its domestic production and trade with other countries. We do not consider inequalities within a country in access to food, which can be great in some countries. In this study, we focus on the average food intake per capita, which we use to compare with food requirement per capita, as an indicator of a country's food and nutrition security. Indicators of country-specific inequality (such as the GINI index) can be built into the model later on, which is beyond the scope of this study. Table 1 lists selected attributes of a country agent.

Trade intermediary
For a given commodity, an intermediary country is one that imports food for the purpose of re-exporting. As discussed before, intermediary countries are important facilitators of trade. In the model, we define a country as an intermediary for the commodity if the total export of the commodity is more than 80% of the total import (i.e. the majority of import is for re-exporting) in 2000, the baseline year. The motivation and trade behaviour of an intermediary country will be different from other non-intermediary countries that import for domestic consumption.

Typical diet
We use the term 'diet' in the paper, but this is based on the national supply of food taken from the FAO food balance sheets (FBS), adjusted by the proportion that is inedible (e.g. banana peels) and wasted, which differs by region. Typical diet varies across countries and reflects a country's tradition and culture, as well as their natural and land-use conditions. When considering nutrient sufficiency and dietary change, we need to make sure that we do not naively prescribe countries an 'ideal diet' (nutritionally adequate) that is unrealistic to implement. In the model, we use the average reported food consumption between 2000 and 2002 (to smooth out fluctuations in any one year) as the baseline for each country's typical diet. The food composition in the typical diet changes every year in proportion to global food production and supply, to reflect the fact that the diet of people changes gradually (not drastically) over time. We assume that a country will aim to obtain the typical diet for its population in the current year; it will import a food commodity if it produces less domestically than is needed in the typical diet and export if it produces more. Some countries may fail to feed their populations with the typical diet; nor does a country's typical diet necessarily guarantee nutrient sufficiency, which reflects the situations in reality.

Fortification
In some countries where wheat is refined and stripped of fibre and micronutrients, the flour and refined cereals are fortified replacing some of the micronutrients. The most commonly fortified food is wheat (flour) [53]. Hence, when calculating nutrient supply for each country, we need to adjust for the nutrient content of wheat in each country depending on if it is refined or not, then if the refined flour is fortified. This varies by the income of countries, with higher income countries more commonly refining than fortifying with micronutrients. The level of fortification also varies by country. The refined flour and royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 Food waste up to the point of the household is accounted for in the FBS, but not waste generated in the household, after production and trade where a certain percentage of food will be wasted. Not accounting for household waste will lead to an overestimation of nutritional intake based on food consumption. The amount of food wasted depends on the type of food and the countries and regions. Generally speaking, countries and regions that are wealthier waste more food at the household level. Note that household waste does not include the part of food that is inedible, such as banana peel, which has already been accounted for in the nutrient calculation. Table 2 shows the percentage of food waste, based on food that could have been eaten, in household consumption by region and food type, which is estimated in Gustavsson et al. [52].

Nutrient requirements
Because people in different gender-age groups have different nutritional needs, the population-level nutrient requirement per person in a country is based on the demographic composition of its population. Countries with a larger young adult and male population will have a higher nutrient requirement than those with an ageing population. The demographic composition of a country will change over time, and so will the population-level nutrient requirement. An adequate energy intake was estimated using population-weighted average dietary energy requirements (ADERs), calculated using data for each age and sex with assumptions of physical activity level (PAL) being 1.75 and BMI being 21 kg m −2 for adults. The population-level nutrient requirement of a country will be compared with the nutrient supply in the country in any given year to determine a country's level of nutrient sufficiency. The nutrient requirements are from the WHO [55,56].  North America, Oceania

Trade relationships between countries
As previously said, the trade model will be relation-driven, which means that trade decisions will depend on previous bilateral trade relationships between countries as they engage in trade repeatedly over time, in addition to their geographic location and ability to pay. We assume countries rank each other with different trade priorities to determine whom to trade with (assuming there are multiple competing buyers or sellers). Trade priority will depend on four elements: (i) GDP per capita, (ii) geographic distance, (iii) historic trade relationship, and (iv) emergent trade relationship. The first element, GDP per capita, serves as a proxy for a country's ability to pay for a commodity. Priority is given to countries with a higher GDP per capita or high ability to pay. The second element, geographic distance between the two trading countries, is an important factor in predicting trade volumes: countries close to each other tend to trade more. One reason is the lower transport cost. Another reason is that countries close to each other are also more familiar with each other, and more likely to have a similar culture, customs and languages, all of which facilitate trade [28].
The third element, historic trade relationship, is measured by trade volume of all commodities in the year 2000. We use trade volume as an indicator of the existing trade relationships established between the two countries. As research has shown, countries that are more familiar with each other (via common language, religion, institutional structure and other social and cultural characteristics) trade more often [19,20,57]. While geographic proximity is one cause for enhanced familiarity and trust between countries, there are other non-geographic factors, such as historic connections (e.g. former colony, commonwealth) [58] and international organizations or trade unions (e.g. OECD, EEA, Trans-Pacific Partnership), that could cause some countries to have closer connections and thus trade more. Historic trade volume will reflect these non-GDP and non-geographic factors. We distinguish trade volumes by exports and imports because they represent different roles in trade relationships.
The last element, emergent trade relationship, allows new trade to emerge endogenously and to influence subsequent trade development in a path-dependent way. While the first three elements are exogenous to the model and deterministic, the last element is endogenous and stochastic. Trade relationship that evolved from the model has an impact on future trade decisions. Two countries low on each other's trade priority (due to low GDP per capita, long geographic distance or few trade records before) can start a new trade relationship in a year when they fail to trade with their usual partners (e.g. due to crop failure or market disturbances). Such an 'incidental' new trade between the two countries will increase their ranks in each other's trade priority, which will in turn increase the chances that they trade again in the future.
The trade priority (for importing and exporting partners) assigned by countries to one another is a weighted average of the four elements above. The weights are calibrated using actual trade and consumption data. We allow the weight to be zero in the search space, so that if any of the above elements do not have a significant impact on trade patterns in the empirical data, it will not have an effect in the model either. Although the second and third elements may be correlated (e.g. many countries that trade often are also geographically close), they do not coincide. For example, countries that have developed historical trade links may not be geographically close, such as the commonwealth countries; on the other hand, geographically close countries may not trade as much, such as the US and Cuba. Hence, we should still be able to distinguish the effect of the four elements when calibrating the weights for the elements using empirical data.
In this model, we do not try to emulate price dynamics or predict future prices. Although prices are not explicitly modelled, the price mechanism to allocate commodities among countries will be partially incorporated in the ranking and matching process of trade partners through countries' GDP per capita, geographic location, production, consumption and dietary preferences. A country's GDP per capita and dietary preference determine its purchasing power and willingness to pay for a product. Moreover, a country's production reflects its overall productivity and production costs of the food; its consumption reveals a country's budget, dietary habits and preferences; its location is a proxy for transportation costs. Therefore, although the model does not include the price mechanism directly, it does implicitly incorporate the information that prices contain. Table 3 shows the attributes of the trade relationship class.

Food and nutrients
As was discussed before, we must look at a more comprehensive food list than a few major crops to gain a better understanding of the nutrient sufficiency, especially micronutrient sufficiency across countries. In The mapping of food to nutrients is based on data from the GENuS project [59]. For a detailed description of the methodology see [46]. Each of the 91 food categories, which are made up of many food items, was disaggregated to individual food items. Each food commodity was then mapped to the nutrient composition. A weighted mean of the nutrient composition for the food items was used when the data were aggregated back to the food commodity groups. This was based on the global production of each food item within that group (FAO production data). If there were no production data for food items in a food commodity, an unweighted average was used. The nutrient data came primarily from the USDA food composition data. 2 If any food item was not in the USDA tables, the composition was taken from other regional food composition tables. In this study, we exclude the nutrients for which the mapping involves large uncertainties, leaving the following: calories (energy, kcal), protein, fat, vitamin C, vitamin A, folate, calcium, iron, zinc, dietary fibre, thiamin, riboflavin, niacin, vitamin B6 and saturated fat.

Process overview and scheduling
Each step in the simulation represents a year in real time. We choose an annual time step because it is appropriate for the production cycle and the time-scale of the model , and also because data on trade, production, GDP and population are only available annually. The starting year of the model was 2000, which is also the baseline year.
At the beginning of each year, countries receive the production of all food from last year, which is the amount available for domestic consumption and trade. If a country has produced more than it needs for domestic consumption of the typical diet, it will try to export the excess; if a country has produced less than it needs for domestic consumption, it will try to import the deficiency. Also, if a country is an intermediary of a food commodity, it will want to import food for re-export, even though it may have a sufficient amount for domestic consumption.
After countries decide on their trade positions (whether to import or export, and the amount to import or export), they will start looking for trade partners. Importers will first send buying offers to potential exporters. If there are multiple exporters of the food on the market, importers will send the offer to the country with the highest trade priority on their lists (see §2.2.2). After importers have sent offers, exporters will decide to whom they will sell their commodity, if they receive multiple buying offers. Similarly, exporters will evaluate importers' priorities and sell only to the ones with the highest priority until all the available food for export is sold. Importers whose buying offers are not satisfied in this round will repeat the same process in the next round until their import demand is satisfied or there is nothing left to buy. To prevent some large countries with high demand from flooding and royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 dominating the market, we limit each trade transaction to a maximum amount, so that smaller countries can compete with larger countries. We emphasize that it is not the maximum amount a country can trade in each commodity in total; it is the maximum amount a country can trade in each commodity per round, and the trade of a commodity can take several rounds (on average 5-20) to finish (figure 1). Hence, countries with a large demand will try to buy again in subsequent rounds until their demand is fulfilled. We have conducted a sensitivity analysis using different values for the maximum amount per round, and the results are not sensitive to the parameter.
It will take several rounds for the market to clear and all the trade opportunities are realized, depending on the total trade volume and the matching process. The same process will then repeat for the next food commodity until all food categories have been traded. For simplicity, we assume that the trading outcome of one food category does not affect that of the other. Figure 1 illustrates the ranking and matching process of trade among countries.
One important factor in the model is trade saturation, which is the rate between realized and maximum trade amounts. Trade saturation ranges from 0% to 100%, which we vary in the computer experiments. When trade saturation is 100%, all trade opportunities are realized. Countries will keep trading until either there are no more importers with remaining demand or exporters with remaining supply. There will be no missed trading opportunities, which can be regarded as an ideal case. When trade saturation is less than 100%, not all potential trade opportunities are realized. Countries at the bottom of the trade priority may not be able to trade, even though there are outstanding buyers and sellers of the same commodity. This 'less than ideal' case may be closer to reality, as factors such as to risk avoidance, market failure, lack of time (for perishable food), lack of information, communication or facilitators can prevent potential trade opportunities from being realized. The higher the trade saturation, the higher percentage of trade opportunities are realized. Later we examine the impact of trade saturation on food and nutrient security across countries.

Design concepts 2.4.1. Interaction
The countries interact with each other via trade. Links and connections are created between countries when one offers to buy from or sell to another. A country's decision to trade with another does not only affect the two countries involved in the trade, but it also indirectly affects other countries because once the food commodity has been traded, there will be less available on the market. Countries also interact with each other via their rankings of each other on trade priority. Their past interactions (trade) with other countries will influence the ranking as familiarity increases, which will in turn affect the way they interact/trade with others in the future.

Emergence
Trade relationships can emerge through repeated interactions among countries. Countries who have never traded before (and thus are low on each other's trade priority) can start a trade relationship by chance, for example, due to the lack of available trade partners at the time. The trade experience will then encourage the countries to trade more with each other in the future, thus the emergence of new trade relationships. The nutrients available per capita in each country emerge from the trade.

Stochasticity
The main source of randomness in the model comes from the matching of trade partners: the sequence of the countries matters when they send each other a buying offer. The random sequence of agents to execute functions is internal in NetLogo. To account for that internal stochasticity, we run the model 30 times for each parameter combination and look at the variance in results. As we can see in tables 15 to 21 in the Appendix, the variances caused by the internal stochasticity are very small. Apart from that, the model is data-driven and has not drawn other random parameters from distributions.

Initialization and data
The initialization of the model is based on empirical data or estimates from existing research. The 165 countries are created with initial GDP, population, production, food consumption using the average value of the years 2000, 2001 and 2002 in FAO's FBS data to smooth out any anomalies in any particular year. The past trade relationship is derived from FAO's trade data of all commodities. The geographic location and area of countries are initialized using a GIS world map. The regions and subregions to which countries belong are according to UN categorization and consistent with Müller et al. [44]. The typical diet for each country is initialized as the food consumption in 2000 from FBS. The income categories and the corresponding fortification type is derived from The World Bank and Food Fortification Initiative, respectively. The avoidable waste rate is initialized using estimates from estimation in Gustavsson et al. [52].

Input data
The current model runs from 2000 to 2013. Each year is input from data from FAO to update the GDP, population and production for all countries. The FAO FBS data is available until 2013. Table 4 shows the royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 input data for model running from 2000 to 2013. For scenario analysis in the future, the model will use projected data for production, GDP and population between 2014 and 2050.

Calibration
The parameters to be calibrated are the weights given to each of the four elements (GDP per capita, distance, historic and emergent trade relationships) in the countries' evaluation of trade partner priorities, which cannot be observed in empirical data. Because the ranking of countries is relative, we lose one degree of freedom, and hence we fix the weight for distance at 1 and allow the other three parameters to vary. The sampling of the parameters is twofold: first, we draw a sample of 10 000 random parameters from a three-dimensional Latin hypercube sampling ranging between 0 and 1; second, we transform the random sample using an exponential transformation to account for the ratio relationships (i.e. relative importance) between the weights, so that the parameters range from 0.05 to 20. In other words, relative to distance (which has a fixed weight 1), the weight for the other parameters range from 0.05 (1/20 as important) to 20 (20 times as important).
We then run the model on the 10 000 sampled parameter combinations. The empirical data we use for calibration and validation is FAO FBS on import and export volume and food consumption, and trade data from the United Nation Comtrade Database. 3 The data for validation and calibration is available The evaluation of the model results is based on two dimensions: trade volume and trade partners. Trade volume compares the actual import, export and food consumption (in FAO FBS) in each country with the simulated results from the model. Because the simulated figures will almost surely not be the same as the observed ones (factors unaccounted for in the model, factors unobserved, errors in model specification, errors in input data, errors in empirical/validation data), we use a threshold to determine 'match': if the simulated volume is within ±20% of the actual volume (of import, export and food in each country), it is regarded as a match. The first dimension, trade volume, measures the percentage of simulated trade volumes (import, export, food) that falls within the range of the actual volume between 2001 and 2007.
The second dimension, trade partners, compares the actual bilateral trade between two countries in each food category with the simulated ones. If for a specific food category, the importer and exporter in the empirical data match that in the simulated data (regardless of trade volume), it is marked as a match. The trade partner index is the percentage of simulated trade records that matches the actual one of all trade records between 2001 and 2007. Because the FAO trade data does not contain information on bilateral trade partners or is not commodity-specific, we use the Comtrade data from the United Nations to calibrate and validate the bilateral trade results. The Comtrade data, however, does not cover all food categories in FAO. Of the 91 food categories, 42 are available in the Comtrade data.
To account for internal stochasticity, we run the model 30 times for each parameter combination and calculate the average matching rate. Figure 2 shows the 10 000 parameter combinations (consisting of three weights) plotted by the two evaluation dimensions: average matching rate for trade volume and trade partners. The higher the matching rate in each dimension, the better the model with that parameter combination performs. Tables 13 and 14 in Appendix show a small subset or example of the simulated trade volume and partners from the calibrated model (versus actual data), which we  Figure 2 shows the Pareto front (the red line connecting the points) of the parameter combinations. The Pareto front represents the set of optimal parameters in that the model performance cannot be improved on one dimension without lowering the performance on the other dimension. There are 10 points on the Pareto front, as shown (in red and green) in figure 2. There is a big gap in the graph, which shows that a group of parameter combinations (those to the right of the gap) does significantly better in matching trade volumes than the rest. The data used to generate the graph, i.e. the mean match rate of trade partners and trade volumes for all 10 000 parameter combinations is available in the electronic supplementary material, data.
By definition, all the points on the Pareto front are incomparable and can only be partially ordered. Since we value the two performance dimensions equally, we would like to choose a parameter combination that does relatively well in both dimensions. We then calculate the average of the two dimensions (i.e. give equal weight to each) and pick the point with the highest average (in green in figure 2), which will be the parameters for the calibrated ABM. The calibrated values of the weight for GDP, distance (fixed at 1 as the bench market), historic and emergent trade (in trade priority evaluation) are listed in table 5. We see that GDP and Historic trade have higher weights than distance and emergent trade, indicating a relatively bigger influence in countries' ranking of trade partners. However, the other two elements are also significantly different from zero, which means they also play a role. There are two caveats concerning the validation method. First, the parameters are the same for all countries (lack of parametrization per country). Second, there are potential although not linear correlations between the four elements in the ranking of trade partners as discussed in §2.2.2. However, they are not an issue for the study, which includes the prediction trade volumes among countries based on their trade relationships.

Discussion on calibration and validation
To save space, the validation results are presented in appendix A.1. Overall, we find that the model has a better predictive power for trade partners than trade volumes, which is unsurprising partly because the calibrated parameters are in the functions of countries to rank and match trade partners. Moreover, the errors in input data for the volume of trade are likely to be larger than that for trade partners. As a result, we expect the validation results for volume to be less accurate than that for trade partners. We also find   (2000), and the years on which is it calibrated (2001-2007), we expect its predictive power to go down, and the variances among parallel models to go up as the effects of stochasticity and random events from previous periods accumulate over time (i.e. being path-dependent). While using empirical data to initialize, input, calibrate and validate the global trade model, we notice that the data availability varies greatly across countries, and it is the dataset available to all countries (the common denominator) that determines the data the model can use for input and validation. While some countries (e.g. UK, US) have more detailed or accurate data for trade and nutritional intake, the same data is not available for all countries, especially some countries in Africa, which largely restricts the data available for the global ABM. In some models, the problem is mitigated by grouping countries into regions and sub-regions, so missing data for some countries do not necessarily cause issues in the aggregated models. In ABM, however, because individual countries are modelled on their own, there is a higher demand for the same type of data with the same content, quality and format to be available for all countries. We identify the issue of data inequality across countries as one of the challenges in building an empirically grounded global ABM.
Finally, we find that a Pareto front can be a useful visual tool to show and compare the performance of models when the evaluation criteria are multi-dimensional. Not only can it identify a set of models with the 'best' performance ( partially ordered), it can also reveal patterns of model performance in the evaluation space, especially when the number of candidate models is large. In this study, we select a model on the Pareto front by giving equal weights to the two evaluation criteria and pick the one with the highest weighted average. In the future, more sophisticated methods can be developed to select a model in the Pareto set; or one can include all models in the Pareto set and develop predictions based on multiple Pareto models, based on which new approaches can be developed towards model optimization, selection and prediction, which we leave for future research.

The impact of trade on macro and micronutrient sufficiency in 2015
In this section, we show preliminary results on the impact of trade (saturation) on micro and macronutrient sufficiency. For each nutrient, we will compare the nutrition security of countries when trade saturation is low (60%, i.e. 60% of all potential trade opportunities are realized), medium (80%, i.e. 80% of all potential trade opportunities are realized) and high (100%, i.e. all potential trade opportunities are realized). Trade saturation is an exogenous intervention parameter that we will vary in the experiment. In reality, trade saturation can be influenced by countries' trade policies, trade conflicts and other factors such as a global pandemic. We will vary the level of trade saturation by low, medium and high in the computer experiment and study its impact on trade and food security.
As we discussed before in §2.2.1, the population-level nutrient intake (average per person) is calculated based on food consumption after production and trade, which we compare with nutrient requirement (average per person), which is based on the demographic compositions (age and sex) and varies across countries. If a country's average nutrient intake per person is higher than its average nutrient requirement per person, the country is considered secure in the specific nutrient, and vice versa.
For all graphs in this section except for 'fat', countries that are nutrient secure are in blue, and countries that are nutrient insecure are in red. Grading with the colours illustrates how far the country is from achieving nutrition security. The darker the shade of blue, the more secure the country is in that nutrient (intake ≫ maximum recommendation) and the darker the shade of red, the more insecure the country is in that nutrient (intake ≪ lower recommendation). For the nutrient 'fat', because the recommendation is within a range, there is a lower and upper limit (too little and too much fat can be can have negative health consequences), we use three colour schemes to show fat: red for below the lower recommendation, green for healthy, and yellow for over-consumption. In this section, we show the nutrient sufficiency in 2015 under low, medium and high trade saturations for calories, fat, vitamin A, iron and zinc, the latter three are important micronutrients, and in the Appendix, we will show that for folate, niacin, riboflavin, thiamine and vitamin C (figures [8][9][10][11][12]. Figure 3 shows the impact of trade on the consumption of calories. We see that with low to medium trade saturation, a handful of countries in Africa, Asia and South America will suffer from the lack of calories (or energy). The problem, however, can be solved by increasing trade saturation to 100%, royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 meaning that the world can produce food to feed the population with enough calories, as long as all trade opportunities are realized. Figure 4 shows the impact of trade on the consumption of fat. We see that sufficient trade not only increases fat intake to within the healthy range in some countries in Africa, Asia and South America, and it also brings the fat intake down for some countries (e.g. Russia, Southeast Asian countries) and makes them healthier. The reasons that countries reduce fat intake when the trade is fully realized is that trade allows them to access a more diverse diet from a global supply. Figure 5 shows the impact of trade saturation on vitamin A supply. We see more countries including developed ones such as the UK becoming deficient in vitamin A, an essential micronutrient, under low to medium trade saturation. Increasing trade saturation reduces the level of vitamin A deficiency to a large extent, especially in African countries. It does not, however, eliminate vitamin A deficiency altogether. Moreover, some countries that are not vitamin A deficient under low and medium trade saturation such as Brazil and Indonesia become so under full trade saturation, because some vitamin A-rich foods consumed domestically under low and medium trade can now be exported when trade saturation increases. Hence for vitamin A, although trade reduces the extent of deficiency in many countries, it alone cannot eliminate deficiency. Figure 6 shows the impact of trade saturation on iron deficiency. As with vitamin A, more countries become deficient for iron than for calories, including some Scandinavian countries under the different levels of trade. The result shows that increasing trade saturation significantly reduces the level of iron deficiency, especially in countries in Africa, Asia and South America. However, trade does not eliminate iron deficiency in Scandinavia countries or Mongolia, although it makes them less deficient  royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 (light shade in red). As with vitamin A, other measures such as improving diet and increasing production and consumption of certain foods will be needed to eliminate iron deficiency. Figure 7 shows the impact of trade saturation on zinc deficiency. It shows that increasing trade saturation from low or medium to high can eliminate zinc deficiency.
The results show that deficiency in micronutrients such as vitamin A and iron is much more common than that in macronutrients such as calories and fat. The latter is found only in developing countries in Africa, Asia and South America while the former can be found in both developed and developing countries, which signifies the importance of including both macro and micronutrients in the study of food and nutrition security.
We see that trade plays a positive role in improving food and nutrition security in almost all cases. A fully realized trade eliminates calories deficiency in all countries, compared with low trade and makes fat intakes more balanced across countries. For some micronutrients (e.g. niacin and zinc, see Appendix), high trade saturation has successfully eliminated deficiency in all countries, compared with low and medium trade saturation; for others, deficiency still exists even under fully realized trade, but to a lesser degree. It will require other measures, such as change increasing production and alternative trade scenarios of food rich in the micronutrients to eliminate nutrient deficiency in those micronutrients. In many developing countries currently use supplementation to correct the deficiencies. In almost all cases, we observe that trade at least reduces the level of nutrient deficiency across countries, if not eliminates it. The effect of trade is most prominent in countries most vulnerable to food and nutrition insecurity, including those in Africa, Asia and South America.
Finally, table 6 lists the nutrition intake per capita of the 20 most populous countries in 2013, which together account for more than two-thirds of the world population; also table 22 in the Appendix for the full list of countries. Note that the nutrient requirement per capita will vary slightly by countries due to the different population composition in each country (e.g. a younger/higher male percentage population will require more nutrient).

Discussion
The preliminary results from the model demonstrate the impact of increasing trade on improving macro and micronutrient sufficiency across countries in the world. For all nutrients included in §4.1, fully realized global trade can help ensure a sufficient supply of nutrients and enables countries to have a healthier diet. The reason is quite straightforward: trade allows the countries to access a larger variety of food, thus enabling them to have a more nutritionally balanced diet. Trade is even more important royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 Table 6. Nutrition intake per capita a of the 20 most populous countries in 2013, which together account for more than two-thirds of the world population (also nutrition intake per capita will be compared with the nutrition required per capita in the country, which depends on the country's demographic composition to determine a country's food and nutrition security.
royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 when considering micronutrient sufficiency because they tend to be more concentrated in specific foods than macronutrients such as calories and fat, so the diet needs to contain more diverse food items to supply sufficient micronutrients. The role of increasing trade in improving nutrition security is found to be universal across all macro and micronutrients, but more pronounced in micronutrients. Results from this study agree with previous studies in that global trade can balance food supply and demand across regions and smooth out nutrient intake across countries [60]. It also confirms the previous conclusion that the focus of food security should shift from calories to critical micronutrients, in which many regions will continue to have inadequacies [41]. A criticism of global food trade is that free trade penalizes the poorest and most vulnerable countries [61,62]. This is largely true: the results show that low-income countries are the first to fall into food and nutrition insecurity as trade saturation goes from high to medium to low, partly because they are often ranked lower on countries' trade priority due to their low GDP per capita and remote location. However, the results also suggest that the solution is not trade-protectionism. This is very important for countries where diets need to diversity to achieve nutrition security. We need to further remove any trade barriers and increase trade saturation so that all potential trade opportunities can be used and the demand for the most vulnerable countries can be met. Preliminary results show that increasing trade saturation always improves the nutrition security of countries. For some nutrients, trade alone can eliminate food and nutrition insecurity for all countries altogether. The poor and vulnerable countries also benefit from trade. Because they are lower on the priority rank, they benefit the most from additional trade liberalization and opportunities. Pradhan et al. [63] estimate that in 2000 about 1 billion people from Asia and Africa require cross-continental agricultural trade to be food secure, and by 2050 the number of people depending on trade for food security will be between 1.5 and 6 billion. Any hindrance to trade will put these people at high risk of food insecurity.
The model presented in the study is the first step towards a holistic approach to the grand challenge of food and nutrition security under global trade and climate change. There are many ways to extend the model in the future. First, the dimension and factors of countries' trade relationships included in the model are far from complete. Apart from GDP, distance, and historic and emergent trade relationships, many factors can affect the trade relationships between countries. For example, the trade war between the US and China in 2019 was motivated by complex economic and political reasons. The flexibility of the ABM, however, means that the model can be easily adapted to implement additional factors to increase the dimension of the trade relationship. The relation-driven trade model developed in this paper will be a framework to which these relation-driven dimensions and motivations can be added to analyse its impact on trade and food security.
Moreover, so far we have only considered the average nutrition intake in a country. We have not considered the inequality and distribution within a country. A country may have enough food for its population overall, but is still food insecure because of unequal internal allocation. This is especially important for countries with unequal developments across regions, where a minority of the population has more than adequate access to food and nutrition while the majority do not. Since the global model cannot model each country in such details due to computational constraints, one approach is to use a measure of inequality of access to food within a country as used by the FAO, such as in the FEEDME model [64,65], which uses a country-level measure of inequality (income and food access inequality) to determine the percentage of a population in each country which is undernourished. Another approach is to couple the global model with individual country models for the country of interest. For example, we can couple the individual country model of China or Brazil with the global trade model developed in this paper, which allows us to position the internal dynamics and interactions between different regions and firms under the background of global trade, without having to acquire the same level of detailed data for all countries. This is particularly useful for countries like Brazil where global food trade plays a crucial role in its domestic agri-food systems.

Concluding remarks
In an increasingly connected world, a country's ability to secure food concerns more than what is produced on the ground, but also its relationships with other countries. The issue is particularly relevant and timely given the current debates about Brexit, US-China trade war and the global COVID-19 pandemic. This paper develops an empirically grounded, relation-driven model of global trade to study the impact of trade on the food and nutrition security of countries around the world, complementing existing price-driven trade models in the literature. It makes several important royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 contributions. First, it provides a flexible modelling framework that focuses on country-wise relationships in trade. The framework can be used to study more complex and relation-driven behaviour when trading with each other, such as trust, familiarity, history and conflicts. Second, the global trade model is linked with a comprehensive nutrition formula based on food consumption to investigate the impact of trade on food and nutrition security. As researchers have been constantly calling for a holistic and multifactorial approach to these global challenges, the model is one of the first attempts to develop an integrated framework consisting of socio-economic, geopolitical, nutrition, environmental and agri-food systems to tackle these global challenges.
Preliminary results show that global trade has a significant impact on food and nutrition security across countries. Increasing trade improves the nutritional security of almost all countries, especially countries in Africa, Asia and Latin America susceptible to food insecurity. For some nutrients such as calories, niacin and zinc, trade alone can eliminate nutrition insecurity for all countries; for others such as vitamin A, folate, riboflavin and iron, trade improves nutrition security but is insufficient to achieve food security. Other measures such as dietary changes may be needed. We also find that trade allows countries to have a healthier and more balanced diet, due to the increased variety of food enabled by trade: it decreases fat intake in countries that previously consume too much fat and vice versa. Overall, we find that the effect of trade on enhancing nutrition balance and security is universal across all macro and micronutrients and countries.
In the future, the global trade model developed in the study can be coupled with individual country models to include more detailed regional dynamics, firm interactions and inequality within countries. It offers a way to link models of individual country's agri-food system with a dynamic global trade system, which is particularly useful for countries like Brazil where global food trade plays a crucial role. Finally, the model will be used to systemically conduct scenario analysis on food security under various scenarios of climate change, dietary change and de-globalization.
Data accessibility. We have provided the (simulated) data used in the paper as electronic supplementary material. Authors' contributions. J.G. was involved in conceptualization, formal analysis, investigation, methodology, validation, visualization and writing the original draft preparation. J.G.P. was involved in conceptualization, methodology, writing review and editing. J.I.M. was involved in conceptualization, data curation, methodology, funding acquisition, writing' review and editing. N.F. was involved in data curation, formal analysis, writing review and editing. P.S. was involved in conceptualization, data curation, funding acquisition, methodology, writing review and editing. H.C. was involved in data curation, formal analysis, writing review and editing. T.D. was involved in conceptualization, funding acquisition, writing review and editing. M.A. was involved in conceptualization.
Competing interests. P.S. was a member of the Royal Society Editorial Board at the time this paper was submitted, peerreviewed and accepted; however, P.S. had no involvement in the assessment of this manuscript. Acknowledgements. We would like to thank two anonymous reviewers for their constructive comments and suggestions, which help us greatly improve the paper. A.1.1. Trade volume Table 7 shows the percentage of the simulated volume of trade and consumption that is within ±20% of the actual volume from data. We see that, overall, the model produces a 54.80% matching rate. It does better in predicting export volume and food consumption than predicting import volume. The variance or s.d. among model runs (from internal model stochasticity) is very small, which suggests the absence of bifurcation. Table 8 shows the matching rate of simulated volume by aggregated food category. Note that the average match rate varies across different food categories. The model's prediction of trade and consumption volumes is better for some foods (sugar crops, spices, animal fats, aquatic products) than royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 others (vegetables, milk). Also note that the variance or s.d. tends to be higher for foods with lower average matching rate, which suggests that those foods are more subject to stochastic factors in trade, which may explain the lower matching rate in prediction. Table 9 shows the matching rate of simulated volume by region. The model can better predict trade volumes for some regions (sub-Saharan Africa, Latin America) than others (North America, Europe, Pacific OECD). The regions that the model does relatively well in predicting tend to be developing regions and countries (sub-Saharan Africa, Latin America); the regions that the model does relatively poorly are developed ones (North America, Europe and Pacific OECD). The model's assumption of increasing consumption as production increases may be more valid in developing countries than developed ones; it may not capture the most recent trend in food consumption in developed countries that diverge from a concave increasing function as projected by most conventional models. Empirical data and evidence would be needed to adjust the model for that. Table 10 shows the matching rate of simulated volume by year. We can see that the matching rate steadily goes down over the years, which is as expected as we move away from the original year (2000) initialized with empirical data. The variance of results from the parallel models also increases over time, which is also as expected, because stochasticity (such as emergent trade relationship) occuring in early years may have a lasting effect on model results from that point, the accumulation of which will lead to increased variance among parallel models.

A.1.2. Trade partners
This section shows the matching rate of trade partners between simulated and actual trade outcome (importer, exporter and food traded).   Table 12 shows the matching rate of trade partners by aggregated food category. Because the data used for validation (from Comtrade) does not cover all the food traded in the model, only the ones available in Comtrade are presented here. Similar to trade volume, the model's ability to predict trade partners varies across food categories. For some (e.g. oil crops, stimulants and spices), the model can predict correctly the majority (greater than 85%) of the trade partners, and for others (starchy roots), the model can only predict less than half. One of the reasons could be that the production of some commodities is concentrated in a handful of countries (e.g. oil crops, stimulants and spices). It is relatively easy for the model to predict correctly trade partners for those commodities, as there are only a handful of sellers, than for commodities where buyers and sellers are more scattered (tables 13-22).  Figure 11. Riboflavin sufficiency under low, medium and high trade saturation (blue = sufficient, red = insufficient).  royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587  Afghanistan  import  wheat and products  2000  929  1570   Afghanistan  export  wheat and products  2000  0  0   Afghanistan  food  wheat and products  2000  2600  2681  Afghanistan  import  rice (milled equivalent)          royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587 Table 22. royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201587