---
title: "Terminology"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Terminology}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setupvignette, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
options(scipen = 999)
```

## Introduction

This vignette reviews the terminology used in input–output analysis, 
with reference to the *Eurostat Manual of Supply, Use and Input–Output Tables* (Beutel, 2008). 

*Work in progress:* a more comprehensive review will follow, comparing 
terminology with the UN Handbook (2018), OECD input–output matrices, 
and recent economics literature. This vignette should therefore be 
read as descriptive, showing how the iotables package currently uses 
Eurostat-style terminology.


```{r setup}
library(iotables)
```

Retrieve the demo dataset, the Germany 1995 Symmetric Input-Output Table: 

```{r germany}
germany_siot <- iotable_get()
```

### First quadrant

The first quadrant of the symmetric input-output tables, or in other words, the _domestic intermediate matrix_, input-output flows between a simplified, 6 sectors of the German economy in 1995. 

```{r firstq}
germany_siot[c(1:7), c(1:7)]
```

Row-wise, we see the flow of inputs. For example, at basic prices, out of the 
total demand for business services (423 933), 193 176 of the production of 
business services is used by other business service providers, 65 755 by 
trade enterprises, and 34 223 by other service industries.

```{r outputflow}
germany_siot[5, c(1, 5:8)]
```

The columns describe the structure of the input of the corresponding sector. For example, the business service sectors needed 15058 input from the other services, and 13371 imports from abroad (shown in the table below), to meet the final domestic demand of 423933 for business services (shown in the table above):

```{r inputflow}
germany_siot[c(5:9), c(1, 6)]
```

## Coefficients

### Input coefficients for domestic intermediates

The `input_coefficient_matrix_create()` function relies on the following equation. The numbering of the equations is the numbering of the Eurostat Manual.

(9)  \deqn{a_{ij} = x_{ij} / x_j}{a_ij = x_ij / x_j}  [recap: (43) is the same]

$a_{ij}$: input coefficient for domestic goods and services</br>
$x_{ij}$: flow of domestic commodity i to sector j, i.e., a cell in the first quadrant.</br>
$x_j$: output of j

```{r inputcoeffmatrix, eval=FALSE}
input_coefficient_matrix_create_2(iotable_get(), digits = 2)
```


### Output coefficients

The output coefficients are ratios derived from quadrant I (intermediates) and
quadrant II (final demand) of a sector.

The `output_coefficient_matrix_create()` function creates these coefficients based on equation (5) in the Eurostat Manual.

(5) $o_{ij}$ = $x_{ij}$ / $x_i$ 
 
$o_{ij}$ = output coefficient for domestic goods and services (i = 1, ..., 6; j = 1, ..., 6)
$x_{ij}$ = flow of commodity i to sector j
$x_j$ = output of sector i


## Inter-industry analysis

The term **forward linkage** refers to the interconnection of a sector 
to those to which it sells its output. In its simplest form, the 
strength of the forward linkage of a sector *i* is given by the 
row-wise sum of the direct output coefficients. This considers the 
direct supply-side economic effects of sector *i* on the entire economy.

The **backward linkage** of a sector *j* is given by the column sum 
of the direct input coefficients. This captures the direct demand-side 
effects of sector *j* on the economy. When calculated from the 
Leontief inverse, backward linkages also include the **indirect effects** 
propagated through the supply chain.

## Next steps

This terminology vignette is intended as a descriptive overview. 
Future releases of `iotables` will expand this section to align 
with the UN *Handbook on Supply and Use Tables and Input–Output 
Tables with Extensions and Applications* (2018), OECD input–output 
matrices, and recent economics literature. A systematic review of 
terminology and extended validation tests are planned for the next 
major release.
