Skip to contents

Timing Lumpy Investments with Informal Bridge Loans and Clunky Formal Loans: Evidence from Thailand

This is the code and data repository for Jain, Townsend, and Wang (2023). The package documentation site is at https://fanwangecon.github.io/PrjThaiHFID/.

The package provides tools for constructing and analyzing links between lumpy household investments, informal bridge loans, and formal loans in Thai household-finance data. The philosophy is to first construct all possible loan/bridge linkages under weak requirements, and then, upon linking to investment, retain for final analysis only the subset of bridges that satisfy more stringent bridge-analysis requirements.

All shipped identifiers are anonymized: household, village, province, and region keys are replaced with anonymized tmid_* codes. No true household/geographic keys are committed to the repository.

Repository structure

  • R/ — exported functions: loan/hook/bridge construction, investment identification, return windows, the investment-loan-bridge gateway, and support helpers.
  • data/ — anonymized packaged datasets (lazy-loaded, e.g. tstm_loans), including vignette inputs and generated outputs.
  • data-raw/ — anonymization pipeline and anonymized build inputs (true-key crosswalks stay local and are git-ignored).
  • vignettes/ — eight Quarto articles forming a dependency-ordered analysis pipeline (see Articles).
  • res/ — local-only table/figure outputs written by vignettes (git-ignored; not shipped).

Data lineage

How anonymized data-raw/ build inputs and the anonymization pipeline produce the packaged data/ objects consumed by vignettes.

flowchart LR
  subgraph raw["data-raw/ (anonymized build inputs)"]
    whitem["whitem160aggregate_wthhhkey_loanamount.rda"]
    keyhh["tm_key_id_hh_anony.rda"]
    keyvil["tm_key_id_vil_anony.rda"]
    census["census_vil_hh_structure_count.rda"]
  end
  subgraph anon["data-raw/id_anonymize/ (pipeline)"]
    fun["fun_id_anonymize.R"]
  end
  subgraph dat["data/ (packaged, lazy-loaded)"]
    loans["tstm_loans"]
    panel["tstm_loans_panel"]
    assetloan["tstm_asset_loan"]
    loansamt["tstm_loans_amount"]
    mthspan["tstm_hh_mthspan"]
    gateway["8 gateway tstm_* objects"]
    stats["tstm_invest_stats_bridgechar"]
  end
  fun --> whitem
  fun --> keyhh
  fun --> keyvil
  whitem --> assetloan
  whitem --> loansamt
  panel --> assetloan
  assetloan --> mthspan
  assetloan --> gateway
  panel --> gateway
  gateway --> stats
  keyhh --> stats
  census --> stats

R program groups

flowchart TD
  subgraph loan["Loans / hooks / bridges"]
    a1["ffp_hfid_loan_non_duplicate"]
    a2["ffp_hfid_hook_pairs"]
    a3["ffp_hfid_bridge_from_hook"]
    a4["ffp_hfid_bridge_type"]
  end
  subgraph inv["Investments"]
    b1["ffp_hfid_invest_jump"]
    b2["ffp_hfid_invest_unique_dura"]
    b3["ffp_hfid_invest_combine"]
    b4["ffp_hfid_invest_gateway"]
  end
  subgraph win["Return windows"]
    c1["ff_hfid_invest_window"]
    c2["ff_hfid_invest_winstats"]
  end
  subgraph gw["Invest-loan-bridge gateway"]
    d1["ffp_hfid_invest_loan_bridge_roster"]
    d2["ffp_hfid_invest_loan_or_bridge_linker"]
    d3["ffp_hfid_invest_loan_linked*"]
    d4["..._abc_investloan_char_gateway"]
  end
  subgraph sup["Support"]
    e1["ffs_hfid_path"]
    e2["ffp_preview_dataset"]
    e3["ffp_save_res_table / ffp_save_res_figure"]
  end
  loan --> gw
  inv --> gw
  gw --> win

Vignette dependency tiers

flowchart TD
  t1["Tier 1: ffv_gen_asset_loan (#5)"]
  t2a["Tier 2: ffv_loan_terms_dist (#14)"]
  t2b["Tier 2: ffv_loan_terms_dist_comm (#14)"]
  t2c["Tier 2: ffv_loan_overlap (#36)"]
  t3["Tier 3: ffv_invest_loan_bridge (#32)"]
  t4a["Tier 4: ffv_invest_freq_sizes (#9)"]
  t4b["Tier 4: ffv_invest_return_bridge (#32/#2/#3)"]
  t5["Tier 5: ffv_bridge_timing (#34)"]
  t1 --> t2a
  t1 --> t2b
  t1 --> t2c
  t1 --> t3
  t1 --> t4a
  t1 --> t4b
  t3 --> t4b
  t3 --> t5

See the Project Map for the full program/data/vignette/issue cross-reference tables.