Each row is a hooked loan pair, defined as cases where (loan_start <= loan_start_paired) & (loan_start_paired <= loan_end) & (loan_end <= loan_end_paired) is satisfied.
Note this potentially allows for the hooked loan to have just 1 month. The paired bottom hook loan must be connected to the paired top hook loan.
Format
loan pair dataframe with various top loan and bottom loan attributes
- hhid_Num
household id
- hh_loan_id_nd
non-duplicate loan id, sequential for all loans, top loan
- hh_loan_id_nd_paired
non-duplicate loan id, sequential for all loans, bottom hooked loan
- loan_start
loan start month, top loan
- loan_start_paired
loan start month, bottom hooked loan
- loan_end
loan end month, top loan
- loan_end_paired
loan end month, bottom hooked loan
- forinfm4
name of categorical variable defining loan group types, top loan
- forinfm4_paired
name of categorical variable defining loan group types, bottom hooked loan
- hook_gap_gl
GL: top left - bottom left, GL> 0, the bottom loan is taken out after the top loan.
- hook_gap_gm
GM: bottom left - top right, GM >= 0, the top loan is not due yet or just due when the bottom loan is taken out.
- hook_gap_gr
GR: top right - bottom right, GR > 0, the bottom loan is due after the top loan is due.
Source
Regenerated by
vignettes/ffv_invest_loan_bridge.qmd
via ffp_hfid_invest_loan_linked_abc_investloan_char_gateway()
(PrjThaiHFID-#32).
Set bl_replace_data_output <- TRUE in the vignette to overwrite data/*.rda.
MBF filters: investment months 14–144, fl_min_invest_size = 10000,
ar_st_vars_to_keep = c("agg_BS_1021", "agg_BS_1012", "agg_BS_1011").
Packaged inputs: tstm_loans_panel, tstm_asset_loan (see ?tstm_loans_panel).
Group A (loan hooks/bridges): built from tstm_loans_panel inside the gateway.
See also issue-18.
Examples
data(tstm_loans_hooks)
ffp_preview_dataset(tstm_loans_hooks)
#>
#> ── tstm_loans_hooks ────────────────────────────────────────────────────────────
#> Dimensions: 47754 rows × 12 columns(3.8 Mb)
#>
#> ── Column names (12) ──
#>
#> • 1. hhid_Num
#> • 2. hh_loan_id_nd
#> • 3. hh_loan_id_nd_paired
#> • 4. loan_start
#> • 5. loan_start_paired
#> • 6. loan_end
#> • 7. loan_end_paired
#> • 8. forinfm4
#> • 9. forinfm4_paired
#> • 10. hook_gap_gl
#> • 11. hook_gap_gm
#> • 12. hook_gap_gr
#>
#> ── Summary statistics (all variables) ──
#>
#> hhid_Num hh_loan_id_nd hh_loan_id_nd_paired loan_start
#> Min. :1003 Min. : 1 Min. : 2 Min. : 0.00
#> 1st Qu.:3107 1st Qu.: 4962 1st Qu.: 4965 1st Qu.: 47.00
#> Median :5279 Median : 9748 Median : 9750 Median : 77.00
#> Mean :5420 Mean : 9845 Mean : 9850 Mean : 76.81
#> 3rd Qu.:7668 3rd Qu.:14756 3rd Qu.:14760 3rd Qu.:108.00
#> Max. :9996 Max. :19586 Max. :19587 Max. :160.00
#> loan_start_paired loan_end loan_end_paired forinfm4
#> Min. : 0.00 Min. : 0.00 Min. : 0.0 Length :47754
#> 1st Qu.: 61.00 1st Qu.: 65.00 1st Qu.: 75.0 N.unique : 4
#> Median : 87.00 Median : 91.00 Median :102.0 N.blank : 0
#> Mean : 88.05 Mean : 93.14 Mean :103.8 Min.nchar: 8
#> 3rd Qu.:120.00 3rd Qu.:125.00 3rd Qu.:137.0 Max.nchar: 15
#> Max. :160.00 Max. :160.00 Max. :160.0
#> forinfm4_paired hook_gap_gl hook_gap_gm hook_gap_gr
#> Length :47754 Min. : 0.00 Min. : 0.00 Min. : 0.00
#> N.unique : 4 1st Qu.: 3.00 1st Qu.: 0.00 1st Qu.: 2.00
#> N.blank : 0 Median : 8.00 Median : 3.00 Median : 7.00
#> Min.nchar: 8 Mean : 11.24 Mean : 5.09 Mean : 10.63
#> Max.nchar: 15 3rd Qu.: 12.00 3rd Qu.: 7.00 3rd Qu.: 12.00
#> Max. :159.00 Max. :159.00 Max. :159.00
#> ── Sample rows (first 6) ──
#>
#> # A tibble: 6 × 12
#> hhid_Num hh_loan_id_nd hh_loan_id_nd_paired loan_start loan_start_paired
#> <int> <int> <int> <dbl> <dbl>
#> 1 1003 1 2 1 1
#> 2 1003 1 4 1 3
#> 3 1003 2 5 1 9
#> 4 1003 2 6 1 10
#> 5 1003 2 7 1 10
#> 6 1003 3 4 2 3
#> # ℹ 7 more variables: loan_end <dbl>, loan_end_paired <dbl>, forinfm4 <chr>,
#> # forinfm4_paired <chr>, hook_gap_gl <dbl>, hook_gap_gm <dbl>,
#> # hook_gap_gr <dbl>
if (requireNamespace("dplyr", quietly = TRUE)) {
tb_tally <- tstm_loans_hooks |>
dplyr::group_by(hook_gap_gl, hook_gap_gm, hook_gap_gr) |>
dplyr::tally() |>
dplyr::arrange(dplyr::desc(n))
print(utils::head(tb_tally, 10L))
}
#> # A tibble: 10 × 4
#> # Groups: hook_gap_gl, hook_gap_gm [7]
#> hook_gap_gl hook_gap_gm hook_gap_gr n
#> <dbl> <dbl> <dbl> <int>
#> 1 12 0 12 2233
#> 2 11 0 12 718
#> 3 12 0 0 635
#> 4 0 0 12 626
#> 5 12 0 11 601
#> 6 3 9 3 414
#> 7 12 0 13 367
#> 8 6 6 6 363
#> 9 9 3 9 363
#> 10 13 0 12 339