Surahammars Ironworks/Surahammars Järnbruk, Sweden, 1919.

From Sweden’s Tekniska Museet photo collection.

In input-output economics, the **Leontief inverse** (i.e. [I-A]^-1) is ubiquitous. Named after the father of input-output economics, Wassily Leontief, the matrix is a compact representation of the ripple effects in an economy where industries are interconnected. A lone matrix coefficient conveys all direct and indirect effects on output in one sector required by a unit of output from another sector.

Below is Part 1 of a two part tutorial on deriving the Leontief inverse using R. This first part is a “toy” example to motivated the pieces of the input-output analysis and the workflow in R. Part 2 describes how to calculate the Leontief inverse from a full scale input-output table.

#### A Toy Input-Output Model.

Consider a baby example. I’ll use **Table 1** as a guide to calculating a simple Leontief inverse using R. The table represents the essential ingredients of common input-output tables using only two sectors.

**Table 1. A Small Input-Output Table**

From / To | Good 1 | Good 2 | Final Goods | Total Output |

Good 1 | 150 | 500 | 350 | 1000 |

Good 2 | 200 | 100 | 1700 | 2000 |

The above example borrows from the canonical examples in chapter 2 of Miller and Blair’s __Input-Output Analysis__ (1985) as well as chapter 2 of Leontief’s __Input-Output Economics__ (1986).

The heart of the table is a two-by-two matrix representing the intermediate good flows between the two sectors: sector 1 and sector 2. A row represents the value of output sent from a goods sector for productive use in a column sector. Above, a row sector sends goods to itself and sector 2.

After the two columns of intermediate good sales, the “Final Goods” column shows the value of a row’s output used as final products–output not used in production. If we add up a row’s output used as intermediate goods and as final products, we get the last column: total output.

#### Calculating the Matrix

The Leontief inverse is calculated in the following way. We start with an IO table like the one above. Using this basic IO table, we generate a “technical coefficient matrix,” which we then use to solve for the Leontient inverse matrix, L.

First we’ll build the input-output table in Table 1 using R. We generate the two-by-two flow of interindustry sales (`flowtable`

). Then I create the vector of `finaldemand`

.

We combined these pieces into a `data.frame`

object. Once combined, we sum across the intermediate input columns and final demand column to produce a new variable: total demand. The result is a `data.frame`

version of Table 1.

Now we can derive a **technical coefficient matrix**, also called **matrix A**. A column of this matrix represents an industrial recipe used to produce a single industry good.

Matrix A is calculated by dividing intersectoral flows by the total output of each column’s sector. Specifically, sector 1 ships 500 dollars of good 1 to sector 2, which produces 1000 dollars of total output. Thus, one dollar of good 1 is absorbed to produce 25 cents of sector 2’s output.

To calculate matrix A in R: first take the inverse of the total output vector and multiply it with an identity matrix. The resulting object, `z`

, is multiplied again with the `flowtable`

matrix.

Alternatively, we can use R’s `sweep()`

function to calculate A directly from the `flowmatrix`

and the `totaloutput`

vector. `sweep()`

takes the input matrix and divides each column by the corresponding entry of the vector. The argument `margin = 2`

tells us we’re “sweeping” over the columns of the input matrix, as opposed to rows (for row-wise calculations, `margin = 1`

).

Finally, the Leontief matrix is calculated in the following way.

Using R, we first calculate `I-A`

, substracting the technical coefficient matrix from the identity matrix. We then invert the I-A matrix by using the`solve()`

function. The result, `L`

, is the Leontief coefficient matrix.

Substantively, the matrix L summarizes the network effects generated when final output changes. A single coefficient of matrix L, surprisingly, summarizes **all** direct and indirect effects created in sector **i** to supply a single unit of final demand for sector **j**.