## Useful Tools and Materials (External Links)

*A Gentle Introduction to Graph Neural Networks (Google Research)*

A Preprocessor for Function Definitions in GAMS (Ferris, Rutherford and Starkweather)

A Preprocessor for Function Definitions in GAMS (Ferris, Rutherford and Starkweather)

*Calibration and Counterfactuals of Gravity Trade Models (Allen and Arkolakis)*

*CES Functions: Some Hints and Useful Formulae (Rutherford)*

Discrete Choice Methods with Simulation (Kenneth Train)

Discrete Choice Methods with Simulation (Kenneth Train)

*Estibration: An Illustration of Structural Estimation As Calibration (Balistreri and Hillberry)*

*Exact Hat Algebra used in Deckle, Eaton and Kortum (Dingel)*

Exact Hat and MCP solution with the CES Demand - a Comparison (Yang)

Exact Hat and MCP solution with the CES Demand - a Comparison (Yang)

*Mixed Integer Nonlinear Program: Model with Both Nonlinearity and Discrete Variables (Vigerske)*

## Small Gadgets in Research

*VBA code to insert brackets around text in Excel (code)*

*Subplot function to plot multiple plots in Matplotlib with Python*

*(code and sample data) (text)*

## Technical Notes

## Optimization with Hat Derivatives: Theoretical and Mathematical Derivation of an Applied Computable Partial Equilibrium Model

By Yang, Anton

This note links the mathematical concept of hat derivatives to constrained optimization results derived and used by economists which is increasingly often written in the General Equilibrium Modelling (GEMPACK) Software using the TABLO language of writing economic models. Without these connections, it is fair to say that there are at least two substantial gaps in understanding many simple concept-based but probably lengthy economic models that are almost exclusively implemented using computers today. The first one is that, despite its importance, mathematicians almost never (very rarely, if so) formally introduce hat derivatives in a text book or publicly accessible academic sources (Maurer, 2002); the second one is that, despite its frequent use in contemporary economic computations, economists and economic modelers unwittingly lack a step-by-step explanation of how computer languages use the concept of hat derivatives derived from the neoclassical economic theory. Inside and outside of the economics discipline, this has created barriers to economists’ understanding of important model structures and communications among them within their own community. Quality economic research can be disregarded outside of the discipline without the proper and thorough communication of the mathematics. Therefore, the purpose of this note (partially due to increasing demand for relevant inquiries) is to attempt to fill these gaps.

To do so, we use a Simplified International Model of Agricultural Prices, Land use and the Environment (SIMPLE) Model (Baldos and Hertel, 2012)–which is an applied computable partial equilibrium model of global agricultural supply and demand–as an example; we show how equations corresponding to land use changes in this model, written in TABLO language, were converted and algebraically derived from producer theory in microeconomics. We then bring a slightly more general case and use a derivative of this model–SIMPLE-MAIDADS (Yang, Gouel and Hertel, 2018) to show derivations with interactions between long-run competition for land and multiple agricultural outputs.2 Nevertheless, we hope that this note will have much wider adaptability and usefulness, not merely in partial equilibrium models, but as well as in general equilibrium models. For example, the sequence of steps to arrive at the GEMPACK code and mathematical notations are highly similar to those used in the GTAP (Global Trade Analysis Project) Model, which also uses the technique of hat calculus to derive the percentage deviation from the base scenario in economic simulations (e.g., counterfactual analyses carried out on computers). Upon completion, we hope that this note will be beneficial to users who use facilitated interface of simulated economic shocks, while wishing to see the theoretical foundation of its analytical framework.

To do so, we use a Simplified International Model of Agricultural Prices, Land use and the Environment (SIMPLE) Model (Baldos and Hertel, 2012)–which is an applied computable partial equilibrium model of global agricultural supply and demand–as an example; we show how equations corresponding to land use changes in this model, written in TABLO language, were converted and algebraically derived from producer theory in microeconomics. We then bring a slightly more general case and use a derivative of this model–SIMPLE-MAIDADS (Yang, Gouel and Hertel, 2018) to show derivations with interactions between long-run competition for land and multiple agricultural outputs.2 Nevertheless, we hope that this note will have much wider adaptability and usefulness, not merely in partial equilibrium models, but as well as in general equilibrium models. For example, the sequence of steps to arrive at the GEMPACK code and mathematical notations are highly similar to those used in the GTAP (Global Trade Analysis Project) Model, which also uses the technique of hat calculus to derive the percentage deviation from the base scenario in economic simulations (e.g., counterfactual analyses carried out on computers). Upon completion, we hope that this note will be beneficial to users who use facilitated interface of simulated economic shocks, while wishing to see the theoretical foundation of its analytical framework.

## Universal CES Demand Systems and Counterfactuals in International Trade

By Yang, Anton

This note revisits standard and specialized constant elasticity of substitution (CES) demand systems which we call a Universal CES Demand System. We demonstrate, as clear as possible, the transformation of the can-be-nested additive demand systems within this universal parameterized framework illustrated as follows:

Of a particular note is how these transformations can be related to counterfactual analyses in a class of generalizations in quantitative general equilibrium trade models, whether or not they belong to the family of succinct theory-consistent reduced-forms or more sophisticated computational framework (with a well-detailed description of the world economy). Through processes of parameterization, it appears that (1) implicitly additive demand systems are generally less responsive to income changes on trade flows and consumer welfare; and (2) indirectly or directly separable demands (on the indifference surface of consumers' quantity choices), whether implicit or explicit, does not draw any distinctions in terms of counterfactuals.