API Reference

WiNDCHousehold.HouseholdTableType
Household

The primary container for WiNDC household disaggregation data tables. There are three fields, all dataframes:

  • data: The main data table.
  • sets: The sets table, describing the different sets used in the model.
  • elements: The elements table, describing the different elements in the model.
source
WiNDCHousehold.RawHouseholdDataType
RawHouseholdData
RawHouseholdData(
    state_table::WiNDCRegional.State,
    cps::Dict{Symbol,DataFrame},
    nipa::DataFrame,
    acs::DataFrame,
    medicare::DataFrame,
    labor_tax_rates::DataFrame,
    cex_income_elasticities::DataFrame,
    pce_shares::DataFrame,
    capital_tax_rates::DataFrame;
    state_fips = WiNDCHousehold.load_state_fips(),
    income_categories = WiNDCHousehold.load_cps_income_categories(),
    state_abbreviations = WiNDCHousehold.load_state_fips(cols_to_keep = [:state, :abbreviation]),
)

A container for all raw data used in WiNDCHousehold processing.

Fields

  • state_fips::DataFrame: State FIPS codes.
  • income_categories::DataFrame: Income category mappings.
  • state_abbreviations::DataFrame: State abbreviations.
  • income::DataFrame: CPS income data.
  • numhh::DataFrame: CPS number of households data.
  • nipa::DataFrame: NIPA data.
  • acs_commute::DataFrame: ACS commute data.
  • medicare::DataFrame: Medicare data.
  • labor_tax_rates::DataFrame: Labor tax rates.
  • capital_tax_rates::DataFrame: Capital tax rates.
  • nipa_cps::DataFrame: NIPA vs CPS income categories mapping.
  • windc_vs_nipa_income_categories::DataFrame: WiNDC vs NIPA income categories mapping.
  • nipa_fringe::DataFrame: NIPA fringe benefit markup data.
  • cps_data::DataFrame: Processed CPS data.
  • cex_income_elasticities::DataFrame: CEX income elasticities data.
  • pce_shares::DataFrame: PCE shares data.
source
WiNDCHousehold.NYSE_dataMethod
NYSE_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts NYSE-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(data, 
        :Household_Supply,
        :Capital_Demand;
        normalize=:Use
    )
source
WiNDCHousehold.absorptionMethod
absorption(
    HH::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter::Symbol = :absorption,
    normalize::Bool = false
)

Calculate the absorption for each commodity in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :absorption).
  • normalize::Bool: Flip the resulting sign of the data (default is false).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
commodity:absstateyear:absorptionvalue

Non-symbol values are sets.

!!!note "Negative Values Absorption is a demand-side value, which means the resulting values will be negative. If you wish to have positive values, set the normalize argument to true.

Parameters

These values are extracted from the HouseholdTable

  • Intermediate_Demand
  • Other_Final_Demand

Calculation

\[{\rm Absorption} = \sum_{\rm sectors} {\rm Intermediate\_Demand}} + \sum_{\rm other\_final\_demand}{{\rm Other\_Final\_Demand}}\]

source
WiNDCHousehold.adjust_capital_demandMethod
adjust_capital_demand(
    HH::HouseholdTable,
    state_table::State,
    raw_data::RawHouseholdData;
)

Convert gross capital demand in the state_table to net capital demand by removing the capital tax based on state-level capital tax rates provided in raw_data.

\[ {\rm Net\ Capital\ Demand} = \frac{\rm Gross\ Capital\ Demand}{1 + r}\]

Raw Data

  • raw_data.capital_tax_rates (State-level capital tax rates)

Parameters Disaggregated

  • Capital_Demand

Sets Added

  • capital_tax
    • Domain: row
    • Description: "Capital Tax"
    • Elements: cap_tax
  • Capital_Tax - From state_table
source
WiNDCHousehold.adjusted_capital_incomeMethod
adjusted_capital_income(
    HH::HouseholdTable,
    state_table::WiNDCRegional.State,
    raw_data::RawHouseholdData
)

Compute the adjusted capital income for each household in HH based on capital ownership and total capital demand.

Arguments

  • HH::HouseholdTable: The household table.
  • state_table::WiNDCRegional.State: The state-level WiNDC table.
  • raw_data::RawHouseholdData: The raw household data containing CPS data.

Returns

  • adjusted_capital::DataFrame: A DataFrame with columns :hh, :year, :state, and :capital representing the adjusted capital income for each household.

Computation

The adjusted capital income is computed using the formula:

\[ {\rm Adjusted\ Capital\ Income} = {\rm Capital\ Ownership\ Share} \cdot {\rm Total\ Capital\ Demand} \cdot \frac{{\rm Interest\ Income}}{\sum_{hh}{\rm Interest\ Income}}\]

source
WiNDCHousehold.adjusted_consumptionMethod
adjusted_consumption(
    HH::HouseholdTable,
    state_table::WiNDCRegional.State,
    raw_data::RawHouseholdData
)

Compute the adjusted consumption for each household in HH based on consumption shares, personal consumption from state_table, and the household savings rate.

Arguments

  • HH::HouseholdTable: The household table.
  • state_table::WiNDCRegional.State: The state-level WiNDC table.
  • raw_data::RawHouseholdData: The raw household data containing CPS data.

Returns

  • adjusted_consumption::DataFrame: A DataFrame with columns :hh, :year, :state, and :consumption representing the adjusted consumption for each household.

Computation

The adjusted consumption is computed using the formula:

\[ {\rm Adjusted\ Consumption} = \frac{{\rm Consumption\ Share} \cdot {\rm Personal\ Consumption}}{1 - {\rm Savings\ Rate}}\]

source
WiNDCHousehold.adjusted_wagesMethod
adjusted_wages(
    HH::HouseholdTable,
    state_table::WiNDCRegional.State,
    raw_data::RawHouseholdData;
    tax_adjustment::Bool = true
)

Compute the adjusted wages for each household in HH based on labor endowment multipliers and labor tax rates.

Arguments

  • HH::HouseholdTable: The household table.
  • state_table::WiNDCRegional.State: The state-level WiNDC table.
  • raw_data::RawHouseholdData: The raw household data containing CPS data and labor tax rates.

Keyword Arguments

  • tax_adjustment::Bool = true: Whether to apply labor tax adjustments.

Returns

  • adjusted_wages::DataFrame: A DataFrame with columns :hh, :year, :state, and :wage representing the adjusted wages for each household.

Computation

The adjusted wages are computed using the formula:

\[ {\rm Adjusted\ Wage} = {\rm Wage\ Share} \cdot ({\rm tax\ adjustment}\cdot {\rm Labor\ Tax\ Rate} - 1) \cdot {\rm Labor\ Endowment\ Multiplier} \cdot \sum_{sectors}{\rm Labor\ Demand}\]

source
WiNDCHousehold.aggregate_transfer_paymentMethod
aggregate_transfer_payment(
    HH::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter = :total_transfers,
)

Aggregate the transfer payments for each household type in each region.

Required Arguments

  • HH::HouseholdTable: The household data.

Keyword Arguments

  • column::Symbol = :value: The column to be used for the aggregation.
  • output::Symbol = :value: The name of the output column.
  • parameter::Symbol =:total_transfers`: The name of the parameter column.

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:tthouseholdstateyear:total_transfersvalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Transfer_Payment

Calculation

The total transfer payments are calculated as:

\[{\rm Total\_Transfers} = \sum_{\rm transfers} {\rm Transfer\_Payment}\]

source
WiNDCHousehold.armington_dataMethod
armington_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts Armington-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    vcat(
        absorption(data; normalize = true),
        table(data, :Reexport, :National_Demand, :Local_Demand, :Import, :Margin_Demand; normalize = :Use),
        tax_rate(data),
        duty_rate(data)
    )

Aggregate data

source
WiNDCHousehold.average_labor_tax_rateMethod
average_labor_tax_rate(
    HH::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter = :average_labor_tax_rate,
)

Calculate the average labor tax rate for each household type in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :average_labor_tax_rate).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:altrhouseholdstateyear:averagelabortax_ratevalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Average_Labor_Tax
  • Labor_Endowment

Calculation

The average labor tax rate is calculated as:

\[{\rm Average\_Labor\_Tax\_Rate} = \frac{\rm Average\_Labor\_Tax}{\sum_{\rm Destinations} \rm Labor\_Endowment}\]

source
WiNDCHousehold.build_transfer_paymentsMethod
build_transfer_payments(
    HH::HouseholdTable,
    raw_data::RawHouseholdData,
)

Add transfer payments to the HouseholdTable HH based on the data in raw_data.

Raw Data

  • WiNDCHousehold.transfer_weights
  • raw_data.income (CPS income data)
  • raw_data.medicare (Medicare and Medicaid data)
  • raw_data.income_categories (CPS income categories)

Sets Added

  • Transfer_Payment

    • Domain: parameter
    • Description: "Transfer Payments"
    • Elements: transfer_payment
  • transfer_payments

    • Domain: row
    • Description: "Transfer Payments"
ElementDescription
hucvalunemployment compensation
hwcvalworkers compensation
hssvalsocial security
hssivalsupplemental security
hpawvalpublic assistance or welfare
hvetvalveterans benefits
hsurvalsurvivors income
hdisvaldisability
hedvaleducational assistance
hcspvalchild support
hfinvalfinancial assistance
medicareedicare
medicaidedicaid
otherOther Income

The year for medicare and medicaid is fixed at 2024. Need to update for more years in the future.

source
WiNDCHousehold.calibration_model_1Method
calibration_model_1(HH::HouseholdTable, state_table::State, HH_Raw_Data::RawHouseholdData)

This is a placeholder docstring. It has been intentionally left blank as this model can be simplified further.

To Do:

  1. Add errors if model fails to solve
source
WiNDCHousehold.calibration_model_2Method
calibration_model_2(
    HH::HouseholdTable, 
    state_table::State, 
    HH_Raw_Data::RawHouseholdData,
    calibration_model_1::JuMP.Model
)

This is a placeholder docstring. It has been intentionally left blank as this model can be simplified further.

To Do:

  1. Add errors if model fails to solve
source
WiNDCHousehold.capital_stock_dataMethod
capital_stock_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts capital stock-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(data, :Capital_Demand; normalize = :Use)
source
WiNDCHousehold.capital_tax_rateMethod
capital_tax_rate(
    HH::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter = :capital_tax_rate,
)

Calculate the capital tax rate for each household type in each region. The capital tax rate is defined as the ratio of Capital_Tax to Capital_Demand.

Required Arguments

  • HH::HouseholdTable: The household data.

Keyword Arguments

  • column::Symbol = :value: The column to be used for the calculation.
  • output::Symbol = :value: The name of the output column.
  • parameter::Symbol =:capitaltaxrate`: The name of the parameter column.

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:ktrhouseholdstateyear:capitaltaxratevalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Capital_Tax
  • Capital_Demand

Calculation

The capital tax rate is calculated as:

\[{\rm Capital\_Tax\_Rate} = \frac{\rm Capital\_Tax}{\rm Capital\_Demand}\]

source
WiNDCHousehold.clean_cps_data_yearMethod
clean_cps_data_year(year, cps_rw, variables, api_key; state_fips = load_state_fips())

Clean and process the CPS data for a given year.

Arguments

  • year::Int: The year of the CPS data to load.
  • cps_rw::Vector{String}: The list of CPS raw variables to load
  • variables::Vector{String}: The list of CPS variables to process.
  • api_key::String: The Census API key.

Optional Arguments

  • state_fips::DataFrame: A DataFrame containing state FIPS codes. Defaults to loading from load_state_fips().

Return

Returns a NamedTuple with the following DataFrames:

  • income::DataFrame: Income data by household type and state.
  • count::DataFrame: Count of households by household type and state.
  • numhh::DataFrame: Number of households by household type and state.
source
WiNDCHousehold.compute_economy_wide_savingsMethod
compute_economy_wide_savings(
        state_table::WiNDCRegional.State
    )

Compute the economy-wide savings rate based on personal consumption and investment from the state_table.

Returns

  • economy_wide_savings::DataFrame: A DataFrame with columns :year and :economy_wide_sr0 representing the economy-wide savings rate for each year.

Computation

\[ {\rm Economy\ Wide\ Savings\ Rate} = \frac{\rm Investment\ Final\ Demand}{\rm Personal\ Consumption + Investment\ Final\ Demand}\]

source
WiNDCHousehold.compute_savings_markup_consumptionMethod
compute_savings_markup_consumption(
    state_table::WiNDCRegional.State,
    raw_data::RawHouseholdData
)

Compute the savings markup based on personal consumption from the state_table and CPS data in raw_data.

Arguments

  • state_table::WiNDCRegional.State: The state-level WiNDC table.
  • raw_data::RawHouseholdData: The raw household data containing CPS data.

Returns

  • savings_markup_consumption::Float64: The computed savings markup based on consumption.

Computation

\[ {\rm Savings\ Markup} = \frac{\rm Total\ Personal\ Consumption}{\rm Total\ Consumption}\]

source
WiNDCHousehold.compute_savings_markup_saveMethod
savings_markup_save(
    HH::HouseholdTable,
    raw_data::RawHouseholdData
)

Compute the savings markup for the household table HH based on the raw CPS data in raw_data.

Arguments

  • HH::HouseholdTable: The household table.
  • raw_data::RawHouseholdData: The raw household data containing CPS data.

Returns

  • savings_markup_save::Float64: The computed savings markup.

Raw Data Used

Computation

\[ {\rm Savings\ Markup} = \frac{\rm Gross\ Capital\ Demand}{\rm Total\ Interest}\]

source
WiNDCHousehold.compute_savings_rateMethod
compute_savings_rate(
        HH::HouseholdTable,
        state_table::WiNDCRegional.State,
        raw_data::RawHouseholdData
    )

Compute the savings rate for each household in HH based on the economy-wide savings rate and the household's interest income and consumption.

Arguments

  • HH::HouseholdTable: The household table.
  • state_table::WiNDCRegional.State: The state-level WiNDC table.
  • raw_data::RawHouseholdData: The raw household data containing CPS data.

Returns

  • savings_rate::DataFrame: A DataFrame with columns :hh, :year, :state, and :save_rate representing the savings rate for each household.

Computation

This computation is broken into several steps:

  1. Compute the economy-wide savings rate using WiNDCHousehold.compute_economy_wide_savings.
  2. Compute the savings markup for savings and consumption using:
  3. Calculate the interest shares and total shares for each household.
  4. Finally, compute the savings rate for each household using the formula:

\[ {\rm Savings\ Rate}_{hh} = \frac{\rm (Economy\ Wide\ Savings\ Rate) \cdot (Interest\ Share)}{Total\ Share}}\]

source
WiNDCHousehold.consumption_dataMethod
consumption_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts consumption-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(data, :Personal_Consumption; normalize = :Use)
source
WiNDCHousehold.cpi_dataMethod
cpi_data(HH::HouseholdTable; output = :DataFrame)

Extracts consumer price index-related parameters from the household data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(HH, :Personal_Consumption; normalize=:Use) |>
        x -> groupby(x, [:col, :region, :parameter]) |>
        x -> combine(x, :value => sum => :value)
source
WiNDCHousehold.disposition_dataMethod
disposition_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts disposition-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    vcat(
        regional_local_supply(data),
        netports(data),
        total_supply(data),
        regional_national_supply(data)
        )

Aggregate Data

source
WiNDCHousehold.duty_rateMethod

dutyrate( HH::HouseholdTable; column::Symbol = :value, output::Symbol = :value, parameter = :dutyrate )

Calculate the duty rate for each commodity in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :duty_rate).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
commodity:drstateyear:duty_ratevalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Duty
  • Import

Calculation

\[{\rm Duty\_Rate} = \frac{\rm Duty}{\rm Import}\]

source
WiNDCHousehold.fetch_zip_dataMethod
fetch_zip_data(
    url::String,
    filter_function::Function;;
    output_path::String = tempname(),
)

Download a zip file from a given url and extract the files in the zip file that are in the data NamedTuple.

This function will throw an error if not all files in data are extracted.

Required Arguments

  1. url::String: The url of the zip file to download.
  2. filter_function::Function;: A function that takes a string and returns a boolean. This function is used to filter the files in the zip file, it should return true if the file should be extracted and false otherwise.

Optional Arguments

  • output_path::String: The path to save the extracted files. Default is a

temporary directory. If this is not an absolute path, it will be joined with the current working directory.

Output

Returns a vector of the absolute paths to the extracted files.

source
WiNDCHousehold.fica_tax_rateMethod
fica_tax_rate(
    HH::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter = :fica_tax_rate,
)

Calculate the FICA tax rate for each household type in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :fica_tax_rate).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:ftrhouseholdstateyear:ficataxratevalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • FICA_Tax
  • Labor_Endowment

Calculation

The FICA tax rate is calculated as:

\[{\rm FICA\_Tax\_Rate} = \frac{\rm FICA\_Tax}{\sum_{\rm Destinations} \rm Labor\_Endowment}\]

source
WiNDCHousehold.get_capital_ownershipMethod
get_capital_ownership(
    raw_data::RawHouseholdData;
    type::Symbol = :all
)

Get the capital ownership share from raw_data.

Arguments

  • raw_data::RawHouseholdData: The raw household data containing CPS and NIPA data.

Keyword Arguments

  • type::Symbol = :all: The type of capital ownership to retrieve. Options are:
    • :all: Returns 1 (100% ownership).
    • :partial: Computes the ownership share based on CPS vs NIPA data.

Returns

  • cap_own::Float64: The capital ownership share.
source
WiNDCHousehold.government_dataMethod
government_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts government-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    vcat(
        table(data, 
            :Government_Final_Demand,
            :Transfer_Payment,
            :Labor_Endowment;
            normalize=:Use
        ),
        WiNDCHousehold.government_deficit(data),
        WiNDCHousehold.average_labor_tax_rate(data),
    )

Aggregate Data

source
WiNDCHousehold.government_deficitMethod
government_deficit(
    HH::HouseholdTable;
    column::Symbol = :value,
    output::Symbol = :value,
    parameter::Symbol = :government_deficit,
)

Calculate the government deficit for each year.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :government_deficit).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:gd:gd:gdyear:government_deficitvalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Government_Final_Demand
  • Transfer_Payment
  • Average_Labor_Tax
  • FICA_Tax
  • Capital_Tax
  • Output_Tax
  • Tax
  • Duty

Calculation

The government deficit is calculated as:

\[{\rm Government\_Deficit} = - \sum (Government\_Final\_Demand - Transfer\_Payment - Average\_Labor\_Tax - FICA\_Tax - Capital\_Tax - Output\_Tax - Tax - Duty)\]

source
WiNDCHousehold.household_modelMethod
household_model(
    HH::HouseholdTable;
    etaK::Real = 4.0,
    )

Constructs a WiNDCHousehold MPSGE model from a WiNDCHousehold data table.

Arguments

  • HH::HouseholdTable: A WiNDCHousehold data table.

Keyword Arguments

  • etaK::Real = 4.0: Capital transformation elasticity

Returns

  • M::MPSGEModel: An MPSGE model representing the household sector.

Parameters

The initial values of the parameters are given by parameter_data. The parameters included in the model are:

  • OTR[r=states, s=sectors]: Output tax rate
  • TR[r=states, g=commodities]: Tax rate
  • DR[r=states, g=commodities]: Duty rate
  • TK[r=states, s=sectors]: Capital tax rate
  • FICA[r=states, h=households]: FICA tax rate
  • LTR[r=states, h=households]: Labor tax rate

If the model is denoted M, these parameters can be accessed as M[:OTR], M[:TR], etc.

Variables

Sectors

  • Y[r=states, s=sectors]:" Production
  • X[r=states, g=commodities]:" Disposition
  • A[r=states, g=commodities]:" Absorption
  • C[r=states, h=households]:" Household Consumption
  • MS[r=states, m=margins]:" Margin supply
  • LS[r=states, h=households]:" Labor supply
  • KS: Aggregate Capital stock

Commodities

  • PA[r=states, g=commodities]:" Regional market (input)
  • PC[r=states, h=households]:" Consumer price index
  • PD[r=states, g=commodities]:" Local market price
  • PFX: Foreign exchange
  • PK: Aggregate return to capital
  • PL[r=states]:" Wage rate
  • PLS[r=states, h=households]:" Leisure price
  • PM[r=states, m=margins]:" Margin price
  • PN[g=commodities]:" National market
  • PY[r=states, g=commodities]:" Regional market (output)
  • RK[r=states, s=sectors]:" Sectoral rental rate
  • RKS: Capital stock

Consumers

  • RA[r=states, h=households]: Representative agent
  • NYSE: Aggregate capital owner
  • INVEST: Aggregate investor
  • GOVT: Aggregate government

Auxiliaries

All auxiliaries start with a value of 1.

  • SAVERATE: Domestic saving rate
  • TRANS: Budget balance rationing variable
  • SSK: Steady-state capital stock
  • CPI: Consumer price index

Production Blocks

Y - Sectoral Production in Each State

WiNDCHousehold.sectoral_output

sectoral_output(HH; output = :DefaultDict) |> Q->
@production(M, Y[r=states, s=sectors], [t=0, s=0, va=>s=1], begin
    @output(PY[r,g=commodities], Q[g, s, r, :intermediate_supply],                     t,  taxes = [Tax(GOVT, M[:OTR][r,s])], reference_price = 1-Q[:otr, s, r, :output_tax_rate])
    @input(PA[r, g=commodities], Q[g, s, r, :intermediate_demand],                     s)
    @input(PL[r],            sum(Q[l, s, r, :labor_demand] for l in labor_demand),     va)
    @input(RK[r, s],         sum(Q[k, s, r, :capital_demand] for k in capital_demand), va, taxes = [Tax(GOVT, M[:TK][r,s])], reference_price = 1 + Q[:ktr, s, r, :capital_tax_rate])
end)

X - Commodity Disposition in Each State

WiNDCHousehold.disposition_data

disposition_data(HH; output = :DefaultDict) |> Q->
@production(M, X[r=states, g=commodities], [s=0, t=4], begin
    @output(PFX,      Q[g, r, :netport],                t)
    @output(PN[g],    Q[g, r, :region_national_supply], t)
    @output(PD[r, g], Q[g, r, :region_local_supply],    t)
    @input(PY[r, g],  Q[g, r, :total_supply],           s)
end)

A - Armington Commodity Absorption in Each State

WiNDCHousehold.armington_data

armington_data(HH; output = :DefaultDict) |> Q-> 
@production(M, A[r=states, g=commodities], [t=0, s=0, dm => s = 2, d=>dm=4], begin
    @output(PA[r, g],        Q[g, :abs, r, :absorption],                  t, taxes = [Tax(GOVT, M[:TR][r,g])], reference_price = 1 - Q[g, :tr, r, :tax_rate])
    @output(PFX,             Q[g, :reexport, r, :reexport],               t)
    @input(PN[g],            Q[g, :national_demand, r, :national_demand], d)
    @input(PD[r, g],         Q[g, :local_demand, r, :local_demand],       d)
    @input(PFX,          sum(Q[g, i, r, :import] for i in imports),       dm, taxes = [Tax(GOVT, M[:DR][r,g])], reference_price = 1 + Q[g, :dr, r, :duty_rate])
    @input(PM[r, m=margins], Q[g, m, r, :margin_demand],                  s)
end)

MS - Margin Supply and Demand in Each State

WiNDCHousehold.margin_supply_data

margin_supply_data(HH; output = :DefaultDict) |> Q->
@production(M, MS[r=states, m=margins], [t=0, s=0], begin
    @output(PM[r, m],        sum(Q[g, m, r, :margin_demand] for g in commodities), t)
    @input(PN[g=commodities],    Q[g, m, r, :national_margin_supply],              s)
    @input(PD[r, g=commodities], Q[g, m, r, :local_margin_supply],                 s)
end)

C - Household Consumption in Each State

WiNDCHousehold.consumption_data

consumption_data(HH; output = :DefaultDict) |> Q->
@production(M, C[r=states, h=households], [t=0, s=1], begin
    @output(PC[r, h],        sum(Q[g, h, r, :personal_consumption] for g in commodities), t)
    @input(PA[r, g=commodities], Q[g, h, r, :personal_consumption],                       s)
end)

LS - Labor Supply in Each State

WiNDCHousehold.labor_data

labor_data(HH; output = :DefaultDict) |> Q->
@production(M, LS[r=states, h=households], [t=0, s=1], begin
    @output(PL[q=states], Q[q, h, r, :labor_endowment], t, taxes = [Tax(GOVT, M[:LTR][r,h] + M[:FICA][r,h])], reference_price = 1 - Q[:ltr, h, r, :marginal_labor_tax_rate] - Q[:ftr, h, r, :fica_tax_rate])
    @input(PLS[r, h],     Q[:ls, h, r, :labor_supply], s)
end)

KS - Capital Stock Transformation

WiNDCHousehold.capital_stock_data

capital_stock_data(HH; output = :DefaultDict) |> Q->
@production(M, KS, [t=etaK, s=1], begin
    @output(RK[r=states, s=sectors], Q[s, r, :capital_demand], t)
    @input(RKS,                  sum(Q[ss, rr, :capital_demand] for ss in sectors, rr in states), s)
end)

Demands

RA - Representative Agent Demand in Each State

WiNDCHousehold.representative_agent_data

representative_agent_data(HH; output = :DefaultDict) |> Q->
@demand(M, RA[r=states, h=households], begin
    @final_demand(PC[r, h], sum(Q[g, h, r, :personal_consumption] for g in commodities; init=0))
    @final_demand(PLS[r, h],    Q[:ld, h, r, :leisure_demand])
    @endowment(PLS[r, h],       Q[:ld, h, r, :leisure_demand] + Q[:ls, h, r, :labor_supply])
    @endowment(PFX,         sum(Q[trn, h, r, :transfer_payment] for trn in transfers; init=0))
    @endowment(PLS[r, h],   (M[:LTR][r,h] - Q[:altr, h, r, :average_labor_tax_rate]) * sum(Q[dest, h, r, :labor_endowment] for dest in states; init=0))
    @endowment(PK,              Q[:interest, h, r, :household_interest])
    @endowment(PFX,            -Q[:savings, h, r, :savings]*SAVERATE)
end, elasticity = Q[:els, h, r, :leisure_consumption_elasticity])

NYSE - Aggregate Capital Owner Demand

WiNDCHousehold.NYSE_data

NYSE_data(HH; output = :DefaultDict) |> Q->
@demand(M, NYSE, begin
    @final_demand(PK,                       sum(Q[row, col, r, :household_supply] for row in commodities, col in personal_consumption, r in states; init=0) + sum(Q[row, col, r, :capital_demand] for row in capital_demand, col in sectors, r in states; init=0))
    @endowment(PY[r=states, g=commodities], sum(Q[g, col, r, :household_supply] for col in personal_consumption; init=0))
    @endowment(RKS,                         sum(Q[k, s, r, :capital_demand] for k in capital_demand, s in sectors, r in states;init=0)*SSK)
end)

INVEST - Aggregate Investor Demand

WiNDCHousehold.invest_data

invest_data(HH; output = :DefaultDict) |> Q->
@demand(M, INVEST, begin
    @final_demand(PA[r=states, g=commodities], Q[g, :invest, r, :investment_final_demand])
    @endowment(PFX,                        sum(Q[:savings, h, r, :savings] for h in households, r in states; init=0)*SAVERATE)
    @endowment(PFX, 0) # fsav0
end)

GOVT - Aggregate Government Demand

WiNDCHousehold.government_data

government_data(HH; output = :DefaultDict) |> Q->
@demand(M, GOVT, begin
    @final_demand(PA[r=states, g=commodities], Q[g, :govern, r, :government_final_demand])
    @endowment(PFX,                 -TRANS*sum(Q[trn, h, r, :transfer_payment] for trn in transfers, h in households, r in states; init=0))
    @endowment(PFX,                            Q[:gd, :gd, :gd, :government_deficit])
    @endowment(PLS[r=states, h=households], -(M[:LTR][r,h] - Q[:altr, h, r, :average_labor_tax_rate]) * sum(Q[dest, h, r, :labor_endowment] for dest in states; init=0))
end)

Auxiliary Constraints

SSK - Steady-State Capital Stock Constraint

WiNDCHousehold.ssk_data

ssk_data(HH; output = :DefaultDict) |> Q->
@aux_constraint(M, SSK, 
    sum(Q[g, :invest, r, :investment_final_demand]*(PA[r,g]-RKS) for g in commodities, r in states)
)

SAVERATE - Domestic Saving Rate Constraint

WiNDCHousehold.saverate_data

saverate_data(HH; output = :DefaultDict) |> Q->
@aux_constraint(M, SAVERATE, 
    INVEST - sum(Q[g, :invest, r, :investment_final_demand]*PA[r,g]*SSK for g in commodities, r in states)
)

TRANS - Budget Balance Rationing Variable Constraint

WiNDCHousehold.trans_data

trans_data(HH; output = :DefaultDict) |> Q->
@aux_constraint(M, TRANS,
    GOVT - sum(PA[r,g]*Q[g, :govern, r, :government_final_demand] for g in commodities, r in states)
)

CPI - Consumer Price Index Constraint

WiNDCHousehold.cpi_data

cpi_data(HH; output = :DefaultDict) |> Q->
@aux_constraint(M, CPI,
    CPI - sum(PC[r,h]*Q[h, r, :personal_consumption] for h in households, r in states)/ sum(Q[h, r, :personal_consumption] for h in households, r in states; init=0)
)
source
WiNDCHousehold.household_raw_dataMethod
household_raw_data()
household_raw_data(path::String)
household_raw_data(info::Dict)

Load the raw household data based on the provided configuration dictionary.

Arguments

If no arguments are provided, the function loads the configuration from household.yaml in the current directory. If a path::String is provided, it loads the configuration from the specified path. If a info::Dict is provided, it uses the given configuration dictionary directly.

Returns

This currently returns a tuple containing:

Raw Data Loaded

Maps Loaded

source
WiNDCHousehold.initialize_tableMethod
initialize_table(state_table::State)

Create an initial HouseholdTable from a State table by selecting only the relevant parameters, sets, and elements.

Essentially, all parameters, sets, and elements are maintained except those related to personal_consumption.

Parameters Maintained

  • Capital_Demand
  • Duty
  • Export
  • Government_Final_Demand
  • Household_Supply
  • Import
  • Intermediate_Demand
  • Intermediate_Supply
  • Investment_Final_Demand
  • Labor_Demand
  • Local_Demand
  • Local_Margin_Supply
  • Margin_Demand
  • National_Demand
  • National_Margin_Supply
  • Output_Tax
  • Reexport
  • Tax

Sets Maintained

  • duty
  • export
  • government_final_demand
  • import
  • investment_final_demand
  • local_demand
  • margin
  • national_demand
  • reexport
  • sector
  • tax
  • trade
  • transport
  • state
  • capital_demand
  • commodity
  • labor_demand
  • output_tax
  • year
  • Final_Demand
  • Other_Final_Demand
  • Margin_Supply
  • Use
  • Supply
  • Value_Added

Sets Added

  • household
    • Domain: col
    • Description: "Household Categories"
    • Elements: hh1, hh2, hh3, hh4, hh5
source
WiNDCHousehold.invest_dataMethod
invest_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts investment-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(data, 
        :Investment_Final_Demand,
        :Savings;
        normalize=:Use
    )
source
WiNDCHousehold.labor_dataMethod
labor_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts leisure-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

   vcat(
        table(data, :Labor_Endowment),
        WiNDCHousehold.labor_supply(data),
        WiNDCHousehold.marginal_labor_tax_rate(data),
        WiNDCHousehold.fica_tax_rate(data)
    )

Aggregate Data

source
WiNDCHousehold.labor_endowment_multiplierMethod
labor_endowment_multiplier(
    HH::HouseholdTable,
    state_table::WiNDCRegional.State,
    raw_data::RawHouseholdData
)

Compute the labor endowment multiplier for each region based on labor demand and wages.

Arguments

  • HH::HouseholdTable: The household table.
  • state_table::WiNDCRegional.State: The state-level WiNDC table.
  • raw_data::RawHouseholdData: The raw household data containing CPS data.

Returns

  • labor_endow_multiplier::DataFrame: A DataFrame with columns :region and :le_mult representing the labor endowment multiplier for each region.

Computation

The labor endowment multiplier is computed using the formula:

\[ {\rm Labor\ Endowment\ Multiplier} = \frac{\rm Fringe\ Benefit\ Markup \cdot \rm Wage}{\rm Labor\ Demand}\]

Changes also made based on commuting patterns to ensure that regions without commuting workers do not have their labor endowment multipliers adjusted beyond 1.

source
WiNDCHousehold.labor_supplyMethod
labor_supply(
    HH::HouseholdTable;
    column::Symbol = :value,
    output::Symbol = :value,
    parameter::Symbol = :labor_supply,
)

Calculate the labor supply for households. The labor supply is defined as the labor endowment adjusted for marginal labor taxes and FICA taxes.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :labor_supply).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:lshouseholdstateyear:labor_supplyvalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Labor Endowment
  • Marginal Labor Tax
  • FICA Tax

Calculation

\[{\rm Labor\_Supply} = \sum (Labor\_Endowment - Marginal\_Labor\_Tax - FICA\_Tax)\]

source
WiNDCHousehold.leisure_consumption_elasticityMethod
leisure_consumption_elasticity(
    HH::HouseholdTable;
    column::Symbol = :value,
    output::Symbol = :value,
    parameter::Symbol = :leisure_consumption_elasticity,
)

Calculate the leisure consumption elasticity for households.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :leisure_consumption_elasticity).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:elshouseholdstateyear:leisureconsumptionelasticityvalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Personal_Consumption

Aggregate Parameters

Calculation

Leisure consumption elasticity is calculated as:

\[{\rm Leisure\_Consumption\_Elasticity} = \epsilon \cdot \frac{(PCE + LD)}{PCE} \cdot \frac{LS}{LD}\]

where

  • ( \epsilon ) is the leisure income elasticity (0.2),
  • PCE is Personal Consumption Expenditure
  • LD is Leisure Demand
  • LS is Labor Supply

```

source
WiNDCHousehold.leisure_demandMethod
leisure_demand(
    HH::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter = :leisure_demand,
)

Calculate the leisure demand for households. The leisure demand is defined as a fraction of the leisure supply, based on a labor supply income elasticity, which is set to 0.05.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :leisure_demand).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:ldhouseholdstateyear:leisure_demandvalue

Non-symbol values are sets.

Aggregate Parameters

Calculation

Leisure demand is calculated as:

\[{\rm Leisure\_Demand} = \epsilon \cdot {\rm Leisure\_Supply}\]

where ( \epsilon ) is the labor supply income elasticity (0.05).

source
WiNDCHousehold.load_acs_data_apiMethod
load_acs_data_api(year::Int, census_api_key; output_path::String = tempname())

Pull the raw ACS commuting flow data directly from the Census website for a given year.

Arguments

  • year::Int: The year of the ACS data to load.
  • census_api_key::String: The Census API key.

Optional Arguments

  • output_path::String: The path to save the downloaded ACS data. Default is a temporary directory.

Returns

Return a DataFrame with the commuting flow data for the specified year, enriched with income data from the CPS.

Data Source

The ACS commuting flow data is downloaded from the Census website:

https://www2.census.gov/programs-surveys/demo/tables/metro-micro/{year}/commuting-flows-{year}/table1.xlsx
source
WiNDCHousehold.load_acs_medicare_dataMethod
load_acs_medicare_data(
    census_api_key::String;
    years::Vector{Int} = 2009:2024,
    state_fips::DataFrame = load_state_fips()
)

Load ACS Medicare data from the Census API for the specified years.

Required Arguments

  • census_api_key::String: The Census API key.

Optional Arguments

  • years::Vector{Int}: The years of the ACS data to load. Default is 2009 to 2024.
  • state_fips::DataFrame: A DataFrame containing state FIPS codes. Default is the result of load_state_fips().
Excluded 2020

The year 2020 is excluded from the default years because the ACS data for that year does not include Medicare data due to low response rates.

Early years?

Currently we don't have data before 2009, so requesting years before. We should update this to just use 2009 data for earlier years.

Return

Returns a DataFrame with shares of income groups for Medicare enrollment by state and year.

source
WiNDCHousehold.load_capital_tax_ratesMethod
load_capital_tax_rates(
    path::String;
    state_abbreviations = WiNDCHousehold.load_state_fips(cols_to_keep = [:state, :abbreviation])
)

Load capital tax rates from a CSV file located at path. The CSV is expected to contain state-level capital tax rate information, which will be matched with state abbreviations provided by state_abbreviations.

Arguments

  • path::String: The path to the CSV file.

Optional Arguments

  • state_abbreviations::DataFrame: A DataFrame containing state abbreviations and their corresponding state names. Default loads state FIPS with state names and abbreviations.

Returns

A DataFrame containing capital tax rates by state.

source
WiNDCHousehold.load_cps_data_apiMethod
load_cps_data_api(api_key; years = 2001:2022)

Load all the CPS data in the given year range.

Arguments

  • api_key::String: The Census API key.

Optional Arguments

  • years::UnitRange{Int}: The range of years to load. Defaults to 2001:2022.

Return

Returns a NamedTuple with the following DataFrames:

  • income::DataFrame: Income data by household type and state.
  • shares::DataFrame: Share of income by household type and state.
  • count::DataFrame: Count of households by household type and state.
  • numhh::DataFrame: Number of households by household type and state.

Variables Loaded

VariableDescription
hwsvalwages and salaries
hsevalself-employment (nonfarm)
hfrvalself-employment farm
hucvalunemployment compensation
hwcvalworkers compensation
hssvalsocial security
hssivalsupplemental security
hpawvalpublic assistance or welfare
hvetvalveterans benefits
hsurvalsurvivors income
hdisvaldisability
hintvalinterest
hdivvaldividends
hrntvalrents
hedvaleducational assistance
hcspvalchild support
hfinvalfinancial assistance
hoivalother income
htotvaltotal household income
gestfipsstate fips
a_exprrpexpanded relationship code
h_hhtypetype of household interview
ppposperson identifier
marsupwtasec supplement final weight
hdstvalretirement distributions - Post 2019
hpenvalpension income - Post 2019
hannvalannuities - Post 2019
hretvalretirement income - Pre 2019
source
WiNDCHousehold.load_cps_income_categoriesMethod
load_cps_income_categories(;
        path = joinpath(@__DIR__, "maps", "cps_income_categories.csv"),
        cols_to_keep = [:windc, :source]
    )

Load a CSV file containing CPS income category mappings. The default path is set to maps/cps_income_categories.csv relative to this file's directory. You can specify which columns to keep using the cols_to_keep argument.

Returns a DataFrame with the specified columns as Strings.

source
WiNDCHousehold.load_labor_tax_ratesMethod
load_labor_tax_rates(
        path::String;
        state_abbreviations = WiNDCHousehold.load_state_fips(cols_to_keep = [:state, :abbreviation])
    )

Load labor tax rates from a CSV file located at path. The CSV is expected to contain state-level labor tax rate information, which will be matched with state abbreviations provided by state_abbreviations.

Arguments

  • path::String: The path to the CSV file.

Optional Arguments

  • state_abbreviations::DataFrame: A DataFrame containing state abbreviations and their corresponding state names. Default loads state FIPS with state names and abbreviations.

Returns

A DataFrame containing labor tax rates by household and state.

source
WiNDCHousehold.load_medicare_dataMethod
load_medicare_data(path::String; years::UnitRange{Int}=2009:2024)

Load Medicare or Medicaid data from a CSV file at the given path.

Required Arguments

  • path::String: The path to the CSV file.

Optional Arguments

  • years::UnitRange{Int}: The range of years to include in the data. Default is 2009 to 2024.
source
WiNDCHousehold.load_medicare_data_apiMethod
load_medicare_data_api(
    census_api_key::String;
    url::String = "https://www.cms.gov/research-statistics-data-and-systems/statistics-trends-and-reports/nationalhealthexpenddata/downloads/resident-state-estimates.zip",
    output_path::String = tempname(),
    years::UnitRange{Int} = 2009:2024,
    state_fips::DataFrame = load_state_fips()
)

Load Medicare and Medicaid data from the CMS website for the specified years.

Required Arguments

  • census_api_key::String: The Census API key.

Optional Arguments

  • url::String: The url of the Medicare/Medicaid data zip file. Default is the CMS website link.
  • output_path::String: The path to save the downloaded and extracted data. Default is a temporary directory.
  • years::UnitRange{Int}: The range of years to include in the data Default is 2009 to 2024.
  • state_fips::DataFrame: A DataFrame containing state FIPS codes. Default is the result of load_state_fips().

Returns

A DataFrame containing Medicare and Medicaid data by state and year.

source
WiNDCHousehold.load_nipa_data_apiMethod
load_nipa_data_api(years::Vector{Int}, bea_api_key)

Pull the raw data directly from the BEA API

Arguments

  • years::Vector{Int}: The years of the NIPA data to load.
  • bea_api_key::String: The BEA API key.

Returns

A DataFrame with the NIPA data for the specified years.

Query

VariableValue
MethodGetData
datasetnameNIPA
TableNameT20100
FrequencyA
YearComma-separated list of years
ResultFormatjson
source
WiNDCHousehold.load_pce_sharesMethod
function load_pce_shares(
    path::String;
    naics_windc_map = load_windc_naics_map()
)

Load PCE shares from a CSV file located at path. The CSV is expected to contain columns for CEX categories, WiNDC categories, and percentage of PCE shares. The function joins this data with a NAICS to WiNDC mapping to associate CEX categories with NAICS codes.

source
WiNDCHousehold.load_state_fipsMethod
load_state_fips(;
        path = joinpath(@__DIR__, "maps", "state_fips.csv"),
        cols_to_keep = [:fips, :state]
    )

Load a CSV file containing state FIPS codes and state names. The default path is set to maps/state_fips.csv relative to this file's directory. You can specify which columns to keep using the cols_to_keep argument.

Returns a DataFrame with the specified columns as Strings.

Optional Arguments

  • path::String: Path to the state FIPS CSV file.
  • cols_to_keep::Vector{Symbol}: Columns to keep from the CSV file. Default is [:fips, :state].

It is recommended to keep the columns :fips and :state for proper mapping.

source
WiNDCHousehold.load_windc_naics_mapMethod
load_windc_naics_map(;
        path = joinpath(@__DIR__, "maps", "naics_windc_map.csv")
    )

Load a CSV file containing the mapping between WiNDC labels and NAICS codes. The default path is set to maps/naics_windc_map.csv relative to this file's directory.

Returns a DataFrame with columns :naics and :windc.

source
WiNDCHousehold.margin_supply_dataMethod
margin_supply_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts margin supply and demand parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(data, :Margin_Demand, :Margin_Supply; normalize = :Use)
source
WiNDCHousehold.marginal_labor_tax_rateMethod
marginal_labor_tax_rate(
    HH::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter = :marginal_labor_tax_rate
)

Calculate the marginal labor tax rate for each household type in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :marginal_labor_tax_rate).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:ltrhouseholdstateyear:marginallabortax_ratevalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Marginal_Labor_Tax
  • Labor_Endowment

Calculation

The marginal labor tax rate is calculated as:

\[{\rm Marginal\_Labor\_Tax\_Rate} = \frac{\rm Marginal\_Labor\_Tax}{\sum_{\rm Destinations} \rm Labor\_Endowment}\]

source
WiNDCHousehold.netportsMethod
netports(
    HH::HouseholdTable;
    column::Symbol = :value,
    output::Symbol = :value,
    parameter::Symbol = :netport
)

Calculate the netports for each commodity in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :netport).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
commodity:netportstateyear:netportvalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Export
  • Reexport

Calculation

\[{\rm Netports} = \sum (Export + Reexport)\]

source
WiNDCHousehold.other_incomeMethod
other_income(
    HH::HouseholdTable,
    state_table::WiNDCRegional.State,
    raw_data::RawHouseholdData
)

Compute the other income for each household in HH based on adjusted consumption, adjusted wages, transfer payments, and adjusted capital income.

Arguments

  • HH::HouseholdTable: The household table.
  • state_table::WiNDCRegional.State: The state-level WiNDC table.
  • raw_data::RawHouseholdData: The raw household data containing CPS data.

Returns

  • other_income::DataFrame: A DataFrame with columns :hh, :year, :state, and :income representing the other income for each household.

Computation

The other income is computed using the formula:

\[ {\rm Other\ Income} = {\rm Adjusted\ Consumption} + {\rm Adjusted\ Wages} - {\rm Average\ Transfer\ Payments} - {\rm Adjusted\ Capital\ Income}\]

where:

source
WiNDCHousehold.output_tax_rateMethod
output_tax_rate(
        HH::HouseholdTable; 
        column::Symbol = :value, 
        output::Symbol = :value,
        parameter = :output_tax_rate
    )

Calculate the output tax rate for each commodity in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :output_tax_rate).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
:otrsectorstateyear:outputtaxratevalue

Non-symbol values are sets.

Parameters

  • Intermediate_Supply
  • Output_Tax

Calculation

\[{\rm Output\_Tax\_Rate} = \frac{\rm Output\_Tax}{\sum_{\rm commodity} \rm Intermediate\_Supply}\]

source
WiNDCHousehold.parameter_dataMethod
parameter_data(data::T; output = :DataFrame) where T<:AbstractHouseholdTable

Returns initial parameter data for the household model.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

vcat(
    output_tax_rate(data),
    tax_rate(data),
    duty_rate(data),
    capital_tax_rate(data),
    fica_tax_rate(data),
    marginal_labor_tax_rate(data)
    )

Aggregate Data

source
WiNDCHousehold.regional_local_supplyMethod
regional_local_supply(
    HH::HouseholdTable;
    column::Symbol = :value,
    output::Symbol = :value,
    parameter::Symbol = :region_local_supply,
)

Calculate the regional local supply for each commodity in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :region_local_supply).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
commodity:rlsstateyear:regionlocalsupplyvalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Local_Margin_Supply
  • Local_Demand

Calculation

\[{\rm Regional\_Local\_Supply} = \sum (Local\_Margin\_Supply + Local\_Demand)\]

source
WiNDCHousehold.regional_national_supplyMethod
regional_national_supply(
    HH::HouseholdTable;
    column::Symbol = :value,
    output::Symbol = :value,
    parameter::Symbol = :region_national_supply
)

Calculate the regional national supply for each commodity in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :region_national_supply).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
commodity:rnsstateyear:regionnationalsupplyvalue

Non-symbol values are sets.

Aggregate Parameters

Calculation

\[{\rm Regional\_National\_Supply} = {\rm Total\_Supply} - {\rm Netports} - {\rm Regional\_Local\_Supply}\]

source
WiNDCHousehold.representative_agent_dataMethod
representative_agent_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts representative agent-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    vcat(
        leisure_consumption_elasticity(data),
        average_labor_tax_rate(data),
        labor_supply(data),
        leisure_demand(data),
        table(data, 
            :Personal_Consumption,
            :Household_Interest,
            :Transfer_Payment,
            :Savings,
            :Labor_Endowment;
            normalize=:Use
        )
    )

Aggregate Data

source
WiNDCHousehold.saverate_dataMethod
saverate_data(HH::HouseholdTable; output = :DataFrame)

Extracts saving rate-related parameters from the household data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(HH, :Investment_Final_Demand; normalize=:Use)
source
WiNDCHousehold.sectoral_outputMethod
sectoral_output(data::T, output = :DataFrame) where T<:AbstractHouseholdTable

Extracts sectoral output-related parameters from the regional data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the sectoral output data.

Data

vcat(
    table(data, 
        :Intermediate_Supply, 
        :Intermediate_Demand, 
        :Labor_Demand, 
        :Capital_Demand;
        normalize = :Use
        ),
    output_tax_rate(data),
    capital_tax_rate(data)
    )

Aggregate Data

source
WiNDCHousehold.ssk_dataMethod
ssk_data(HH::HouseholdTable; output = :DataFrame)

Extracts steady-state capital stock-related parameters from the household data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(HH, :Investment_Final_Demand; normalize=:Use)
source
WiNDCHousehold.tax_rateMethod
tax_rate(
    HH::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter = :tax_rate
)

Calculate the tax rate, inclusive of subsidies, for each commodity in each region.

Arguments

  • HH::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol: The column to aggregate (default is :value).
  • output::Symbol: The name of the output column (default is :value).
  • parameter::Symbol: The parameter to assign to the output (default is :tax_rate).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
commodity:trstateyear:tax_ratevalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Tax

Aggregate Parameters

Calculation

\[{\rm Tax\_Rate} = \frac{\rm Tax}{\rm Absorption}\]

source
WiNDCHousehold.total_supplyMethod
total_supply(
    data::HouseholdTable; 
    column::Symbol = :value, 
    output::Symbol = :value,
    parameter::Symbol = :total_supply
)

Calculate the total supply for each commodity.

Arguments

  • data::HouseholdTable: The household table containing household data.

Keyword Arguments

  • column::Symbol = :value: The column to aggregate (default is :value).
  • output::Symbol = :value: The name of the output column (default is :value).
  • parameter::Symbol = :total_supply: The parameter to assign to the output (default is :total_supply).

Returns

A DataFrame with the following structure:

rowcolregionyearparametervalue
commodity:tot_supstateyear:total_supplyvalue

Non-symbol values are sets.

Parameters

These values are extracted from the HouseholdTable

  • Intermediate_Supply
  • Household_Supply

Calculation

\[{\rm Total\_Supply} = \sum_{sectors} {\rm Intermediate\_Supply}} + {{\rm Household\_Supply}}\]

source
WiNDCHousehold.trans_dataMethod
trans_data(HH::HouseholdTable; output = :DataFrame)

Extracts transfer-related parameters from the household data table.

Arguments

  • data::T: A WiNDCHousehold data table.

Keyword Arguments

  • output::Symbol = :DataFrame: The output format, either :DataFrame or :DefaultDict.

Returns

  • A DataFrame or DefaultDict containing the parameter data.

Data

    table(HH, :Government_Final_Demand; normalize=:Use)
source
WiNDCHousehold.transfer_weightsMethod
transfer_weights(raw_data::RawHouseholdData)

Compute transfer weights based on the CPS vs NIPA comparison in raw_data.

Transfer weight is defined as the ratio of NIPA transfer income to CPS transfer income for each transfer category. If the CPS income for a category is zero, the weight from either the Meyer or Rothbaum study is used as a fallback.

Transfer Categories

CategorySource
government benefits: unemployment insurancehucval
government benefits: social securityhssval
government benefits: social securityhssival
government benefits: social securityhdisval
government benefits: veterans' benefitshvetval

Meyer and Rothbaum Weights

SourceLiteratureValue
hucvalmeyer1/0.679
hssvalmeyer1/0.899
hssivalmeyer1/0.759
hdisvalmeyer1/0.819
hvetvalrothbaum1/0.679
hwcvalmeyer1 / 0.527
hpawvalmeyer1 / 0.487
hsurvalmeyer1 / 0.908
hedvalrothbaum1 / 0.804
hcspvalrothbaum1 / 0.804
hfinvalmeyer1 / 0.539

The values are hard coded based on literature and may need to be updated as new studies emerge. Also, the year is fixed at 2024 for these weights. Need to update for more years in the future.

source