API Reference
WiNDCHousehold.HouseholdTableWiNDCHousehold.RawHouseholdDataWiNDCHousehold.NYSE_dataWiNDCHousehold.NYSE_dataWiNDCHousehold.absorptionWiNDCHousehold.adjust_capital_demandWiNDCHousehold.adjusted_capital_incomeWiNDCHousehold.adjusted_consumptionWiNDCHousehold.adjusted_wagesWiNDCHousehold.aggregate_transfer_paymentWiNDCHousehold.armington_dataWiNDCHousehold.armington_dataWiNDCHousehold.average_labor_tax_rateWiNDCHousehold.build_household_tableWiNDCHousehold.build_transfer_paymentsWiNDCHousehold.calibration_model_1WiNDCHousehold.calibration_model_2WiNDCHousehold.capital_stock_dataWiNDCHousehold.capital_stock_dataWiNDCHousehold.capital_tax_rateWiNDCHousehold.clean_aggregate_medi_dataWiNDCHousehold.clean_cps_data_yearWiNDCHousehold.compute_economy_wide_savingsWiNDCHousehold.compute_savings_markup_consumptionWiNDCHousehold.compute_savings_markup_saveWiNDCHousehold.compute_savings_rateWiNDCHousehold.consumption_dataWiNDCHousehold.consumption_dataWiNDCHousehold.cpi_dataWiNDCHousehold.cpi_dataWiNDCHousehold.cps_vs_nipa_income_categoriesWiNDCHousehold.create_personal_consumptionWiNDCHousehold.disposition_dataWiNDCHousehold.disposition_dataWiNDCHousehold.duty_rateWiNDCHousehold.fetch_zip_dataWiNDCHousehold.fica_tax_rateWiNDCHousehold.get_capital_ownershipWiNDCHousehold.get_cps_data_apiWiNDCHousehold.government_dataWiNDCHousehold.government_dataWiNDCHousehold.government_deficitWiNDCHousehold.household_modelWiNDCHousehold.household_modelWiNDCHousehold.household_raw_dataWiNDCHousehold.household_raw_dataWiNDCHousehold.initialize_tableWiNDCHousehold.invest_dataWiNDCHousehold.invest_dataWiNDCHousehold.labor_dataWiNDCHousehold.labor_dataWiNDCHousehold.labor_endowment_multiplierWiNDCHousehold.labor_supplyWiNDCHousehold.leisure_consumption_elasticityWiNDCHousehold.leisure_demandWiNDCHousehold.load_acs_data_apiWiNDCHousehold.load_acs_medicare_dataWiNDCHousehold.load_capital_tax_ratesWiNDCHousehold.load_cex_income_elasticitiesWiNDCHousehold.load_cps_data_apiWiNDCHousehold.load_cps_income_categoriesWiNDCHousehold.load_labor_tax_ratesWiNDCHousehold.load_medicare_dataWiNDCHousehold.load_medicare_data_apiWiNDCHousehold.load_nipa_data_apiWiNDCHousehold.load_pce_sharesWiNDCHousehold.load_state_fipsWiNDCHousehold.load_windc_naics_mapWiNDCHousehold.margin_supply_dataWiNDCHousehold.margin_supply_dataWiNDCHousehold.marginal_labor_tax_rateWiNDCHousehold.netportsWiNDCHousehold.nipa_fringe_benefit_markupWiNDCHousehold.other_incomeWiNDCHousehold.output_tax_rateWiNDCHousehold.parameter_dataWiNDCHousehold.parameter_dataWiNDCHousehold.regional_local_supplyWiNDCHousehold.regional_national_supplyWiNDCHousehold.representative_agent_dataWiNDCHousehold.representative_agent_dataWiNDCHousehold.saverate_dataWiNDCHousehold.saverate_dataWiNDCHousehold.sectoral_outputWiNDCHousehold.sectoral_outputWiNDCHousehold.ssk_dataWiNDCHousehold.ssk_dataWiNDCHousehold.tax_rateWiNDCHousehold.total_supplyWiNDCHousehold.trans_dataWiNDCHousehold.trans_dataWiNDCHousehold.transfer_weightsWiNDCHousehold.windc_vs_nipa_income_categories
WiNDCHousehold.HouseholdTable — Type
HouseholdThe 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.
WiNDCHousehold.RawHouseholdData — Type
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.
WiNDCHousehold.NYSE_data — Method
NYSE_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts NYSE-related parameters from the regional data table.
Arguments
data::T: A WiNDCHousehold data table.
Keyword Arguments
output::Symbol = :DataFrame: The output format, either:DataFrameor:DefaultDict.
Returns
- A DataFrame or DefaultDict containing the parameter data.
Data
table(data,
:Household_Supply,
:Capital_Demand;
normalize=:Use
)WiNDCHousehold.absorption — Method
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 isfalse).
Returns
A DataFrame with the following structure:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| commodity | :abs | state | year | :absorption | value |
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_DemandOther_Final_Demand
Calculation
\[{\rm Absorption} = \sum_{\rm sectors} {\rm Intermediate\_Demand}} + \sum_{\rm other\_final\_demand}{{\rm Other\_Final\_Demand}}\]
WiNDCHousehold.adjust_capital_demand — Method
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
- Domain:
Capital_Tax- Fromstate_table
WiNDCHousehold.adjusted_capital_income — Method
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:capitalrepresenting 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}}\]
WiNDCHousehold.adjusted_consumption — Method
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:consumptionrepresenting 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}}\]
WiNDCHousehold.adjusted_wages — Method
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:wagerepresenting 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}\]
WiNDCHousehold.aggregate_transfer_payment — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :tt | household | state | year | :total_transfers | value |
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}\]
WiNDCHousehold.armington_data — Method
armington_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts Armington-related parameters from the regional data table.
Arguments
data::T: A WiNDCHousehold data table.
Keyword Arguments
output::Symbol = :DataFrame: The output format, either:DataFrameor: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
WiNDCHousehold.average_labor_tax_rate — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :altr | household | state | year | :averagelabortax_rate | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
Average_Labor_TaxLabor_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}\]
WiNDCHousehold.build_household_table — Method
build_household_table(
state_table::State,
raw_data::RawHouseholdData;
)Build a HouseholdTable from the given state_table and raw_data.
Disaggregation Steps
The disaggregation is performed through the following steps:
WiNDCHousehold.build_transfer_payments — Method
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_weightsraw_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
- Domain:
transfer_payments- Domain:
row - Description: "Transfer Payments"
- Domain:
| Element | Description |
|---|---|
hucval | unemployment compensation |
hwcval | workers compensation |
hssval | social security |
hssival | supplemental security |
hpawval | public assistance or welfare |
hvetval | veterans benefits |
hsurval | survivors income |
hdisval | disability |
hedval | educational assistance |
hcspval | child support |
hfinval | financial assistance |
medicare | edicare |
medicaid | edicaid |
other | Other Income |
WiNDCHousehold.calibration_model_1 — Method
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:
- Add errors if model fails to solve
WiNDCHousehold.calibration_model_2 — Method
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:
- Add errors if model fails to solve
WiNDCHousehold.capital_stock_data — Method
capital_stock_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts 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:DataFrameor:DefaultDict.
Returns
- A DataFrame or DefaultDict containing the parameter data.
Data
table(data, :Capital_Demand; normalize = :Use)WiNDCHousehold.capital_tax_rate — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :ktr | household | state | year | :capitaltaxrate | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
Capital_TaxCapital_Demand
Calculation
The capital tax rate is calculated as:
\[{\rm Capital\_Tax\_Rate} = \frac{\rm Capital\_Tax}{\rm Capital\_Demand}\]
WiNDCHousehold.clean_aggregate_medi_data — Method
clean_aggregate_medi_data(df::DataFrame)Cleans Medicare or Medicaid aggregate data DataFrame.
WiNDCHousehold.clean_cps_data_year — Method
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 loadvariables::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 fromload_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.
WiNDCHousehold.compute_economy_wide_savings — Method
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:yearand:economy_wide_sr0representing 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}\]
WiNDCHousehold.compute_savings_markup_consumption — Method
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}\]
WiNDCHousehold.compute_savings_markup_save — Method
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
raw_data.cps_data(CPS interest data)WiNDCHousehold.get_capital_ownership
Computation
\[ {\rm Savings\ Markup} = \frac{\rm Gross\ Capital\ Demand}{\rm Total\ Interest}\]
WiNDCHousehold.compute_savings_rate — Method
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_raterepresenting the savings rate for each household.
Computation
This computation is broken into several steps:
- Compute the economy-wide savings rate using
WiNDCHousehold.compute_economy_wide_savings. - Compute the savings markup for savings and consumption using:
- Calculate the interest shares and total shares for each household.
- 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}}\]
WiNDCHousehold.consumption_data — Method
consumption_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts consumption-related parameters from the regional data table.
Arguments
data::T: A WiNDCHousehold data table.
Keyword Arguments
output::Symbol = :DataFrame: The output format, either:DataFrameor:DefaultDict.
Returns
- A DataFrame or DefaultDict containing the parameter data.
Data
table(data, :Personal_Consumption; normalize = :Use)WiNDCHousehold.cpi_data — Method
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:DataFrameor: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)WiNDCHousehold.cps_vs_nipa_income_categories — Method
cps_vs_nipa_income_categories(cps_income::DataFrame, nipa::DataFrame)Compare CPS income data to NIPA data by income categories.
WiNDCHousehold.create_personal_consumption — Method
create_personal_consumption(
HH::HouseholdTable,
state_table::WiNDCRegional.State,
raw_data::RawHouseholdData,
M2::JuMP.Model
)WiNDCHousehold.disposition_data — Method
disposition_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts disposition-related parameters from the regional data table.
Arguments
data::T: A WiNDCHousehold data table.
Keyword Arguments
output::Symbol = :DataFrame: The output format, either:DataFrameor: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
WiNDCHousehold.duty_rate — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| commodity | :dr | state | year | :duty_rate | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
DutyImport
Calculation
\[{\rm Duty\_Rate} = \frac{\rm Duty}{\rm Import}\]
WiNDCHousehold.fetch_zip_data — Method
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
url::String: The url of the zip file to download.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 returntrueif the file should be extracted andfalseotherwise.
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.
WiNDCHousehold.fica_tax_rate — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :ftr | household | state | year | :ficataxrate | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
FICA_TaxLabor_Endowment
Calculation
The FICA tax rate is calculated as:
\[{\rm FICA\_Tax\_Rate} = \frac{\rm FICA\_Tax}{\sum_{\rm Destinations} \rm Labor\_Endowment}\]
WiNDCHousehold.get_capital_ownership — Method
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.
WiNDCHousehold.get_cps_data_api — Method
get_cps_data_api(year, vars, api_key)Pull the raw data directly from the API
WiNDCHousehold.government_data — Method
government_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts government-related parameters from the regional data table.
Arguments
data::T: A WiNDCHousehold data table.
Keyword Arguments
output::Symbol = :DataFrame: The output format, either:DataFrameor: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
WiNDCHousehold.government_deficit — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :gd | :gd | :gd | year | :government_deficit | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
Government_Final_DemandTransfer_PaymentAverage_Labor_TaxFICA_TaxCapital_TaxOutput_TaxTaxDuty
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)\]
WiNDCHousehold.household_model — Method
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 rateTR[r=states, g=commodities]: Tax rateDR[r=states, g=commodities]: Duty rateTK[r=states, s=sectors]: Capital tax rateFICA[r=states, h=households]: FICA tax rateLTR[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]:" ProductionX[r=states, g=commodities]:" DispositionA[r=states, g=commodities]:" AbsorptionC[r=states, h=households]:" Household ConsumptionMS[r=states, m=margins]:" Margin supplyLS[r=states, h=households]:" Labor supplyKS: Aggregate Capital stock
Commodities
PA[r=states, g=commodities]:" Regional market (input)PC[r=states, h=households]:" Consumer price indexPD[r=states, g=commodities]:" Local market pricePFX: Foreign exchangePK: Aggregate return to capitalPL[r=states]:" Wage ratePLS[r=states, h=households]:" Leisure pricePM[r=states, m=margins]:" Margin pricePN[g=commodities]:" National marketPY[r=states, g=commodities]:" Regional market (output)RK[r=states, s=sectors]:" Sectoral rental rateRKS: Capital stock
Consumers
RA[r=states, h=households]: Representative agentNYSE: Aggregate capital ownerINVEST: Aggregate investorGOVT: Aggregate government
Auxiliaries
All auxiliaries start with a value of 1.
SAVERATE: Domestic saving rateTRANS: Budget balance rationing variableSSK: Steady-state capital stockCPI: 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
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
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
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
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
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
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
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
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)
)WiNDCHousehold.household_raw_data — Method
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:
- A
Statetable object - A
WiNDCHousehold.RawHouseholdDataobject containing all the raw household data.
Raw Data Loaded
WiNDCHousehold.load_cps_data_apiWiNDCHousehold.load_nipa_data_apiWiNDCHousehold.load_acs_data_apiWiNDCHousehold.load_medicare_data_apiWiNDCHousehold.load_labor_tax_ratesWiNDCHousehold.load_capital_tax_ratesWiNDCHousehold.load_cex_income_elasticitiesWiNDCHousehold.load_pce_shares
Maps Loaded
WiNDCHousehold.initialize_table — Method
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_DemandDutyExportGovernment_Final_DemandHousehold_SupplyImportIntermediate_DemandIntermediate_SupplyInvestment_Final_DemandLabor_DemandLocal_DemandLocal_Margin_SupplyMargin_DemandNational_DemandNational_Margin_SupplyOutput_TaxReexportTax
Sets Maintained
dutyexportgovernment_final_demandimportinvestment_final_demandlocal_demandmarginnational_demandreexportsectortaxtradetransportstatecapital_demandcommoditylabor_demandoutput_taxyearFinal_DemandOther_Final_DemandMargin_SupplyUseSupplyValue_Added
Sets Added
household- Domain:
col - Description: "Household Categories"
- Elements:
hh1,hh2,hh3,hh4,hh5
- Domain:
WiNDCHousehold.invest_data — Method
invest_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts investment-related parameters from the regional data table.
Arguments
data::T: A WiNDCHousehold data table.
Keyword Arguments
output::Symbol = :DataFrame: The output format, either:DataFrameor:DefaultDict.
Returns
- A DataFrame or DefaultDict containing the parameter data.
Data
table(data,
:Investment_Final_Demand,
:Savings;
normalize=:Use
)WiNDCHousehold.labor_data — Method
labor_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts leisure-related parameters from the regional data table.
Arguments
data::T: A WiNDCHousehold data table.
Keyword Arguments
output::Symbol = :DataFrame: The output format, either:DataFrameor: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
WiNDCHousehold.labor_endowment_multiplier — Method
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:regionand:le_multrepresenting 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.
WiNDCHousehold.labor_supply — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :ls | household | state | year | :labor_supply | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
Labor EndowmentMarginal Labor TaxFICA Tax
Calculation
\[{\rm Labor\_Supply} = \sum (Labor\_Endowment - Marginal\_Labor\_Tax - FICA\_Tax)\]
WiNDCHousehold.leisure_consumption_elasticity — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :els | household | state | year | :leisureconsumptionelasticity | value |
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),
PCEis Personal Consumption ExpenditureLDis Leisure DemandLSis Labor Supply
```
WiNDCHousehold.leisure_demand — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :ld | household | state | year | :leisure_demand | value |
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).
WiNDCHousehold.load_acs_data_api — Method
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.xlsxWiNDCHousehold.load_acs_medicare_data — Method
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 ofload_state_fips().
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.
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.
WiNDCHousehold.load_capital_tax_rates — Method
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.
WiNDCHousehold.load_cex_income_elasticities — Method
load_cex_income_elasticities(path::String)Load CEX income elasticities from a CSV file located at path.
WiNDCHousehold.load_cps_data_api — Method
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 to2001: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
| Variable | Description |
|---|---|
| hwsval | wages and salaries |
| hseval | self-employment (nonfarm) |
| hfrval | self-employment farm |
| hucval | unemployment compensation |
| hwcval | workers compensation |
| hssval | social security |
| hssival | supplemental security |
| hpawval | public assistance or welfare |
| hvetval | veterans benefits |
| hsurval | survivors income |
| hdisval | disability |
| hintval | interest |
| hdivval | dividends |
| hrntval | rents |
| hedval | educational assistance |
| hcspval | child support |
| hfinval | financial assistance |
| hoival | other income |
| htotval | total household income |
| gestfips | state fips |
| a_exprrp | expanded relationship code |
| h_hhtype | type of household interview |
| pppos | person identifier |
| marsupwt | asec supplement final weight |
| hdstval | retirement distributions - Post 2019 |
| hpenval | pension income - Post 2019 |
| hannval | annuities - Post 2019 |
| hretval | retirement income - Pre 2019 |
WiNDCHousehold.load_cps_income_categories — Method
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.
WiNDCHousehold.load_labor_tax_rates — Method
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.
WiNDCHousehold.load_medicare_data — Method
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.
WiNDCHousehold.load_medicare_data_api — Method
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 ofload_state_fips().
Returns
A DataFrame containing Medicare and Medicaid data by state and year.
WiNDCHousehold.load_nipa_data_api — Method
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
| Variable | Value |
|---|---|
| Method | GetData |
| datasetname | NIPA |
| TableName | T20100 |
| Frequency | A |
| Year | Comma-separated list of years |
| ResultFormat | json |
WiNDCHousehold.load_pce_shares — Method
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.
WiNDCHousehold.load_state_fips — Method
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.
WiNDCHousehold.load_windc_naics_map — Method
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.
WiNDCHousehold.margin_supply_data — Method
margin_supply_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts 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:DataFrameor:DefaultDict.
Returns
- A DataFrame or DefaultDict containing the parameter data.
Data
table(data, :Margin_Demand, :Margin_Supply; normalize = :Use)WiNDCHousehold.marginal_labor_tax_rate — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :ltr | household | state | year | :marginallabortax_rate | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
Marginal_Labor_TaxLabor_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}\]
WiNDCHousehold.netports — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| commodity | :netport | state | year | :netport | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
ExportReexport
Calculation
\[{\rm Netports} = \sum (Export + Reexport)\]
WiNDCHousehold.nipa_fringe_benefit_markup — Method
nipa_fringe_benefit_markup(nipa::DataFrame)Calculate the fringe benefit markup from NIPA data.
WiNDCHousehold.other_income — Method
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:incomerepresenting 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:
Adjusted Consumptionis obtained fromWiNDCHousehold.adjusted_consumption.Adjusted Wagesis obtained fromWiNDCHousehold.adjusted_wages.Average Transfer Paymentsthe average over households and states of theTransfer_Paymentparameter inHH.Adjusted Capital Incomeis obtained fromWiNDCHousehold.adjusted_capital_income.
WiNDCHousehold.output_tax_rate — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| :otr | sector | state | year | :outputtaxrate | value |
Non-symbol values are sets.
Parameters
Intermediate_SupplyOutput_Tax
Calculation
\[{\rm Output\_Tax\_Rate} = \frac{\rm Output\_Tax}{\sum_{\rm commodity} \rm Intermediate\_Supply}\]
WiNDCHousehold.parameter_data — Method
parameter_data(data::T; output = :DataFrame) where T<:AbstractHouseholdTableReturns initial parameter data for the household model.
Arguments
data::T: A WiNDCHousehold data table.
Keyword Arguments
output::Symbol = :DataFrame: The output format, either:DataFrameor: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
WiNDCHousehold.regional_local_supply — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| commodity | :rls | state | year | :regionlocalsupply | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
Local_Margin_SupplyLocal_Demand
Calculation
\[{\rm Regional\_Local\_Supply} = \sum (Local\_Margin\_Supply + Local\_Demand)\]
WiNDCHousehold.regional_national_supply — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| commodity | :rns | state | year | :regionnationalsupply | value |
Non-symbol values are sets.
Aggregate Parameters
Calculation
\[{\rm Regional\_National\_Supply} = {\rm Total\_Supply} - {\rm Netports} - {\rm Regional\_Local\_Supply}\]
WiNDCHousehold.representative_agent_data — Method
representative_agent_data(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts 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:DataFrameor: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
WiNDCHousehold.saverate_data — Method
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:DataFrameor:DefaultDict.
Returns
- A DataFrame or DefaultDict containing the parameter data.
Data
table(HH, :Investment_Final_Demand; normalize=:Use)WiNDCHousehold.sectoral_output — Method
sectoral_output(data::T, output = :DataFrame) where T<:AbstractHouseholdTableExtracts 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:DataFrameor: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
WiNDCHousehold.ssk_data — Method
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:DataFrameor:DefaultDict.
Returns
- A DataFrame or DefaultDict containing the parameter data.
Data
table(HH, :Investment_Final_Demand; normalize=:Use)WiNDCHousehold.tax_rate — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| commodity | :tr | state | year | :tax_rate | value |
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}\]
WiNDCHousehold.total_supply — Method
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:
| row | col | region | year | parameter | value |
|---|---|---|---|---|---|
| commodity | :tot_sup | state | year | :total_supply | value |
Non-symbol values are sets.
Parameters
These values are extracted from the HouseholdTable
Intermediate_SupplyHousehold_Supply
Calculation
\[{\rm Total\_Supply} = \sum_{sectors} {\rm Intermediate\_Supply}} + {{\rm Household\_Supply}}\]
WiNDCHousehold.trans_data — Method
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:DataFrameor:DefaultDict.
Returns
- A DataFrame or DefaultDict containing the parameter data.
Data
table(HH, :Government_Final_Demand; normalize=:Use)WiNDCHousehold.transfer_weights — Method
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
| Category | Source |
|---|---|
| government benefits: unemployment insurance | hucval |
| government benefits: social security | hssval |
| government benefits: social security | hssival |
| government benefits: social security | hdisval |
| government benefits: veterans' benefits | hvetval |
Meyer and Rothbaum Weights
| Source | Literature | Value |
|---|---|---|
| hucval | meyer | 1/0.679 |
| hssval | meyer | 1/0.899 |
| hssival | meyer | 1/0.759 |
| hdisval | meyer | 1/0.819 |
| hvetval | rothbaum | 1/0.679 |
| hwcval | meyer | 1 / 0.527 |
| hpawval | meyer | 1 / 0.487 |
| hsurval | meyer | 1 / 0.908 |
| hedval | rothbaum | 1 / 0.804 |
| hcspval | rothbaum | 1 / 0.804 |
| hfinval | meyer | 1 / 0.539 |
WiNDCHousehold.windc_vs_nipa_income_categories — Method
windc_vs_nipa_income_categories(
state_table::WiNDCRegional.State,
nipa::DataFrame
)Compare WiNDC labor and capital income to NIPA data.