Skip to contents

Translates n0_1_accounts_indicators_v2.do (Pseudocode/n0_1_accounts_indicators_v2.md). Cleans the raw firm-level panel, optionally folds in establishment-level plant data, and constructs every derived variable the other 4 pipeline stages depend on: growth rates, high-growth-firm (HGF) flags, age/size/sector/region categories, the TL3 urbanisation typology, labour productivity, multi-factor productivity (Solow residual), and the acquisition indicator.

Usage

build_accounts_indicators(
  config,
  base_financials,
  plants_raw = NULL,
  exchange_rates = NULL,
  tl3_typology = NULL
)

Arguments

config

A scaleup_config from config_scaleup().

base_financials

A data frame of raw firm-level financials, matching the BASE_FINANCIALS sheet of variable_dictionary_v1.xlsx. Must contain idf, year, sector_1d, sector_2d, sector_3d, employment, turnover, region_2d; every other column is optional and used only if present.

plants_raw

Optional data frame of establishment-level data (the PLANTS_RAW sheet), with columns idf, idp, year. If NULL (the default), no multiplant indicator is produced.

exchange_rates

Optional data frame with columns year, country, rate (as shipped in this package's exchange_rates dataset). Required only for the non-Euro countries listed in country_patches$non_euro.

tl3_typology

Optional data frame with columns region_3d, typology_access_cities (as shipped in this package's tl3_typology dataset). Required only if base_financials has a region_3d column.

Value

A data frame, one row per (idf, year), ready to be passed to compute_characteristics(), compute_persistence(), compute_contribution(), and compute_predictors().

Details

Unlike the source .do file, this is a pure function: it takes already-loaded data frames and returns the built panel, rather than reading/writing .dta files itself (that I/O now lives in run_scaleup_pipeline(), mirroring MASTER_OECD_p2.do's role). This also means the row-order-dependent sort idf year step in the source is unnecessary here: every lag/lead below is computed via panel_lag() / panel_lead(), which key off (idf, year) values directly rather than physical row position.