Input-output analysisの計算が面倒だから、Rで自動的に計算させたい。
Investpediaではこのように説明されています。
Input-output analysis (I-O) is a form of macroeconomic analysis based on the interdependencies between different economic sectors or industries. This method is commonly used for estimating the impacts of positive or negative economic shocks and analyzing the ripple effects throughout an economy. (Investpedia)
主に、計画経済やマルクス経済学で用いられるそうで、経済に対する影響を計算するために使うらしいですね。
とりあえず、SubjectGuideのexampleからやってみましょう。
Subject Guide, example 4.9, p66
まず、数式で表すとこうなります。
\[x_1 = d_1 + 0.2x_1 + 0.3x_2 + 0.2x_3 \\ x_2 = d_2 + 0.4x_1 + 0.1x_2 + 0.2x_3 \\ x_3 = d_3 + 0.1x_1 + 0.3x_2 + 0.2x_3 \\\] Where x is the amount of ouptput from each industry, and d is external demand.
The system of equationsを簡単に表すと、
\[ x = d + Ax \]
Where
\[ x = \left( \begin{matrix} x_1 \\ x_2 \\ x_3 \end{matrix} \right) \]
\[ d = \left( \begin{matrix} d_1 \\ d_2 \\ d_3 \end{matrix} \right) \]
\[ A = \left( \begin{matrix} 0.2 & 0.3 & 0.2 \\ 0.4 & 0.1 & 0.2 \\ 0.1 & 0.3 & 0.2 \end{matrix} \right) \]
Hence,
\[ x - Ax = d \\ (I - A)x = d \\ x = (I - A)^{-1}d \]
Therefore,
\[ \left( \begin{matrix} x_1 \\ x_2 \\ x_3 \end{matrix} \right) = \left(\begin{matrix} \left[ \begin{matrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{matrix} \right ] - \left[ \begin{matrix} 0.2 & 0.3 & 0.2 \\ 0.4 & 0.1 & 0.2 \\ 0.1 & 0.3 & 0.2 \end{matrix} \right] \end{matrix} \right)^{-1} \left( \begin{matrix} d_1 \\ d_2 \\ d_3 \end{matrix} \right) \]
今度は、これをR言語で記述していきましょう。
# load library
pacman::p_load("matlib", "dplyr")
# the matrix A (technology matrix)
A <- matrix(c(0.2, 0.3, 0.2,
0.4, 0.1, 0.2,
0.1, 0.3, 0.1),
ncol = 3)
# (I - A)^(-1)
A_id <- diag(ncol(A))
result <- inv(A_id - A) %>% round(2)
result## [,1] [,2] [,3]
## [1,] 1.69 0.86 0.47
## [2,] 0.74 1.58 0.61
## [3,] 0.54 0.54 1.35
これを方程式の形に直すとこうなります。
\[ x_1 = d_1 + 1.69d_1 + 0.86d_2 + 0.47d_3 \\ x_2 = d_1 + 0.74d_1 + 1.58d_2 + 0.61d_3 \\ x_3 = d_1 + 0.54d_1 + 0.54d_2 + 1.35d_3 \\ \]
結果的に、全ての産業のOutputをexternal demandの形に直すことができました。
宿題で出てきた問題についても見ていきましょう。
Exercise 4, question5
まず、Input-output tableの形に直します。
library(tidyverse)
# external demand
d_1 <- 25000
d_2 <- 50000
d_3 <- 0
# input-ouptut table
df <- tibble(
output = c("coal", "electricity", "railway"),
coal = c(0, 0.65, 0.55),
electricity = c(0.25, 0.05, 0.1),
railway = c(0.25, 0.05, 0)
)
df## # A tibble: 3 x 4
## output coal electricity railway
## <chr> <dbl> <dbl> <dbl>
## 1 coal 0 0.25 0.25
## 2 electricity 0.65 0.05 0.05
## 3 railway 0.55 0.1 0
これを式に直すと、
\[ x_1 = d_1 + 0x_1 + 0.25x_2 + 0.25x_3 \\ x_2 = d_2 + 0.65x_1 + 0.05x_2 + 0.05x_3 \\ x_3 = d_3 + 0.55x_1 + 0.1x_2 + 0x_3 \\ \]
\((I-A)^{-1}\)を計算すると、
# the matrix A (technology matrix)
A <- as.matrix(df[1:3, 2:4])
# (I - A)^(-1)
A_id <- diag(ncol(A))
result <- inv(A_id - A) %>% round(2)
result##
## [1,] 1.50 0.44 0.40
## [2,] 1.08 1.37 0.34
## [3,] 0.93 0.38 1.25
今回は、\(d_1 = 2.5\times 10^{4}\)、\(d_2 = 5\times 10^{4}\)、\(d_3 = 0\)で与えられているので、Outputをexternal demandの形で表した方程式の形に直すとこうなります。
\[ x_1 = d_1 + 1.5d_1 + 0.44d_2 + 0.4d_3 \\ x_2 = d_2 + 1.08d_1 + 1.37d_2 + 0.34d_3 \\ x_3 = d_3 + 0.93d_1 + 0.38d_2 + 1.25d_3 \\ \]
\[ x_1 = 8.45\times 10^{4} \\ x_2 = 1.455\times 10^{5} \\ x_3 = 4.225\times 10^{4} \\ \]
応用として、electricityの生産に必要なcoalの量が減少する(0.25→0.1)技術革新のケースを見てみましょう。
# define the matrix
df_tech <- tibble(
output = c("coal", "electricity", "railway"),
coal = c(0, 0.65, 0.55),
electricity = c(0.1, 0.05, 0.1), # 0.25 -> 0.1
railway = c(0.25, 0.05, 0)
)
# the matrix A (technology matrix)
A_tech <- as.matrix(df_tech[1:3, 2:4])
# (I - A)^(-1)
A_id_tech <- diag(ncol(A_tech))
result_tech <- inv(A_id_tech - A_tech) %>% round(2)
# the initial case
result##
## [1,] 1.50 0.44 0.40
## [2,] 1.08 1.37 0.34
## [3,] 0.93 0.38 1.25
##
## [1,] 1.29 0.17 0.33
## [2,] 0.93 1.18 0.29
## [3,] 0.80 0.21 1.21
これを使って、Economic impactを計算しようと思ったのですが、なかなか難しそうなので、とりあえずここまでで終わりにしたいと思います。