sube packages the core SUBE workflow into a small set of
reusable functions. It is intended both as a practical toolkit for
supply-use based econometrics and as a companion package to the Stehrer,
Rueda-Cantuche, Amores, and Zenz paper on confidence intervals for
input-output multipliers.
Companion paper: Wrapping input-output multipliers in confidence intervals, Journal of Economic Structures 13, 17 (2024).
The central idea is that rectangular supply and use tables can support more than point-estimate Leontief analysis alone. With the right data preparation, they can also support econometric multiplier work, comparison plots, and a more explicit treatment of uncertainty across countries, products, and years.
That paper motivation matters for the package design.
sube does not treat the econometric layer as a side
calculation after Leontief analysis; it treats Leontief benchmarks, SUBE
estimates, and comparison plots as one coherent research workflow.
This vignette shows the compact public workflow used across the package docs:
- import or load supply-use data,
- build domestic matrices,
- compute Leontief benchmark results,
- estimate SUBE models, and
- compare or export both layers from package objects.
All examples below use only the shipped sample data, so the full workflow can be verified from a clean checkout without external downloads. The package works with any supply-use data in the canonical long format - WIOD and FIGARO are two built-in importers, but you can also bring your own source. Readers who want to skip ahead to input contracts and format details can jump to the data-preparation vignette.
Load sample inputs
The shipped example objects map directly to the workflow stages:
sut_data for supply-use tables, cpa_map and
ind_map for aggregation, inputs for the
compute layer, and model_data for SUBE estimation.
sut <- sube_example_data("sut_data")
cpa_map <- sube_example_data("cpa_map")
ind_map <- sube_example_data("ind_map")
inputs <- sube_example_data("inputs")Build matrices
domestic <- extract_domestic_block(sut)
bundle <- build_matrices(domestic, cpa_map, ind_map)
names(bundle)
#> [1] "aggregated" "final_demand" "matrices" "model_data"The matrix bundle should expose the aggregated long data, final demand, and the country-year matrix list used by the compute layer.
names(bundle$matrices)
#> [1] "AAA_2020"Compute Leontief benchmark results
result <- compute_sube(bundle, inputs)
head(result$summary)
#> YEAR COUNTRY CPAagg GO VA EMP CO2 FD GOe
#> <int> <char> <char> <num> <num> <num> <num> <num> <num>
#> 1: 2020 AAA P01 1.625000 0.5416667 0.3993056 0.2569444 6 3.192982
#> 2: 2020 AAA P02 1.428571 0.4761905 0.3214286 0.1666667 5 2.339181
#> VAe EMPe CO2e
#> <num> <num> <num>
#> 1: 3.192982 3.324157 3.639344
#> 2: 2.339181 2.229869 1.967213The returned object contains both tidy outputs and the underlying matrix layer.
names(result)
#> [1] "summary" "tidy" "diagnostics" "matrices"
names(result$matrices[[1]])
#> [1] "country" "year" "A" "L"
result$diagnostics
#> country year status
#> <char> <int> <char>
#> 1: AAA 2020 okWith the shipped sample data, the diagnostics table should report
ok. On real inputs, this table is the first place to check
for singular supply, gross output, or Leontief branches.
Estimate SUBE models
The shipped model_data is a tiny synthetic fixture, so
estimate_elasticities() emits NaN/“essentially
perfect fit” warnings here. Those are artefacts of the small sample -
real datasets do not trigger them. Warnings are suppressed below to keep
the output readable.
model_data <- sube_example_data("model_data")
models <- estimate_elasticities(model_data, predictor_vars = c("P01", "P02"))
head(models$tidy)
#> term estimate std.error statistic p.value lwr upr mean mean_y
#> <char> <num> <num> <num> <num> <num> <num> <num> <num>
#> 1: P01 2.0 NaN NaN NaN NA NA 1.5 4.50
#> 2: P02 1.0 NaN NaN NaN NA NA 1.5 4.50
#> 3: P01 0.5 NaN NaN NaN NA NA 1.5 1.05
#> 4: P02 0.2 NaN NaN NaN NA NA 1.5 1.05
#> 5: P01 0.3 NaN NaN NaN NA NA 1.5 0.60
#> 6: P02 0.1 NaN NaN NaN NA NA 1.5 0.60
#> elasticity COUNTRY YEAR y type
#> <num> <char> <int> <char> <char>
#> 1: 0.6666667 AAA 2020 GO ols
#> 2: 0.3333333 AAA 2020 GO ols
#> 3: 0.7142857 AAA 2020 VA ols
#> 4: 0.2857143 AAA 2020 VA ols
#> 5: 0.7500000 AAA 2020 EMP ols
#> 6: 0.2500000 AAA 2020 EMP olsCompare Leontief and SUBE outputs
comparison <- prepare_sube_comparison(
leontief = result,
models = models,
measure = "multiplier",
variables = c("GO", "VA")
)
head(comparison)
#> COUNTRY CPAagg variable measure type value estimate elasticity
#> <char> <char> <fctr> <char> <char> <num> <num> <num>
#> 1: AAA P01 GO multiplier leontief 1.6250000 NaN NaN
#> 2: AAA P02 GO multiplier leontief 1.4285714 NaN NaN
#> 3: AAA P01 VA multiplier leontief 0.5416667 NaN NaN
#> 4: AAA P02 VA multiplier leontief 0.4761905 NaN NaN
#> 5: AAA P01 GO elasticity leontief 3.1929825 NaN NaN
#> 6: AAA P02 GO elasticity leontief 2.3391813 NaN NaN
#> lwr upr CPAgroup
#> <num> <num> <char>
#> 1: NaN NaN P01-P11
#> 2: NaN NaN P01-P11
#> 3: NaN NaN P01-P11
#> 4: NaN NaN P01-P11
#> 5: NaN NaN P01-P11
#> 6: NaN NaN P01-P11The comparison layer is designed to support the same country, product, density, regression, and export paths described in the README and modeling/output vignette.
country_plots <- plot_paper_comparison(
comparison,
kind = "by_country",
measure = "multiplier",
variables = "GO"
)
paper_regression <- plot_paper_regression(
comparison,
method = "between",
measure = "multiplier",
variables = "GO"
)
write_sube("outputs/benchmark_summary", result$summary, format = "csv")Relation to the companion paper
The package workflow mirrors the broad structure used in the companion paper:
- start from supply and use data,
- derive domestic and aggregated matrices,
- compute Leontief-style benchmark results,
- estimate SUBE regressions on prepared modeling tables, and
- compare benchmark and econometric results with common plotting layouts.
The shipped example data is intentionally tiny, but the workflow is meant to scale to larger inter-country and multi-year settings of the kind discussed in the paper.