# An Open-Source R Package for Building and Using US Environmentally-Extended Input-Output Models
## 2 Materials & Methods
### EEIO Matrices Construction  
The last step to build a complete USEEIO model is to construct EEIO matrices based on previously loaded IO, satellite, and indicator tables. model <- constructEEIOMatrices(model)  
Satellite tables are first combined into one _totals_by_sector_ table, \(TbS\). The \(TbS\) table is then used to calculate coefficients-by-sector and generate a \(CbS\) table. IO tables loaded by previous step are formed into matrices and vectors with standard notations:  
* The Make matrix, \(V\), is an industry x commodity matrix with amounts in commodities in year USD produced by industries;
* The Use matrix, \(U\), is a commodity x industry matrix with total amounts in model year USD of commodities used by industries for intermediate production, or used by final consumers. \(U\) also includes commodity imports, exports, and change in inventories as components of final demand, and value added components as inputs to industries;
* The domestic Use matrix, \(U_{d}\), is a commodity x industry matrix that provides commodity and value added use totals by industries, and final demand, only from the US;
* The commodity output vector, \(q\), and the industry output vector, \(x\), contain economic gross output in model year US dollars;
* The market shares matrix, \(V_{n}\), is a \(q\) normalized form of \(V\), also in industry x commodity format;
* The commodity mix matrix, \(C_{m}\), is an \(x\) normalized and transposed form of \(V\) in commodity x industry format. Model matrices are then prepared. The direct requirements matrix, \(A\), is a sector x sector matrix that contains in each column, \(i\), the direct sector inputs required to produce USD 1 of output from sector \(i\). \(A\) is created from the normalized forms of the model make, \(V\), and use, \(U\), tables in one of two ways, depending on if the model type was set to be commodity or industry (Equations (1) and (2)). \[A(c) =U_{n}*V_{n} \tag{1}\] \[A(i) =V_{n}*U_{n}\] (2) \[U_{n} =U\xi^{-1}\] (3) \[V_{n} =V\bar{q}^{-1} \tag{4}\]  
The domestic direct requirements matrix, \(A_{d}\), is a sector x sector matrix that provides direct sector inputs per dollar sector output, only from the US. Similar to \(A\), \(A_{d}\) is created from the normalized forms of the model Make, \(V\), and Use, \(U_{d}\), tables in one of two ways, depending on if the model type is set to be commodity or industry in the model configuration file (Equations (5) and (6)). \[A_{d}(c) = U_{d_{n}}*V_{n} \tag{5}\] \[A_{d}(i) = V_{n}*U_{d_{n}}\] (6) \[U_{d_{n}} = U_{d}\hat{x}^{-1} \tag{7}\]  
The total requirements matrix, \(L\) (the Leontief inverse of \(A\)), is a sector x sector matrix that contains in each column, \(i\), the total requirements of the respective sectors inputs per 1 USD of output from sector \(i\). \(L\) is obtained from \(A\), using Equation (8). \[L=\left(I-A\right)^{-1} \tag{8}\]  
The domestic total requirements matrix \(L_{d}\) (the Leontief inverse of \(A_{d}\)), is a sector x sector matrix that provides total sector inputs per dollar sector output, only from the US. \(L_{d}\) is obtained from \(A_{d}\), using Equation (9). \[L_{d}=\left(I-A_{d}\right)^{-1} \tag{9}\]  
The direct emission and resource use matrix, \(B\), is a flow x sector matrix that contains in each column, \(i\), the amount of a flow given in the reference units of the respective flow (e.g., kg) per USD 1 output from sector \(i\). To obtain \(B\), \(B(i)\) is first derived from \(E\), a emission x industry matrix of national totals of each flow by industry sector in year \(y\), and \(x_{z,y}\), a vector of gross output by industry in year \(z\), given in year \(y\) dollars (Equation (10)). \[B(i)_{y}=E_{z}\hat{x}_{z,y}^{-1} \tag{10}\]  
The industries in the \(E\) columns match the industries in \(x\). For \(x\) to be in year \(y\) USD, the year of the IO data, \(x\), must first be price adjusted using Equation (11), where \(x_{z}\) is the year industry output for industry, \(i\), in the currency year, \(z\), corresponding to the year of the national flow totals.