Domestic versus foreign drivers of trade (im)balances: How robust is evidence from estimated DSGE models?

Estimated DSGE models tend to ascribe a significant and often predominant part of a country's trade balance (TB) dynamics to domestic drivers (“shocks”), suggesting foreign factors to be only of secondary importance. This paper revisits the result based on more agnostic approaches to shock transmission and using “agnostic structural disturbances”. We estimate multi-region models for Germany and Spain as countries with very distinct TB patterns since 1999. Results suggest that domestic drivers remain dominant when theory-based restrictions on shock transmission are relaxed, although the transmission of foreign shocks is strengthened.


Introduction
The sign and size of a country's trade balance (TB) are affected by domestic and foreign factors alike (e.g., Obstfeld and Rogoff, 1996). The relative importance of each group is an empirical question, which we revisit through the lens of dynamic stochastic general equilibrium (DSGE) models, with a focus on Germany (DE) and Spain (ES) as two large Euro Area (EA) Member States that have witnessed strikingly distinct TB dynamics since the start of EMU in 1999. In particular, we estimate multi-region DSGE models (EA Member State, the rest of the EA (REA), and the rest of the world (RoW)) for DE and ES, respectively.  . Results in Kollmann et al. (2016) and Giovannini et al. (2019) with more complex estimated multiregion models are more balanced, with non-negligible contributions of RoW shocks to EA and US GDP and trade balance dynamics since 1999. Turning to individual EA countries, Kollmann et al. (2015) find the persistence of DE's TB surplus to be driven mainly by domestic factors, although external factors matter quantitatively in the build-up phase.
Looking at Spain, in 't Veld et al. (2014Veld et al. ( , 2015 find a quantitatively significant contribution of narrowing intra-EA risk premia to the country's TB deficit before the financial crisis, but little contribution of (other) foreign factors to GDP growth and net export dynamics. Albonico et al. (2019) provide a comparative perspective in which domestic shocks are essential to explain the persistent TB surplus of DE and the pre-crisis TB deficit build-up in ES and Italy (IT), whereas foreign shocks account for a more substantial part in France, particularly in recent years.
The finding of a limited role for external factors is linked to the ambivalent role of various shocks in terms of spillover and TB dynamics. Positive foreign supply shocks, e.g., tend to generate positive income effects and, at the same time, improve the competitiveness of foreign producers, where the first effect strengthens and the second effect weakens net exports of the domestic economy. Spillover of positive foreign demand shocks inside a monetary union is rather weak in normal times, as stronger demand is met by a tightening of monetary policy that dampens domestic demand in the domestic economy and appreciates the common currency, reducing net exports to the RoW. In addition, it should be underlined that distinguishing between domestic and foreign shocks and between demand and supply shocks is less clear-cut in reality. Domestic demand shocks, e.g., can be the result of changes in the credit supply by foreign or domestic financial intermediaries, and domestic financial conditions may be subject to contagion effects (e.g., Dornbusch et al., 2000) in excess of "real" trade and financial linkages.
The benchmark estimates in this paper are in line with previous findings and suggest TB dynamics in DE and ES to be driven mainly by domestic (demand) factors. In a counterfactual simulation without domestic demand shocks, Spain's TB (in % of nominal GDP) is more than 5 percentage points (pp) higher in 2008, and the subsequent TB reversal 4 pp less pronounced.
Domestic demand conditions also explain a large part of the DE TB variation, but external factors are more important than for ES. The REA pre-crisis boom raised DE net exports, whereas falling REA demand has weighted negatively on the DE TB during the subsequent recession. We find little role for spillover of foreign supply shocks ("competitiveness gains/losses") within the EA, however. Intra-EA relative price dynamics reflect to a large extent diverging demand conditions in the benchmark model.
We then extend the model in two directions to assess the robustness of the benchmark results.
We first investigate the hypothesis that price and wage pressure from abroad affect net trade beyond the ambivalent role of supply shocks in the standard model and the (realised) transmission to export and import prices. We test the idea by including price and wage shocks directly in the trade equations and re-estimating the models with wide agnostic priors. The data reject the inclusion of supply shocks in trade equations for Spain, supporting the results of the baseline model. Interestingly, however, we find some evidence for a stronger role of price pressure and spillover in the case of DE, with a larger role for foreign price shocks. The inclusion of foreign price shocks in trade equations does, however, not overturn the benchmark result that domestic demand factors dominate the decomposition of TB dynamics in DE and ES.
Second, we follow recent methodological advances in empirical business cycle analysis and adopt a more agnostic perspective on shock transmission by applying the agnostic structural disturbances (ASDs) methodology of Den Haan and Drechsel (2020). ASDs enter the model like structural shocks, but their impact is a priori unrestricted. Our main results remain robust with different ASD specifications, i.e. domestic developments still explain most of the TB variance. One of the ASDs that we investigate shares essential similarities with the key domestic demand shock, but also implies stronger international co-movement in the spirit of global risk shocks. We conclude that the (more) agnostic specifications preserve the main message from the benchmark model.

Stylised facts
The TBs of DE and ES have followed distinct patterns in recent years ( Figure 1). DE is characterised by a large and persistent TB surplus that has built up since the early 2000s, with a pause in the years of the global financial crisis and a peak at around 8% of GDP in 2015. ES has run a large trade deficit in the early years of EMU, reaching -6% of GDP on the eve of the financial crisis. The TB has turned into a surplus of up to 4% of GDP in recent years. DE's TB surplus shows limited co-movement with the output gap, i.e. the surplus has remained high in periods of positive and negative output gaps alike. Spain's TB dynamics, to the contrary, displays marked cyclicality, with TB deficits in periods of positive output gaps, and a move into surplus in conjunction with negative output gaps after 2008.  and it depreciated after 2008, when the economy contracted and the TB moved into positive territory.

Figure 2: Trade balance and real effective exchange rate
Note: TBY is the trade balance in % of GDP; REER is the real effective exchange rate, normalised to 2010=100. The REER is calculated based on the GDP deflator (PGDP) and unit labour costs (UCL), respectively, compared to a group of 37 industrial countries. A REER decline indicates REER depreciation. Source: AMECO.

Model description
Our analysis uses a set of estimated multi-country models.
where is the (non-stochastic) discount factor (common for both types of households) and is a saving shock, which is limited to saver households. 3 (•) denotes per period utiliy described below.

Ricardian households
The Ricardian households work, consume, own firms and receive nominal transfers from the government. Ricardians are the only households with full access to financial markets. The financial wealth of household j consists of bonds and shares, where is the nominal price of shares in t, −1 the number of shares held by the household, and , is the consumption price, including VAT. The period t budget constraint of a saver household j is: where is the nominal wage rate, is the employment in hours, and the labour tax rate. −1 , −1 and −1 are domestic government bonds, foreign bonds, and risk-free bonds with returns −1 , −1 , and −1 , respectively. 4 is the GDP price deflator.
denotes the bilateral exchange rate. are government transfers to savers, and are lump-sum taxes paid by savers. Intermediate goods producers pay dividends to savers.
denotes wage adjustment costs.
We define the gross nominal return on domestic shares as: The instantaneous utility functions of savers, (•), is defined as: 3 Unless stated differently, all exogenous random variables in the model follow independent autoregressive processes. 4 As in Benigno (2009) and Ratto et al. (2009), we assume that only the RoW bond is traded internationally. The disutility of holding risky financial assets, −1 , is defined as: The asset-specific risk premium shock depends on an asset-specific exogenous shock , ∈ { , , } (government bonds, stocks, and foreign assets) and an asset-specific intercept . 5 Similar to Krishnamurthy and Vissing-Jorgensen (2012) and Fisher (2015), introducing a disutility of holding risky assets captures the households' preferences for the safe short-term bonds and introduces an endogenous wedge between the return on risky assets and safe bonds.
An uncovered interest rate parity condition links the interest rate of the MS to the EA interest rate: captures a debt-dependent country risk premium on net foreign asset (NFA) holdings to ensure the long-run stability of foreign debt (see, e.g., Schmitt-Grohe and Uribe, 2003;Adolfson et al., 2008). The 'flight-to-safety' shock, , creates a wedge between the EA interest rate, , and . A positive shock increases the required return on domestic assets and the cost of capital, reducing consumption and investment simultaneously.
Appendix B.3 provides additional information on the transmission and the relative importance of domestic demand shocks.

Liquidity-constrained household
The liquidity-constrained household consumes her disposable after-tax wage and transfer income in each period ("hand-to-mouth"), which gives the period t budget constraint: 5 Internationally traded bonds are also subject to transaction costs in form of a function of the average net foreign asset position relative to GDP.

Wage setting
Households provide differentiated labour services, , in a monopolistically competitive market. A labour union bundles labour hours provided by both types of domestic households and resells homogeneous labour services to intermediate goods producing firms. 6 The resulting wage rule equates a weighted average of the marginal utility of leisure to a weighted average of the marginal utility of consumption times the real wage adjusted for a wage markup. Wage adjustment costs give rise to nominal wage rigidity. We also allow for real wage rigidity as in Blanchard and Galí (2007), parametrized by .

EA Member State production sector
Perfectly competitive firms produce total output, , by combining value added, , with energy input, , using the following CES production function: where is the energy input share in total output and the elasticity of substitution between the two components. . Each variety is produced by a single firm using total capital, −1 , and labour, , which are combined by a Cobb-Douglas production function: where is the steady-state labour share, is exogenous labour-augmenting productivity common to all firms . 7 and are the firm-specific level of capital utilization and 6 Since both households face the same labour demand schedule, each household works the same number of hours as the average of the economy. It follows that the individual union's choice variable is a common nominal wage rate for both types of households. See Appendix A for additional details. 7 Productivity is a non-stationary stochastic process subject to trend and level shocks (see Appendix A).
where is physical investment, is the investment price, is the corporate tax, and is the capital depreciation rate. summarizes adjustment costs on production factors, namely capital and labour, and on capacity utilization, labour hoarding and investment.

Import sector
where is a shock to productivity in the sector producing goods, is a shock to the share of good-specific import demand components, , , and is the elasticity of substitution between domestic output and imports. It follows that the demand for and imported goods are given by: where and are the price deflators associated with and , respectively, and the total final good deflator is: Perfectly competitive firms produce final imported goods, , by combining countryspecific final import goods, , using a CES production function: where is the price elasticity of demand for country 's goods and denotes the share of country in world output. Since all products from foreign country are initially purchased at export price, , the economy-specific import good price can be expressed as: = , where is the bilateral exchange rate between domestic country k and foreign country l.

Export sector
The exporting firms are competitive and export a good that is a combination of domestic output and import content. The corresponding export price is given by: where captures an export-specific price shock.

EA Taylor rule
The ECB sets the policy rate in response to the annualized EA-wide inflation gap, ))] + , where ̅ = + ̅ is the steady-state nominal interest rate, equal to the sum of the steady-state real interest rate and GDP inflation in the steady state. The policy parameters ( , , ) capture the interest rate inertia and the response to the annualized inflation and output gaps, respectively. captures unexpected monetary policy changes.

Member State fiscal policy
The government collects taxes on labour, , capital, , and consumption, , as well as lump-sum taxes, , and constant excise duties on oil imports from RoW, 0 , and it issues one-period bonds, . Government spending includes public consumption, , public investment, , transfers, , and the servicing of the outstanding debt. , , and follow autoregressive processes with shocks : where ∈ { , , } The government budget constraint is: where nominal government revenues, , are: The government uses lump-sum taxes as a budget closure and increases (lowers) them when government debt and deficit are above (below) the respective targets, ̅ and :

The trade balance and aggregate accounting
Market clearing requires that: where the trade balance, , is defined as the difference between nominal exports and imports, with domestic importers buying the imported good at the price : There are shocks to labour productivity, price mark-ups for final output, the subjective discount rate, the relative preference for domestic vs. imported goods, as well as monetary policy shocks.
The budget constraint for the representative household in REA, as an oil importer, is: where 0 captures the excise duty. 11 Total nominal exports of final goods for REA and RoW are defined as: = ∑ ,with the bilateral export price being defined as the domestic price subject to a bilateral price shock, = exp ( ) .
We combine the FOCs of REA and RoW with respect to international bonds to obtain the uncovered interest parity (UIP) condition: 9 Since we allow for a non-zero trade balance in the steady state, we include an international transfer, , calibrated to satisfy zero NFA in equilibrium. 10 Appendix B.5 shows that our main results remain unaffected when we extend the model by capital formation and multi-input production functions in the REA and the RoW. For clarity, we thus choose the simpler approach outlined here as the benchmark. 11 In contrast, since RoW is an oil exporter, the budget constraint for the representative household is: + = , + , where and are price and volume of RoW final good output, and are price and volume of oil exports to country l=(EMU regions), and is the trade balance. For simplicity, oil is an unstorable exogenous endowment of RoW and is supplied inelastically. The price of oil, , is determined in RoW currency.
[ , , +1 , , where captures a bond premium shock between EA and RoW (exchange rate shock), and 1 is a debt-dependent country risk premium on NFA holdings. 12 In the absence of investment and government spending in the REA and RoW blocks, final domestic demand, , is a CES aggregate of domestic output, , and imported goods, : where the import share.
The intermediate good producers use labour to manufacture domestic goods : where captures a trend in productivity. Price setting follows a New Keynesian Phillips curve: is the share of forward-looking price-setters, and is a cost-push shock.
The intertemporal equation for aggregate domestic demand follows from the FOC for consumption: with = exp ( ) , and as the REA and RoW demand shock, respectively.
Monetary policy in RoW follows a Taylor-type rule similar to the EA (estimated parameters are region-specific). 12 The endogenous risk premium ensures long-run stability of the NFA position (see, e.g., Adolfson et al., 2008;Schmitt-Grohe and Uribe, 2003).

Model solution and econometric approach
The following non-linear system summarizes the state-space representation of our model: where collects all endogenous variables of the model, while is a vector of exogenous shocks. We compute an approximate model solution by linearizing the model around its deterministic steady state. Given the structural parameters collected in , the linear rational expectation solution takes the following form: where Φ 1 and Φ govern the decision rules of the model.
We calibrate a subset of parameters to match long-run data properties, and we estimate the remaining parameters with Bayesian methods using data for the period 1999q1-2018q4. To perform a large number of robustness checks, we use a computationally efficient parallelized slice sampling algorithm. 13 Appendix C provides information on data transformations and our data set.
The calibration of parameters for the long run replicates average historical ratios and trade shares for the respective MS (see Table B.1.1 in the appendix). All real GDP components on the demand side (deflated by the GDP deflator) are assumed to grow at the average growth rate of output over the sample period. Prices in steady state grow at a rate of 2% per year. We set the steady-state share of Ricardian households according to the survey evidence in Dolls et al. (2012). The parameters of the EA monetary policy rule have been estimated in a tworegion (EA-RoW) version of the model and are imposed here to ensure an identical policy rule for both EA configurations, i.e. DE-REA-RoW and ES-REA-RoW. 13 We use the DYNARE software (Adjemian et al., 2011). The estimated model includes 39 exogenous shocks, as it appears that many shocks are needed to capture the dynamic properties of the macroeconomic and financial data (e.g., Kollmann et al., 2015). The large number of shocks is also dictated by the fact that we use a large number of observables (38) for the estimation. For details on slice sampling, see Neal (2003) and Planas et al. (2015).  The estimates also suggest substantial nominal rigidities in prices and wages.
Demand shocks are highly serially correlated, as shown in Table 2. 14 Appendix B.2 shows that model-implied moments are close to the data and that the estimated model successfully replicates business cycles features in DE and ES.

Estimated drivers of the trade balance in the benchmark model
This section quantifies the main drivers of the TBs of DE and ES based on the estimated benchmark model. Figure 3 and Figure 4 assess the role of different shocks as drivers of the TB for DE and ES, respectively. We first consider the historical decomposition of DE TB as the EA's emblematic surplus country in Figure 3.

Figure 3: Shock decomposition of the German trade balance-to-GDP ratio
Note: Units on the x-axis are years and units on the y-axis measure the trade balance as a share of GDP relative to its sample mean, where 0.01 corresponds to 1% of GDP. The mean (steady state) of the trade balance-to-GDP ratio in DE is 4.0%. The solid lines represent the historical series of the trade balance-to-GDP ratio from which we have subtracted the sample average. Vertical bars measure the estimated contribution of different shock groups. Bars above (below) the x-axis indicate positive (negative) contributions to the trade balance relative to its average in a given year. The sum of positive and negative contributions matches the data (solid black line) for any point in time. We have assigned shocks to distinct groups, mainly focusing on demand versus supply shocks originating in different regions (domestic, REA, and RoW). In addition, we report shocks to preferences for foreign goods and mark-up shocks to import and export prices as "trade shocks", and shocks to EA monetary policy and the interest rate parity condition between the EA and the RoW as "EXR and monetary policy shocks." The group "Others + Initial Values" summarizes any remaining factors and the effect of initial conditions. Initial conditions ("initial disbalances") are estimated measures of how much the starting values in the data deviate from the model steady state.
The estimates suggest that domestic demand conditions, namely excess saving and adverse investment shocks, account for a large share of the surplus build-up. The shocks are very persistent, which explains the non-cyclical upward trend in Figure 1   In sum, the estimated benchmark version of the model suggests that spillover from foreign shocks, particularly foreign demand shocks, has played a notable but limited role for TB dynamics in DE and ES. The estimation provides little evidence for quantitatively important supply-driven spillover, such as exogenous "competitive gains/losses" or "competitive pressure", on the TBs of DE and ES. The rest of the paper examines the secondary role of foreign shocks in more detail in a more agnostic setting.

Inspecting the robustness of the benchmark results
The Drechsel (2020), as a "theory-free" alternative to structural shocks ("drivers") that we identified as drivers in Section 5. constraining the sign and size of additional effects and, hence, letting the data speak more freely. We assign wide priors with zero mean such that the four variants remain a priori identical to the benchmark specification of Section 5. Table 3 provides the data density of the four variants as the criterion for model selection in the Bayesian context. The data density evaluates the fit of the model, but also penalizes models with more parameters, giving a preference to simplicity. 16 Table 3 shows that the data reject all four augmented specifications for the case of ES, i.e. supports the benchmark results that spillover from supply-side shocks have played little role ES TB dynamics. Interestingly, however, the estimation favours a reinforced role for foreign (REA and RoW) and domestic price pressure in the case of DE, whereas the data reject the inclusion of the domestic wage mark-up also for the DE model.

Agnostic structural disturbances
This subsection generalises the empirical specification further to soften model-imposed restrictions on the shock transmission. Based on the "agnostic structural disturbances" (ASD) approach of Den Haan and Drechsel (2020), it investigates whether estimated shocks that mainly drive the TB in the benchmark decompositions are correctly specified, or whether an alternative shock structure would change the relative importance of domestic and foreign shocks.
Formally, ASDs are structural shocks (disturbances) that enter the model like regular structural shocks. Their role in explaining the observed data is a priori unrestricted, however.
We can rewrite the model representation as: The ASD procedure is especially insightful when we replace a key shock from our baseline set-up. The replacing ASD enters the model in the same equation as the original shock and many other equations. The impact in all equations is a priori zero, including in the original location. In this way, the model estimation can detect potential misspecification of structural shocks. The estimation then agnostically determines the properties of the ASD. If, for instance, the resulting ASD assigns a large coefficient to the place of the original shock and 17 In the approach in Subsection 6.1, the original shocks remain in the price or wage equations, i.e. the coefficients on the initial shocks equal one. 18 In practice, the size of Υ in a multi-region macro model is very large. We do not include ASDs in equations that are pure definitions (e.g., of growth rates) or accounting identities. Given the size of our model and the data set, we focus discussion on entries of Υ in the main behavioural equations.
the ASD behaves similarly to the omitted shock (similar IRFs), the procedure supports the original specification. Otherwise, the data may point to a "theory-free", but econometrically preferred alternative shock structure. As in Subsection 6.1, we use the estimated data density to evaluate the fit of the model.
We focus the analysis on shocks to domestic demand and exogenous changes in competitiveness, which reflect competing hypotheses about the sources of external imbalances. 19 For each shock replaced by an ASD, we re-estimate the model parameters and shock processes. Table 4 shows that the data indeed prefer some of the agnostic specifications to the benchmark, suggesting that the extended models provide a better fit. Note: The data density is reported in log points using a Laplace approximation.

Replacing a key domestic demand shock
The flight-to-safety shock is critical in the estimated benchmark model in Section 5, where it is the main driver of domestic demand and the TB-to-GDP ratio in ES (Figure 4 above).
Replacing this flight-to-safety shock by an ASD therefore opens the possibility of decomposing the TB dynamics in an entirely different way. The estimated ASD specification, however, shows the benchmark result to be robust to the modification. In particular, the decomposition of the TB-to-GDP ratio remains similar, supporting the benchmark estimates.     20 See also Devereux and Sutherland (2011) on the role of leverage constraints for the international transmission of shocks.

Replacing a key competitiveness shock
Wage moderation (wage mark-up) shocks have contributed to the DE TB surplus, notably during the period of the "Hartz" labour market reforms, according to the benchmark model.
This section presents a model variant that replaces the wage mark-up shock by an ASD. Table   4 suggests related improvements in the model fit for ES and, in particular, for DE. The estimated IRFs in Figure 9 characterise the ASD in the model for DE. The ASD replacing the wage mark-up shock combines characteristics of demand and supply shocks. Output increases in conjunction with a decline in the price level and REER depreciation, which is characteristic for positive supply shocks. At the same time, domestic demand increases sharply, driven notably by strong consumption demand from Ricardian households. TB falls in response to the ASD, contrary to the TB improvement in response to a negative wage mark-up shock in the benchmark model.

Figure 9: IRFs for wage mark-up and replacing ASD shock in Germany
Note: Dynamic effects of wage mark-up shocks (we normalize the shock size to 1%). Solid black lines refer to the benchmark model, dashed blue ones to the agnostic model. An increase in the real exchange rate corresponds to a real effective depreciation. Units on the x-axis are quarters, units on the y-axis are percentage-point deviations from the steady state (trade balance) and per cent (%) deviations from steady state (all other variables), respectively.

Conclusion
This paper examines the trade balance (TB) dynamics of Germany (DE) and Spain (ES), emblematic cases with very distinct TB dynamics since the start of EMU in 1999, in estimated multi-region open-economy DSGE models that feature rich trade linkages and international financial markets. In line with previous results from this class of models, the estimated benchmark models ascribes a large part of TB dynamics to domestic drivers, notably domestic demand shocks, although international (foreign demand) and supply factors also matter for the TB profile, particularly for DE. We revisit the benchmark result by adopting more agnostic approaches with respect to shock transmission and use the "agnostic structural disturbances" of Den Haan and Drechsel (2020). Letting the data speak more freely suggests that the benchmark model neglects elements of international co-movement, but these additional factors do not fundamentally alter the decomposition of the TB dynamics. The domestic (demand) drivers remain dominant also when theoretical restrictions on the shock transmission are relaxed.
The distinction between domestic versus foreign and demand versus supply shocks is, admittedly, less sharp in reality. Domestic demand shocks in the model reflect, e.g., financial constraints, such as credit supply by foreign and domestic financial intermediaries, and may be subject to financial contagion that is unrelated to the structural linkages included in the model. In this sense, positive (negative) private domestic demand shocks, notably in the model for ES, may, e.g., also relate to softening (tightening) financial constraints and strengthening (weakening) credit supply by foreign lenders.

A. Model description
This Appendix provides the full equilibrium conditions of the household and firm optimization problems.

Households
The Ricardian household problem leads to the following first-order conditions (FOC): The FOC w.r.t. savers' consumption produces: where is the Lagrange multiplier on the budget constraint.
The FOC w.r.t. domestic risk-free bond: The FOC w.r.t. domestic government bonds: the consumption deflator inflation rate and the risk-premium on government bonds.
The FOC w.r.t. domestic stocks: where the risk premium on stocks. The above optimality conditions are similar to a textbook Euler equation, but incorporate asset-specific risk premia that depend on an exogenous shock as well as the size of the asset holdings as a share of GDP; see Vitek  (2007), we also introduce an additional risk premium shock, ('flight-to-safety'), which creates a wedge between the EA interest rate, , and the return on domestic risk-free assets, . Since a positive shock increases the required return on domestic assets and the cost of capital, it reduces current consumption and investment simultaneously and helps explaining the co-movement of consumption and investment.
The instantaneous utility functions for liquidity-constrained households, (•), is defined as:

Total output
Perfectly competitive firms produce total output, , by combining value added, , with energy input, , using the following CES production function: where is the energy input share in total output and is the elasticity of substitution between both components. It follows that demand for and by total output producers is, respectively: 21 Observationally, this approach is equivalent to exogenous risk premia as well as risk premia derived in the spirit of Bernanke et al. (1996).
where and are price deflators associated with and , respectively. Oil is imported from RoW, the oil price is given by: is the excise duty. The price index of total output is:

Firms
Each variety is produced by a single firm using total capital, −1 , and labour, , which are combined by a Cobb-Douglas production function: where is the steady-state labour share, is labour-augmenting productivity common to all firms in the differentiated goods sector, and and are the firm-specific levels of capital utilization and labour hoarding, respectively. 22 Total capital, , is the sum of privately installed capital, , and public capital, . captures fixed costs in production. Economy-wide total Factor Productivity, , is: Since TFP is a non-stationary process, we allow for two types of shocks that are related to a non-stationary process and its autoregressive component, respectively: which depends directly on the investment risk premium, . The dividends are defined as: where is physical investment, is the investment price, is the corporate tax, and is the capital depreciation rate.
Adjustment costs, , are associated with the output price, , labour input, , capacity utilization, , investment, , and labour hoarding, : where: where is the inverse of the price mark-up shock.

Labour markets
The optimality condition for the equilibrium wage is given by: where is the wage mark-up, is the degree of real wage rigidity, is the degree of nominal wage rigidity, and is the degree of forward-lookingness in the labour supply equation.
is the marginal disutility of labour: In the case of Germany, the real wage term on the left-hand side accounts for unemployment benefits, i.e. we modify (1 − ) to (1 − − −1 ), where −1 is the replacement rate.

REA and RoW demand functions
From profit maximization we obtain the demand for domestic and foreign goods: where the consumer price deflator, , is given by:

RoW monetary policy
Monetary policy in RoW follows a Taylor-type rule similar to the EA one: ))] + .

RoW oil endowment
The RoW supplies inelastically its unstorable exogenous endowment: = ∑ , the price of which, is set in RoW currency.  The last column reports the r 2 of the 1-year ahead forecast. We define the r 2 as 1 minus the ratio between the k-step ahead forecast error and the deviation of the observed time series from the model-implied steady state. This definition implies that r 2 has an upper bound at 1 and is unbounded from below. In the perfect case where the model generates no forecast error, the r 2 is equal to one, whereas in the case where the volatility of the forecast error is larger than the volatility of the observed time series, the r 2 is negative. The positive r 2 values indicate that the model forecast errors are not very large. However, the model-implied volatility of consumption growth in DE is higher than its empirical counterpart.

B.3 Details on the estimated effects of private demand shocks, discretionary fiscal policy, and oil price shocks
This section provides additional details on the contributions of private demand shocks (B.3.1), fiscal policy (B.3.2), and oil price shocks (B.3.3) to the dynamics of the TB.

B.3.1 Private domestic demand shocks
The model includes three private domestic demand shocks: Shocks to preferences for risk-free bonds ("flight-to-safety" shocks), shocks to the discount factor ("savings shocks"), and shocks to the investment risk premium. While our main results are robust to the exclusion of one of these shocks, the model fit and identification critieria support the specification with all three shocks.

B.3.2 Fiscal shocks
Fiscal shocks play only a small role for DE TBY dynamics ( Figure B.3.2). In ES, the initial fiscal stimulus during the Global financial crisis counteracted the private demand contraction, which shows up as negative contribution to TBY. Starting around 2012, however, the model estimation identifies reductions in government spending and investment ("austerity") as contributions to the post-crisis TB reversal in ES ( Figure B.3.3).

B.3.3 Oil price shocks
The model includes an oil price shock as exogenous supply-side change in the price of oil (in RoW currency). Because EA and its MS are oil importers, any change in the oil price will affect the TBY, i.e. a lower (higher) oil price will reduce (increase) the import bill and improve (deteriorate) the TB. Giovannini et al. (2019) show that oil prices (and a broader bundle of commodities) were indeed relevant drivers of the TBY in the EA and the US after the Great Recession. 23 We find that oil price hikes deteriorated the TBY in 2008 and 2011/12, whereas the oil price decline in 2015-17 led to an improvement in DE and ES external positions relative to the long-term average. The estimated dynamics are similar for both DE and ES, i.e. they do not explain differences in the overall TBY pattern between the two economies.

Figure B.3.2: Selected shock contributions to TBY in Germany (DE)
Note: Units on the x-axis are years and units on the y-axis measure the trade balance (as a share of GDP) relative to its sample mean, where 0.01 corresponds to 1% of GDP. Black bars show the contributions of the respective shock group.

Figure B.3.3: Selected shock contributions to TBY in Spain (ES)
Note: Units on the x-axis are years and units on the y-axis measure the trade balance (as a share of GDP) relative to its sample mean, where 0.01 corresponds to 1% of GDP. Black bars show the contributions of shock groups.

B.4 Hartz reforms -estimated effects of replacement rate shocks
In 2003-2005, the DE government implemented a far-reaching labour market deregulation, the so-called 'Hartz' reforms, which aimed at better job matching and reduced the length and generosity of unemployment benefits (the benefit replacement rate fell permanently from 62% to 53% on average in [2004][2005]. The discussion and model implementation here closely follows Kollmann et al. (2015). In particular, we capture the structural change by observing the benefit replacement rate (see lower panel in Figure B.4.1) in this model. Unemployment benefits (paid to unemployed workers in the labour force) enter the budget constraints of the households and the government. A random-walk shock to the replacement rate captures the observed (permanent) structural change. Appendix A above provides the formal details.  Note: Dynamic effects of shock to the replacement rate (shock size of 1 pp.). Simulations use the DE baseline model. An increase in the real exchange rate corresponds to a real effective depreciation. Units on the x-xis are quarters, units on the y-axis are percentage-point deviations from the steady state (trade balance) and percent (%) deviations from steady state (all other variables), respectively. The real interest rate is expressed in annualized basis points. The lower two panels depict the observed replacement rate and the corresponding estimated shock process in the model.

B.5 Model extension -adding capital to the REA and RoW model blocks
As a further robustness check, we have extended the REA and RoW model blocks by including capital and investment decisions to assess whether the simplified structure of the benchmark model may bias results against a stronger impact of foreign drivers by omitting "pull factors" of net capital exports. 24 Figure B.5.1 shows that domestic demand factors remain the main driver of the DE TBY ratio.   Note: Units on the x-axis are years and units on the y-axis measure the trade balance as share of GDP relative to its sample mean, where 0.01 corresponds to 1% of GDP.

C. Data transformations
We use quarterly and annual data for the period 1999q1 to 2018q4. Data for EMU countries (DE and ES)  When not available, quarterly-frequency data are obtained by interpolating annual data. We seasonally adjust the following time series using the TRAMO-SEATS package developed by Gómez and Maravall (1996)  observables, with the exception of the trade balance-to-GDP ratio, the oil price, and nominal interest rates. GDP deflators and relative prices of demand components are computed as the ratios of the current-price value to the chain-indexed volume series. The trend component of total factor productivity is computed using the DMM package developed by Fiorentini et al.
(2012). The resulting series at quarterly frequency is then used to estimate potential output. In DE, we additionally observe the historical average unemployment benefit ratio (constructed as the ratio of unemployment benefits to the wage rate).