Sets and Parameters

WiNDCNational is built using WiNDCContainer, which provides a flexible way to define and manage sets and parameters within the data model. We will provide a listing of the sets used and demonstrate how to access and view them in code.

The sets and parameters are the same for both the summary and detailed tables. For this reason we will use the summary table as the basis for our examples.

using WiNDCNational
using DataFrames
summary = build_us_table(:summary);

Sets

To view all the sets, use the sets function:

sets(summary) |> x-> sort(x, [:domain, :name])
40×3 DataFrame
Rownamedescriptiondomain
SymbolStringSymbol
1dutyDutycol
2exportExportscol
3government_final_demandGovernment portions of final demandcol
4importImportscol
5investment_final_demandInvestment portions of final demandcol
6marginMargin sectorscol
7personal_consumptionPersonal consumption expenditurescol
8sectorSectorscol
9subsidySubsidycol
10taxTaxcol
11tradeTradecol
12transportTransportcol
13Capital_Demandparameter
14Dutyparameter
15Exportparameter
16Final_DemandFinal demandparameter
17Government_Final_Demandparameter
18Household_SupplyPositive values in PCE (negative in USE table)parameter
19Importparameter
20Intermediate_Demandparameter
21Intermediate_Supplyparameter
22Investment_Final_Demandparameter
23Labor_Demandparameter
24Margin_DemandPositive values in marginal categoriesparameter
25Margin_SupplyNegative values in marginal categoriesparameter
26Other_Final_DemandNon-export components of final demandparameter
27Output_Taxparameter
28Personal_ConsumptionNegative values in PCE (positive in USE table)parameter
29Sector_Subsidyparameter
30Subsidyparameter
31SupplySupply (or output) sections of the IO tableparameter
32Taxparameter
33UseUse (or input) sections of the IO tableparameter
34Value_AddedValue addedparameter
35capital_demandGross operating surplusrow
36commodityCommoditiesrow
37labor_demandCompensation of employeesrow
38output_taxOutput taxrow
39sector_subsidySector subsidyrow
40yearyear

The |> x -> sort(x, :[:domain, :name]) sorts the sets by their domain, or the column in the data table where the set elements are located, and their name.

By convention we use snake_case for sets that do not have the parameter domain.

Let's consider the set margin with domain col. I would like to view the elements:

elements(summary, :margin)
2×3 DataFrame
Rownamedescriptionset
AnyAnySymbol
1TradeTrade marginsmargin
2TransTransport marginsmargin

The values in the name column are the elements of the set, they are NAICS codes as they appear in the BEA input/output tables. To examine the actual data use:

table(summary, :margin) |> x -> first(x, 5)
5×5 DataFrame
Rowrowcolyearparametervalue
AnySymbol?Int64SymbolFloat64
1111CATrans1998margin_demand20.257
2113FFTrans1998margin_demand2.421
3211Trans1998margin_demand22.533
4212Trans1998margin_demand14.247
5321Trans1998margin_demand4.592

This will show the first 5 rows of the data table restricted to the margin set. Recall margin had domain col and that is the column where the elements live. To demonstrate the multiple values in col, just view the unique values:

table(summary, :margin) |> x -> unique(x, :col)
2×5 DataFrame
Rowrowcolyearparametervalue
AnySymbol?Int64SymbolFloat64
1111CATrans1998margin_demand20.257
2111CATrade1998margin_demand45.523

Because we are only viewing the first few rows, we only see the Trans code. We can further filter the data by specifying a particular element:

table(summary, :margin => :Trade) |> x -> first(x, 5)
5×5 DataFrame
Rowrowcolyearparametervalue
AnySymbol?Int64SymbolFloat64
1111CATrade1998margin_demand45.523
2113FFTrade1998margin_demand5.41
3211Trade1998margin_demand3.609
4212Trade1998margin_demand2.508
5321Trade1998margin_demand17.94

Again, we can extract the unique values:

table(summary, :margin => :Trade) |> x -> unique(x, :col)
1×5 DataFrame
Rowrowcolyearparametervalue
AnySymbol?Int64SymbolFloat64
1111CATrade1998margin_demand45.523

Parameters

Parameters are just sets with domain :parameter.

sets(summary) |> x-> subset(x, :domain => ByRow(==(:parameter)))
22×3 DataFrame
Rownamedescriptiondomain
SymbolStringSymbol
1Exportparameter
2Subsidyparameter
3Labor_Demandparameter
4Capital_Demandparameter
5Investment_Final_Demandparameter
6Importparameter
7Sector_Subsidyparameter
8Government_Final_Demandparameter
9Dutyparameter
10Intermediate_Demandparameter
11Intermediate_Supplyparameter
12Taxparameter
13Output_Taxparameter
14Value_AddedValue addedparameter
15Final_DemandFinal demandparameter
16Other_Final_DemandNon-export components of final demandparameter
17UseUse (or input) sections of the IO tableparameter
18SupplySupply (or output) sections of the IO tableparameter
19Margin_DemandPositive values in marginal categoriesparameter
20Margin_SupplyNegative values in marginal categoriesparameter
21Household_SupplyPositive values in PCE (negative in USE table)parameter
22Personal_ConsumptionNegative values in PCE (positive in USE table)parameter

By convention, parameter names are capital-version of snake_case. Sets are required to have distinct names and this avoid conflicts.

Extracting parameters is identical to extracting sets.

table(summary, :Intermediate_Demand) |> x -> first(x, 5)
5×5 DataFrame
Rowrowcolyearparametervalue
AnySymbol?Int64SymbolFloat64
1111CA111CA1998intermediate_demand-33.87
2113FF111CA1998intermediate_demand-12.047
3212111CA1998intermediate_demand-1.67
422111CA1998intermediate_demand-3.378
523111CA1998intermediate_demand-0.796

We can extract multiple parameters:

table(summary, :Intermediate_Demand, :Intermediate_Supply) |> x -> first(x, 5)
5×5 DataFrame
Rowrowcolyearparametervalue
AnySymbol?Int64SymbolFloat64
1111CA111CA1998intermediate_demand-33.87
2113FF111CA1998intermediate_demand-12.047
3212111CA1998intermediate_demand-1.67
422111CA1998intermediate_demand-3.378
523111CA1998intermediate_demand-0.796

Some parameters are composites of multiple parameters:

elements(summary, :Value_Added)
2×3 DataFrame
Rownamedescriptionset
AnyAnySymbol
1labor_demandValue addedValue_Added
2capital_demandValue addedValue_Added

Composite Parameters

Some parameters are require aggregations and can't be extracted directly. Here is a full list of these parameters:


This page was generated using Literate.jl.