<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>iotables | Antal Dániel honlapja</title><link>https://danielantal.eu/hu/tag/iotables/</link><atom:link href="https://danielantal.eu/hu/tag/iotables/index.xml" rel="self" type="application/rss+xml"/><description>iotables</description><generator>Wowchemy (https://wowchemy.com)</generator><language>hu</language><lastBuildDate>Thu, 03 Jun 2021 16:00:00 +0000</lastBuildDate><image><url>https://danielantal.eu/media/icon_hub9491570ac57158c0eeecc95c95b13e5_20247_512x512_fill_lanczos_center_3.png</url><title>iotables</title><link>https://danielantal.eu/hu/tag/iotables/</link></image><item><title>Economic and Environment Impact Analysis, Automated for Data-as-Service</title><link>https://danielantal.eu/hu/post/2021-06-03-iotables-release/</link><pubDate>Thu, 03 Jun 2021 16:00:00 +0000</pubDate><guid>https://danielantal.eu/hu/post/2021-06-03-iotables-release/</guid><description>&lt;p>We have released a new version of
&lt;a href="https://iotables.dataobservatory.eu/" target="_blank" rel="noopener">iotables&lt;/a> as part of the
&lt;a href="http://ropengov.org/" target="_blank" rel="noopener">rOpenGov&lt;/a> project. The package, as the name
suggests, works with European symmetric input-output tables (SIOTs).
SIOTs are among the most complex governmental statistical products. They
show how each country’s 64 agricultural, industrial, service, and
sometimes household sectors relate to each other. They are estimated
from various components of the GDP, tax collection, at least every five
years.&lt;/p>
&lt;p>SIOTs offer great value to policy-makers and analysts to make more than
educated guesses on how a million euros, pounds or Czech korunas spent
on a certain sector will impact other sectors of the economy, employment
or GDP. What happens when a bank starts to give new loans and advertise
them? How is an increase in economic activity going to affect the amount
of wages paid and and where will consumers most likely spend their
wages? As the national economies begin to reopen after COVID-19 pandemic
lockdowns, is to utilize SIOTs to calculate direct and indirect
employment effects or value added effects of government grant programs
to sectors such as cultural and creative industries or actors such as
venues for performing arts, movie theaters, bars and restaurants.&lt;/p>
&lt;p>Making such calculations requires a bit of matrix algebra, and
understanding of input-output economics, direct, indirect effects, and
multipliers. Economists, grant designers, policy makers have those
skills, but until now, such calculations were either made in cumbersome
Excel sheets, or proprietary software, as the key to these calculations
is to keep vectors and matrices, which have at least one dimension of
64, perfectly aligned. We made this process reproducible with
&lt;a href="https://iotables.dataobservatory.eu/" target="_blank" rel="noopener">iotables&lt;/a> and
&lt;a href="https://CRAN.R-project.org/package=eurostat" target="_blank" rel="noopener">eurostat&lt;/a> on
&lt;a href="http://ropengov.org/" target="_blank" rel="noopener">rOpenGov&lt;/a>&lt;/p>
&lt;figure id="figure-our-iotables-package-creates-direct-indirect-effects-and-multipliers-programatically-our-observatory-will-make-those-indicators-available-for-all-european-countries">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://danielantal.eu/media/img/package_screenshots/iotables_0_4_5.png" alt="Our iotables package creates direct, indirect effects and multipliers programatically. Our observatory will make those indicators available for all European countries." loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption data-pre="&amp;nbsp;" data-post=". ábra:&amp;nbsp;" class="numbered">
Our iotables package creates direct, indirect effects and multipliers programatically. Our observatory will make those indicators available for all European countries.
&lt;/figcaption>&lt;/figure>
&lt;h2 id="accessing-and-tidying-the-data-programmatically">Accessing and tidying the data programmatically&lt;/h2>
&lt;p>The iotables package is in a way an extension to the &lt;em>eurostat&lt;/em> R
package, which provides a programmatic access to the
&lt;a href="https://ec.europa.eu/eurostat" target="_blank" rel="noopener">Eurostat&lt;/a> data warehouse. The reason for
releasing a new package is that working with SIOTs requires plenty of
meticulous data wrangling based on various &lt;em>metadata&lt;/em> sources, apart
from actually accessing the &lt;em>data&lt;/em> itself. When working with matrix
equations, the bar is higher than with tidy data. Not only your rows and
columns must match, but their ordering must strictly conform the
quadrants of the a matrix system, including the connecting trade or tax
matrices.&lt;/p>
&lt;p>When you download a country’s SIOT table, you receive a long form data
frame, a very-very long one, which contains the matrix values and their
labels like this:&lt;/p>
&lt;pre>&lt;code>## Table naio_10_cp1700 cached at C:\Users\...\Temp\RtmpGQF4gr/eurostat/naio_10_cp1700_date_code_FF.rds
# we save it for further reference here
saveRDS(naio_10_cp1700, &amp;quot;not_included/naio_10_cp1700_date_code_FF.rds&amp;quot;)
# should you need to retrieve the large tempfiles, they are in
dir (file.path(tempdir(), &amp;quot;eurostat&amp;quot;))
dplyr::slice_head(naio_10_cp1700, n: 5)
## # A tibble: 5 x 7
## unit stk_flow induse prod_na geo time values
## &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;chr&amp;gt; &amp;lt;date&amp;gt; &amp;lt;dbl&amp;gt;
## 1 MIO_EUR DOM CPA_A01 B1G EA19 2019-01-01 141873.
## 2 MIO_EUR DOM CPA_A01 B1G EU27_2020 2019-01-01 174976.
## 3 MIO_EUR DOM CPA_A01 B1G EU28 2019-01-01 187814.
## 4 MIO_EUR DOM CPA_A01 B2A3G EA19 2019-01-01 0
## 5 MIO_EUR DOM CPA_A01 B2A3G EU27_2020 2019-01-01 0
&lt;/code>&lt;/pre>
&lt;p>The metadata reads like this: the units are in millions of euros, we are
analyzing domestic flows, and the national account items &lt;code>B1-B2&lt;/code> for the
industry &lt;code>A01&lt;/code>. The information of a 64x64 matrix (the SIOT) and its
connecting matrices, such as taxes, or employment, or &lt;em>C**O&lt;/em>&lt;sub>2&lt;/sub>
emissions, must be placed exactly in one correct ordering of columns and
rows. Every single data wrangling error will usually lead in an error
(the matrix equation has no solution), or, what is worse, in a very
difficult to trace algebraic error. Our package not only labels this
data meaningfully, but creates very tidy data frames that contain each
necessary matrix of vector with a key column.&lt;/p>
&lt;p>iotables package contains the vocabularies (abbreviations and human
readable labels) of three statistical vocabularies: the so called
&lt;code>COICOP&lt;/code> product codes, the &lt;code>NACE&lt;/code> industry codes, and the vocabulary of
the &lt;code>ESA2010&lt;/code> definition of national accounts (which is the government
equivalent of corporate accounting).&lt;/p>
&lt;p>Our package currently solves all equations for direct, indirect effects,
multipliers and inter-industry linkages. Backward linkages show what
happens with the suppliers of an industry, such as catering or
advertising in the case of music festivals, if the festivals reopen. The
forward linkages show how much extra demand this creates for connecting
services that treat festivals as a ‘supplier’, such as cultural tourism.&lt;/p>
&lt;h2 id="lets-seen-an-example">Let’s seen an example&lt;/h2>
&lt;pre>&lt;code>## Downloading employment data from the Eurostat database.
## Table lfsq_egan22d cached at C:\Users\...\Temp\RtmpGQF4gr/eurostat/lfsq_egan22d_date_code_FF.rds
&lt;/code>&lt;/pre>
&lt;p>and match it with the latest structural information on from the
&lt;a href="http://appsso.eurostat.ec.europa.eu/nui/show.do?wai=true&amp;amp;dataset=naio_10_cp1700" target="_blank" rel="noopener">Symmetric input-output table at basic prices (product by
product)&lt;/a>
Eurostat product. A quick look at the Eurostat website already shows
that there is a lot of work ahead to make the data look like an actual
Symmetric input-output table. Download it with &lt;code>iotable_get()&lt;/code> which
does basic labelling and preprocessing on the raw Eurostat files.
Because of the size of the unfiltered dataset on Eurostat, the following
code may take several minutes to run.&lt;/p>
&lt;pre>&lt;code>sk_io &amp;lt;- iotable_get ( labelled_io_data: NULL,
source: &amp;quot;naio_10_cp1700&amp;quot;, geo: &amp;quot;SK&amp;quot;,
year: 2015, unit: &amp;quot;MIO_EUR&amp;quot;,
stk_flow: &amp;quot;TOTAL&amp;quot;,
labelling: &amp;quot;iotables&amp;quot; )
## Reading cache file C:\Users\..\Temp\RtmpGQF4gr/eurostat/naio_10_cp1700_date_code_FF.rds
## Table naio_10_cp1700 read from cache file: C:\Users\..\Temp\RtmpGQF4gr/eurostat/naio_10_cp1700_date_code_FF.rds
## Saving 808 input-output tables into the temporary directory
## C:\Users\...\Temp\RtmpGQF4gr
## Saved the raw data of this table type in temporary directory C:\Users\...\Temp\RtmpGQF4gr/naio_10_cp1700.rds.
&lt;/code>&lt;/pre>
&lt;p>The &lt;code>input_coefficient_matrix_create()&lt;/code> creates the input coefficient
matrix, which is used for most of the analytical functions.&lt;/p>
&lt;p>&lt;em>a&lt;/em>&lt;sub>&lt;em>i**j&lt;/em>&lt;/sub>: &lt;em>X&lt;/em>&lt;sub>&lt;em>i**j&lt;/em>&lt;/sub> / &lt;em>x&lt;/em>&lt;sub>&lt;em>j&lt;/em>&lt;/sub>&lt;/p>
&lt;p>It checks the correct ordering of columns, and furthermore it fills up 0
values with 0.000001 to avoid division with zero.&lt;/p>
&lt;pre>&lt;code>input_coeff_matrix_sk &amp;lt;- input_coefficient_matrix_create(
data_table: sk_io
)
## Columns and rows of real_estate_imputed_a, extraterriorial_organizations are all zeros and will be removed.
&lt;/code>&lt;/pre>
&lt;p>Then you can create the Leontieff-inverse, which contains all the
structural information about the relationships of 64x64 sectors of the
chosen country, in this case, Slovakia, ready for the main equations of
input-output economics.&lt;/p>
&lt;pre>&lt;code>I_sk &amp;lt;- leontieff_inverse_create(input_coeff_matrix_sk)
&lt;/code>&lt;/pre>
&lt;p>And take out the primary inputs:&lt;/p>
&lt;pre>&lt;code>primary_inputs_sk &amp;lt;- coefficient_matrix_create(
data_table: sk_io,
total: 'output',
return: 'primary_inputs')
## Columns and rows of real_estate_imputed_a, extraterriorial_organizations are all zeros and will be removed.
&lt;/code>&lt;/pre>
&lt;p>Now let’s see if there the government tries to stimulate the economy in
three sectors, agricultulre, car manufacturing, and R&amp;amp;D with a billion
euros. Direct effects measure the initial, direct impact of the change
in demand and supply for a product. When production goes up, it will
create demand in all supply industries (backward linkages) and create
opportunities in the industries that use the product themselves (forward
linkages.)&lt;/p>
&lt;pre>&lt;code>direct_effects_create( primary_inputs_sk, I_sk ) %&amp;gt;%
select ( all_of(c(&amp;quot;iotables_row&amp;quot;, &amp;quot;agriculture&amp;quot;,
&amp;quot;motor_vechicles&amp;quot;, &amp;quot;research_development&amp;quot;))) %&amp;gt;%
filter (.data$iotables_row %in% c(&amp;quot;gva_effect&amp;quot;, &amp;quot;wages_salaries_effect&amp;quot;,
&amp;quot;imports_effect&amp;quot;, &amp;quot;output_effect&amp;quot;))
## iotables_row agriculture motor_vechicles research_development
## 1 imports_effect 1.3684350 2.3028203 0.9764921
## 2 wages_salaries_effect 0.2713804 0.3183523 0.3828014
## 3 gva_effect 0.9669621 0.9790771 0.9669467
## 4 output_effect 2.2876287 3.9840251 2.2579634
&lt;/code>&lt;/pre>
&lt;p>Car manufacturing requires much imported components, so each extra
demand will create a large importing activity. The R&amp;amp;D will create a the
most local wages (and supports most jobs) because research is
job-intensive. As we can see, the effect on imports, wages, gross value
added (which will end up in the GDP) and output changes are very
different in these three sectors.&lt;/p>
&lt;p>This is not the total effect, because some of the increased production
will translate into income, which in turn will be used to create further
demand in all parts of the domestic economy. The total effect is
characterized by multipliers.&lt;/p>
&lt;p>Then solve for the multipliers:&lt;/p>
&lt;pre>&lt;code>multipliers_sk &amp;lt;- input_multipliers_create(
primary_inputs_sk %&amp;gt;%
filter (.data$iotables_row == &amp;quot;gva&amp;quot;), I_sk )
&lt;/code>&lt;/pre>
&lt;p>And select a few industries:&lt;/p>
&lt;pre>&lt;code>set.seed(12)
multipliers_sk %&amp;gt;%
tidyr::pivot_longer ( -all_of(&amp;quot;iotables_row&amp;quot;),
names_to: &amp;quot;industry&amp;quot;,
values_to: &amp;quot;GVA_multiplier&amp;quot;) %&amp;gt;%
select (-all_of(&amp;quot;iotables_row&amp;quot;)) %&amp;gt;%
arrange( -.data$GVA_multiplier) %&amp;gt;%
dplyr::sample_n(8)
## # A tibble: 8 x 2
## industry GVA_multiplier
## &amp;lt;chr&amp;gt; &amp;lt;dbl&amp;gt;
## 1 motor_vechicles 7.81
## 2 wood_products 2.27
## 3 mineral_products 2.83
## 4 human_health 1.53
## 5 post_courier 2.23
## 6 sewage 1.82
## 7 basic_metals 4.16
## 8 real_estate_services_b 1.48
&lt;/code>&lt;/pre>
&lt;h2 id="vignettes">Vignettes&lt;/h2>
&lt;p>The &lt;a href="https://iotables.dataobservatory.eu/articles/germany_1990.html" target="_blank" rel="noopener">Germany
1990&lt;/a>
provides an introduction of input-output economics and re-creates the
examples of the &lt;a href="https://iotables.dataobservatory.eu/articles/germany_1990.html" target="_blank" rel="noopener">Eurostat Manual of Supply, Use and Input-Output
Tables&lt;/a>,
by Jörg Beutel (Eurostat Manual).&lt;/p>
&lt;p>The &lt;a href="https://iotables.dataobservatory.eu/articles/united_kingdom_2010.html" target="_blank" rel="noopener">United Kingdom Input-Output Analytical Tables Daniel Antal, based
on the work edited by Richard
Wild&lt;/a>
is a use case on how to correctly import data from outside Eurostat
(i.e. not with &lt;code>eurostat::get_eurostat()&lt;/code>) and join it properly to a
SIOT. We also used this example to create unit tests of our functions
from a published, official government statistical release.&lt;/p>
&lt;p>Finally, &lt;a href="https://iotables.dataobservatory.eu/articles/working_with_eurostat.html" target="_blank" rel="noopener">Working With Eurostat
Data&lt;/a>
is a detailed use case of working with all the current functionalities
of the package by comparing two economies, Czechia and Slovakia and
guides you through a lot more examples than this short blogpost.&lt;/p>
&lt;p>Our package was originally developed to calculate GVA and employment
effects for the Slovak music industry (see our &lt;a href="https://music.dataobservatory.eu/publication/slovak_music_industry_2019/" target="_blank" rel="noopener">Slovak Music Industry Report&lt;/a>), and similar calculations for the
Hungarian film tax shelter. We can now programatically create
reproducible multipliers for all European economies in the &lt;a href="https://music.dataobservatory.eu/" target="_blank" rel="noopener">Digital
Music Observatory&lt;/a>, and create
further indicators for economic policy making in the &lt;a href="https://economy.dataobservatory.eu/" target="_blank" rel="noopener">Economy Data
Observatory&lt;/a>.&lt;/p>
&lt;h2 id="environmental-impact-analysis">Environmental Impact Analysis&lt;/h2>
&lt;p>Our package allows the calculation of various economic policy scenarios,
such as changing the VAT on meat or effects of re-opening music
festivals on aggregate demand, GDP, tax revenues, or employment. But
what about the &lt;em>C**O&lt;/em>&lt;sub>2&lt;/sub>, methane and other greenhouse gas
effects of the reopening festivals, or the increasing meat prices?&lt;/p>
&lt;p>Technically our package can already calculate such effects, but to do
so, you have to carefully match further statistical vocabulary items
used by the European Environmental Agency about air pollutants and
greenhouse gases.&lt;/p>
&lt;p>The last released version of &lt;em>iotables&lt;/em> is Importing and Manipulating
Symmetric Input-Output Tables (Version 0.4.4). Zenodo.
&lt;a href="https://zenodo.org/record/4897472" target="_blank" rel="noopener">https://doi.org/10.5281/zenodo.4897472&lt;/a>,
but we are alread working on a new major release. In that release, we
are planning to build in the necessary vocabulary into the metadata
functions to increase the functionality of the package, and create new
indicators for our &lt;a href="https://greendeal.dataobservatory.eu/" target="_blank" rel="noopener">Green Deal Data
Observatory&lt;/a>. This experimental
data observatory is creating new, high quality statistical indicators
from open governmental and open science data sources that has not seen
the daylight yet.&lt;/p>
&lt;h2 id="ropengov-and-the-eu-datathon-challenges">rOpenGov and the EU Datathon Challenges&lt;/h2>
&lt;figure id="figure-ropengov-reprex-and-other-open-collaboration-partners-teamed-up-to-build-on-our-expertise-of-open-source-statistical-software-development-further-we-want-to-create-a-technologically-and-financially-feasible-data-as-service-to-put-our-reproducible-research-products-into-wider-user-for-the-business-analyst-scientific-researcher-and-evidence-based-policy-design-communities">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://danielantal.eu/media/img/partners/rOpenGov-intro.png" alt="rOpenGov, Reprex, and other open collaboration partners teamed up to build on our expertise of open source statistical software development further: we want to create a technologically and financially feasible data-as-service to put our reproducible research products into wider user for the business analyst, scientific researcher and evidence-based policy design communities." loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption data-pre="&amp;nbsp;" data-post=". ábra:&amp;nbsp;" class="numbered">
rOpenGov, Reprex, and other open collaboration partners teamed up to build on our expertise of open source statistical software development further: we want to create a technologically and financially feasible data-as-service to put our reproducible research products into wider user for the business analyst, scientific researcher and evidence-based policy design communities.
&lt;/figcaption>&lt;/figure>
&lt;p>&lt;a href="http://ropengov.org/" target="_blank" rel="noopener">rOpenGov&lt;/a> is a community of open governmental
data and statistics developers with many packages that make programmatic
access and work with open data possible in the R language.
&lt;a href="https://reprex.nl/" target="_blank" rel="noopener">Reprex&lt;/a> is a Dutch-startup that teamed up with
rOpenGov and other open collaboration partners to create a
technologically and financially feasible service to exploit reproducible
research products for the wider business, scientific and evidence-based
policy design community. Open data is a legal concept - it means that
you have the rigth to reuse the data, but often the reuse requires
significant programming and statistical know-how. We entered into the
annual &lt;a href="https://reprex.nl/project/eu-datathon_2021/" target="_blank" rel="noopener">EU Datathon&lt;/a>
competition in all three challenges with our applications to not only
provide open-source software, but daily updated, validated, documented,
high-quality statistical indicators as open data in an open database.
Our &lt;a href="https://iotables.dataobservatory.eu/" target="_blank" rel="noopener">iotables&lt;/a> package is one of
our many open-source building blocks to make open data more accessible
to all.&lt;/p>
&lt;p>&lt;em>Join our open collaboration Digital Music Observatory team as a &lt;a href="https://music.dataobservatory.eu/authors/curator" target="_blank" rel="noopener">data curator&lt;/a>, &lt;a href="https://music.dataobservatory.eu/authors/developer" target="_blank" rel="noopener">developer&lt;/a> or &lt;a href="https://music.dataobservatory.eu/authors/team" target="_blank" rel="noopener">business developer&lt;/a>. More interested in environmental impact analysis? Try our &lt;a href="https://greendeal.dataobservatory.eu/#contributors" target="_blank" rel="noopener">Green Deal Data Observatory&lt;/a> team! Or economic policies, particularly computation antitrust, innovation and small enterprises? Check out our &lt;a href="https://economy.dataobservatory.eu/#contributors" target="_blank" rel="noopener">Economy Music Observatory&lt;/a> team!&lt;/em>&lt;/p></description></item></channel></rss>