Collapse transaction-level trade data to a firm-year panel
Source:R/trade-panel.R
build_trade_panel.RdThe raw trade file has one row per firm, year, flow (trade_type
1 = import, 2 = export), destination country and CN8 product. The result
has one row per firm-year with, for each flow, the total value, the number
of distinct 6-digit products and the largest product's share; for exports
also the number of destination countries (all and EU). Imports have no
partner country in the data, so their partner counts are dropped.
Arguments
- config
A
scaleup_configfromconfig_scaleup().- trade_raw
Data frame with
idf, year, trade_type, trade_value(numeric) andcode_destin, prod_code(string), as in thetrade_RAWrows of variable_dictionary (vignette("input-trade-data")).- storage_types
Optional storage types of
trade_raw's columns (seebuild_accounts_indicators()); used for the PT/HU rescaling.
Details
Values are stored as in the original routines (float totals, double
sums); products whose 6-digit total is
below 1 (thousand EUR) are blanked before the counts; a flow whose values
were all missing stays missing after the collapse (which would sum them to
0); a flow that is entirely absent stays missing for every firm.