Skip to content

Use complete Margins and not PCE Bridge for PUR to PRO conversion in nipa_final_demand_estimates #4

@WesIngwersen

Description

@WesIngwersen

The PCE Bridge file is used to relate PCE data to the BEA Commodities which is appropriate.

# Extract the 2017 PCE Bridge as the basis for attribution
url = 'https://apps.bea.gov/industry/release/xlsx/PCEBridge_Detail.xlsx'
bridge = pd.read_excel(url, sheet_name='2017', header=4)
bridge['Activity'] = bridge['PCE Category'] + ' (' + bridge['NIPA Line'].astype('str') + ')'
df = (nipa_PCE
.merge(bridge.filter(['Activity', 'NIPA Line', 'Commodity Code', 'Commodity Description', 'Unnamed: 8']),
how='left', left_on='Line', right_on='NIPA Line')
.rename(columns={'Unnamed: 8': 'Value'}) # Purchasers value
)

However, the PCE Bridge is used later in the script to get data for margins that are used to transform the FD household data

margins_df = (bridge
.filter(['Commodity Code', 'Unnamed: 4', 'Unnamed: 8'])
.rename(columns={'Unnamed: 4': 'Producer',
'Unnamed: 8': 'Purchaser'})
.groupby('Commodity Code').agg('sum')
.reset_index()
.assign(BEA = lambda x: x['Commodity Code'].astype('str'))
# .assign(phi = lambda x: x['Producer'] / x['Purchaser'])
.set_index('BEA')
.reindex(U_17.index, fill_value=0)
)
household_fd = U_17['F01000/US'] # drop value added rows
margin_ratio = (household_fd / 1000000) / margins_df['Purchaser']
combined = combined.reindex(U_17.index, fill_value=0)
combined_pro = combined.mul(pd.Series(margin_ratio).fillna(1), axis=0)

The complete Margins data are more appropriate to use for these margins because they cover all of final demand.

The margins can be used to subtract from the PUR price FD values to get PRO FD values and add the total values for each margin sector to its own row (which is being done already)

The challenge that remains here is splitting the amount for each margin category (e.g. Transportation) across the individual sectors (e.g. Truck transport, water transport).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions