How samples are built

The decisions a paper rarely spells out in full — read from the code of the 10,383 replication packages with a page (linked to a paper by a confirmed link — the same packages as the home page). Counts are packages.

Winsorizing and trimming — cut points (percentiles)

1,635 packages cap or cut outliers. The two are different treatments and are counted apart: winsorizing replaces a value beyond the cut with the cut and keeps the observation; trimming removes it (sets it missing or drops the row), so it changes the sample. “none” = that tail is left alone (cuts(0 99), p(.01) high and a top-only cap are the same thing). winsor2 with no cuts() is its default 1/99; DescTools Winsorize() with no probs is its default 5/95. A package using several cuts counts once under each.

Winsorize (cap, keep the row) — 1,496 packages, 305 written by hand

  • 1/99
    933
  • none/99
    253
  • 5/95
    230
  • none/95
    86
  • 2.5/97.5
    80
  • 0.5/99.5
    80
  • 2/98
    49
  • 10/90
    37
  • 5/99
    35
  • 0.1/99.9
    32

Cut computed within groups — 235 packages

The percentile is taken inside each group (by(year)), not over the pooled sample.

  • within period (year, month, date)
    136
  • within another group
    107
  • within period × another group
    20
  • within industry
    3
  • within industry × period
    3
cut × grouping
  • 1/99 within period (year, month, date)
    107
  • 1/99 within another group
    64
  • 5/95 within another group
    24
  • 5/95 within period (year, month, date)
    16
  • 2.5/97.5 within period (year, month, date)
    12
  • none/99 within another group
    11

Trim (remove beyond the cut) — 253 packages, 78 written by hand

  • 1/99
    166
  • 5/95
    38
  • 0.5/99.5
    20
  • none/99
    18
  • 2.5/97.5
    15
  • none/95
    10
  • 2/98
    9
  • none/99.9
    5
  • 5/99
    5
  • 1/95
    3

Cut computed within groups — 36 packages

The percentile is taken inside each group (by(year)), not over the pooled sample.

  • within another group
    20
  • within period (year, month, date)
    14
  • within period × another group
    6
  • within industry
    2
cut × grouping
  • 1/99 within another group
    12
  • 1/99 within period (year, month, date)
    8
  • 1/99 within period × another group
    5
  • none/99 within another group
    4
  • none/99 within period (year, month, date)
    3
  • 0.5/99.5 within another group
    2
Cut not a percentile, or still not known — 114 packages

Recovered at build time from the call and the package's other files: psych::winsor's trim argument (the share cut in each tail) (8); the file's own Python function, read with the call's arguments (5); read from the call (probs=, .quantile() bounds, limits=, p() / cuts() arithmetic) (1); the winsorize() of the library the package loads, read by that library's arguments (1).

  • the call could not be read52
    • xtemp=winsorize(x,point); make_fmbwin.m:14
    • xt=winsorize(xt,winth); TianWucode_FunDailyORSestimation.m:48
    • prtchar=winsorize(prtchar,1); Moore-Velikov-main_Functions_._Scripts_prt_char.m:16
  • an R winsorize() that is neither DescTools nor readable from the package24
    • bal_highprin_w=winsorize_x(bal_highprin,cut_l=0.0,cut_u=winsor), RFSDelivery_Code_R_Clarity4_Section_7_Inquiries_and_Transactions_Main_Analysis.R:555
    • cat("Applying winsorization (1%-99%)...") 03_Table_8_11_12_13.R:247
    • estimate_label :="Winsorized (Top 0.1%)" ggmn_replication_code_4-analyses_06-make-figure-B-1.R:251
  • bounds computed earlier into variables19
    • data_c["q"]=data_c["q"].clip(0,q-1) RFSDelivery_Code_Python_2_American_Community_Survey_ACS2_FTP_TractControls.py:169
    • .(Winsorize(capex,probs=c(pct,1-pct),na.rm=T), build.R:1240
    • processed_df["logret"]=processed_df["logret_raw"].clip(lower=lower_bound,upper=upper_bound) data_cleaning.py:222
  • cut set by a macro the package never defines as a number12
    • winsor2 `v',cuts(`winsorlevels') suffix("_winsor") event_study_othassets.do:117
    • winsor2 `y',replace cuts(`WinsorisationLevel' 100 - (`WinsorisationLevel')) 35 Table outlier analysis.do:18
    • capture: winsor `var',gen(`var'_WH`cutoff') p(`cutoff'/100) highonly ISKK_religiosity_municipality_panel_data_clean.do:104
  • Cox's winsor h(#): a number of extreme values, not a percentile6
    • winsor std_diff,gen(w_std_diff) h(`i') highonly do_file_v2.do:173
    • winsor trad_ass,g(w_trad_ass) h(1) low data_assemble_2_jf.do:17
    • winsor assets if fyear==`jj'+1998,gen(assets`jj') h(10) Robustness.do:37
  • an R winsorize() from a library the package does not include (not DescTools, datawizard, statar, robustHD)3
    • bk[,log_propertyvalue_w:=winsorize(log_propertyvalue,fraction=0.01,na.rm=T)] 4. Regression discontinuities.R:60
    • panel_daily[,abmedia :=winsorize(100*(mediacount/normmedia - 1))] generate_figures.R:80
    • fun<- function(x) winsorize(ifelse(x>0,x,NA),pmin=0,pmax=0.995) data_source_crsptaq_202112_ctm_mth.R:85
  • the package's own winsorizing program, cut set by its argument1
    • cap winsor `var' 1 main.do:712

Not counted at all: 12 packages whose only “winsorizing” is a clip at fixed values (.clip(upper=1), Winsorize(x, minval=0, maxval=1)) — a bound on the variable, not a cut at a percentile.

Which industries are screened out

263 packages restrict by industry. Each condition is read into the set of codes it selects, so sic>=6000 & sic<=6999, substr(sic,1,1)=="6", inrange(sic2,60,69) and keep if (df.siccd<6000)|(df.siccd>6999) are one row — exclude SIC 6000–6999 — with the ways it is written listed under it (spellings differing only in spaces, quotes or case are merged). A named screen covers whole conventional sectors; 6000–6799 leaves out SIC 68–69, which hold no firms, so it is the same screen in practice and is shown as its own row.

Every readable screen, named or not (top 25 code sets)
1,701 of 4,023 industry conditions read into a code set; the rest test a loop macro (sic2 == `l'), a text label, or a non-industry term, and are left out rather than guessed. Classification used: SIC 285, NAICS 241, GICS 12, FF 11. A further 238 packages drop rows whose industry code is missing — a data-completeness step, not an industry screen, and not counted above. 98 more packages test an industry code in a way no code set is read from (a loop macro, code 0 or a code in no sector — a total or "unknown" row, not an industry) and are not counted either. A variable is read as an industry code only when its name is the code itself: naics_length, naics_level, naics_type or naics_sic_cat describe a code (its digits, level or category), and are not industry screens.

Keep / drop conditions, by what they test

7,206 of the 10,383 packages keep or drop rows by a condition. Each row is a kind of condition, counted in packages (% of the 10,383); a package using several kinds counts under each. Drops right after a merge (drop if _merge==2) are bookkeeping and are left out. Open a row for examples with file:line and the packages.

What the code does Packageskeep / drop
Missing values — rows where a variable is missing, e.g. drop if roa==.
5,458 53% 3,259 / 4,731
0/1 indicator — rows where a dummy (flag) variable is 1, or 0, e.g. keep if treated==1
5,383 52% 4,653 / 3,468
Value range — a numeric variable compared to a threshold, e.g. drop if at<10
5,309 51% 4,263 / 3,606
Category or code — rows with a given code or label of a categorical variable, e.g. keep if shrcd==10 | shrcd==11
5,113 49% 4,275 / 3,566
Time period — keeps or drops rows by fixed years or dates, e.g. keep if fyear>=1990 & fyear<=2018
4,813 46% 4,163 / 3,018
Row position — the first / last row, or a row number, within the data or a group, e.g. by gvkey: keep if _n==1
2,224 21% 1,634 / 1,213
Geography — a country, state, county or region, e.g. keep if country=="USA"
2,074 20% 1,411 / 1,350
Other condition — a condition the reader places in none of the categories above, e.g. keep if touse
1,976 19% 1,614 / 735
Moving time window — a date window set by a variable — a rolling estimation window or a loop over periods, not the sample's fixed years, e.g. df[df.date < t]
1,793 17% 1,504 / 576
Demographics — age, sex, education or another person attribute, e.g. keep if age>=25 & age<=64
1,774 17% 1,420 / 873
Industry — an industry-code condition (the screens above read it into code sets), e.g. drop if sic>=6000 & sic<=6999
517 5% 286 / 342
Percentile cut — a cut at a percentile computed in the code (not a winsorize call), e.g. drop if x<r(p1)
249 2% 124 / 137

Missing data

6,609 of the 10,383 packages handle missing values in code. A zero or a value put in a missing cell is split by what it is for: an imputation (the value is unknown and something stands in), or building a variable (a dummy that is 0 when nothing happened).

What the code does Packages
Drop rows with a missing value — the row leaves the sample, e.g. drop if x==.
5,272 51%
Missing set to 0 — imputation — an unknown value is replaced by zero (e.g. R&D), e.g. replace xrd=0 if xrd==.
3,576 34%
Missing filled with a value — imputation — a mean, median, previous value or constant stands in, e.g. replace x=x[_n-1] if x==.
3,462 33%
Keep one estimation sample — keep the rows a previous model used, so every column has the same observations, e.g. keep if e(sample)
2,159 21%
Value filled while building a variable — a default for a variable being made, e.g. replace age=agesec if mi(age)
  • by firm_id hs: replace end_by_new1 = 1 if break_episode~=. & break_episode[_n+1]~=break_episode[_n] & break_new[_n+1]==1 & end_by_new1==. tabJ1.do:93
  • replace year_start = l.year_start if year_start == . & l.year_start ~= . & _spell == l._spell step2_inflation_surge.do:105
  • replace row_cty = 4 if row_cty ==. wiod.do:115
  • bys id (period): replace trainmon=ds_train+trainmon[_n-1] if trainmon==. TFDW_B_Cleaning.do:480
1,948 19%
0 while building a variable — a count or dummy that is 0 when the event did not happen — not a guess at a missing value, e.g. gen d = cond(x==., 0, 1)
1,858 18%
Gaps filled — rows added to a panel (tsfill) or values interpolated / carried forward, e.g. tsfill
1,316 13%
Missing set to 0 — purpose not read — replaced by zero; whether it imputes or builds a variable was not decided, e.g. replace x=0 if x==.
1,300 13%
Missing filled with a value — purpose not read — filled; imputation or construction not decided, e.g. replace x=-1 if x==.
1,145 11%
Code recoded to missing — a placeholder value turned into missing, e.g. replace x=. if x==-9
135 1%
Multiple imputation — a formal imputation model, e.g. mi impute
55 1%

Sorting into groups

1,564 packages sort a variable into quantile groups (xtile, nq(), pd.qcut) — for portfolios, binned scatters, heterogeneity splits.

  • deciles
    446
  • quartiles
    377
  • quintiles
    345
  • percentiles
    273
  • terciles
    263
  • halves
    262
  • 20 bins (vigintiles)
    148
  • 50 groups
    44
  • 1000 groups
    31
  • 200 groups
    21

Aggregating to a coarser unit

The statistic used when rows are collapsed (collapse (mean) …), by packages.

  • mean
    4146
  • sum
    3135
  • max
    907
  • count
    708
  • min
    388
  • first
    369
  • median
    348
  • sd
    238

Panel frequency declared

  • annual
    2007
  • monthly
    595
  • quarterly
    482
  • daily
    204
  • weekly
    65
  • halfyearly
    17
  • hourly
    2

Units of analysis

  • geography
    2830
  • firm
    1176
  • industry
    862
  • demographic
    858
  • person
    718
  • treatment group
    545
  • product
    387
  • household
    286
  • strata
    213
  • bank
    174
  • school
    154
  • fund
    121
  • occupation
    119
  • loan
    86