A loan bridge consists of three components, left-bank loan (loan A), bridge loan (loan B), and right-bank loan (loan C). Bridges can be compound and linked together to form a multiple-path bridge
Format
loan bridge dataframe with various top loan, middle loan, and bottom loan attributes.
- bridge_id
multiple-path compound bridge id, this is not the id for each row, but for a group of rows that are linked together as a multiple-path joint/compound bridge
- br_type
one of eight multiple-path joint/compound bridge types, see issue-19-Multiple-path bridges
- br_type_id
multiple-path compound bridge id, counter with each of the eight path types
- hhid_Num
household id
- hh_loan_id_nd_1t2
non-duplicate loan id, sequential for all loans, top loan of bridge, loan set A
- hh_loan_id_nd_paired_1t2
non-duplicate loan id, sequential for all loans, middle loan of bridge, loan set B
- hh_loan_id_nd_paired_2t3
non-duplicate loan id, sequential for all loans, bottom loan of bridge, loan set C
- hh_br_la_n
count within household each loan a id occurrences, top loan of bridge
- hh_br_lb_n
count within household each loan b id occurrences, middle loan of bridge
- hh_br_lc_n
count within household each loan c id occurrences, bottom loan of bridge
- loan_start_1t2
loan start month, top loan of bridge
- loan_end_1t2
loan end month, top loan of bridge
- loan_start_paired_1t2
loan start month, middle loan of bridge
- loan_end_paired_1t2
loan end month, middle loan of bridge
- loan_start_paired_2t3
loan start month, bottom loan of bridge
- loan_end_paired_2t3
loan end month, bottom loan of bridge
- forinfm4_1t2
name of categorical variable defining loan group types, top loan of bridge
- forinfm4_paired_1t2
name of categorical variable defining loan group types, middle loan of bridge
- forinfm4_paired_2t3
name of categorical variable defining loan group types, bottom loan of bridge
- loan_principal_1t2
loan principal aggregating over individual loans with the same dates and lender type, top loan of bridge
- loan_principal_paired_1t2
loan principal aggregating over individual loans with the same dates and lender type, middle loan of bridge
- loan_principal_paired_2t3
loan principal aggregating over individual loans with the same dates and lender type, bottom loan of bridge
- loan_principal_last_1t2
Last month of principal repayment in loan panel, top loan of bridge
- loan_principal_last_paired_1t2
Last month of principal repayment in loan panel, middle loan of bridge
- loan_principal_last_paired_2t3
Last month of principal repayment in loan panel, bottom loan of bridge
- loan_interest_monthly_1t2
monthly interest rate given aggregated interests and principals, top loan of bridge, monthly compounding rate (see Issue-24).
- loan_interest_monthly_paired_1t2
monthly interest rate given aggregated interests and principals, middle loan of bridge, monthly compounding rate (see Issue-24).
- loan_interest_monthly_paired_2t3
monthly interest rate given aggregated interests and principals, bottom loan of bridge, monthly compounding rate (see Issue-24).
- ll_g12l
G12L: start of B - start of A
- ll_g12m
G12M: end of A - start of B
- ll_g12r
G12R: end of B - end of A
- ll_g23l
G23L: start of C - start of B
- ll_g23m
G23M: end of B - start of C
- ll_g23r
G23R: end of C - end of B
- ll_gw1
GW1: loan A gap
- ll_gw2
GW2: loan B gap
- ll_gw3
GW3: loan C gap
- ll_grv
River width (GRV) = G12R - G23M = G23L - G12M
- ll_gab
Abutment width (GAB) = G12M + G23M, Left-abutment width = G12M, Right-abutment width = G23M
- ll_gap
Approach width (GAP) = G12L + G23R, Left-approach width = G12L, Right-approach width = G23R
- ll_gtt
Total bridge length, loan_end_paired_2t3 - loan_start_1t2
- bl_lender_type
Lender type requirement, to be a bridge loan, by definition loan A and loan B can not be from the same lender, and loan B and loan C can not be from the same lender. Filter out loans that can not possibly be bridge, because it is from the same lender type in connected pieces.
if_else((forinfm4_1t2 != forinfm4_paired_1t2) & (forinfm4_paired_1t2 != forinfm4_paired_2t3), TRUE, FALSE))- bl_bridge_informal
Lender type informal as middle (component B) bridge component, with formal lender as component A and C of bridge.
bl_bridge_informal = if_else(forinfm4_1t2 %in% c("BAAC-Commercial", "Village-Fund") & forinfm4_paired_1t2 %in% c("Informal", "Quasi-formal") & forinfm4_paired_2t3 %in% c("BAAC-Commercial", "Village-Fund"), TRUE, FALSE))- bl_loan_size
Loan size based filter, relative loan size filter, bridge loan size is smaller than the loans it is connecting together.
bl_loan_size = if_else((loan_principal_1t2 >= loan_principal_paired_1t2) & (loan_principal_paired_2t3 >= loan_principal_paired_1t2), TRUE, FALSE))- bl_loan_dura_a
Duration a requirement.
if_else((ll_gw1 > ll_gw2) & (ll_gw3 > ll_gw2), TRUE, FALSE))- bl_loan_dura_b
Duration b requirement.
bl_loan_dura_b = if_else((ll_gw1 >= 11) & (ll_gw3 >= 11), TRUE, FALSE)- bl_loan_dura_c
Duration c requirement.
if_else(ll_gap > (ll_gab + ll_grv)*fl_approach_rela_bridge, TRUE, FALSE))
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-19.
Downstream vignettes: consumed by ffv_bridge_timing for bridge-segment
timing figures (issue
#34).
Examples
data(tstm_loans_bridges_type)
ffp_preview_dataset(tstm_loans_bridges_type)
#>
#> ── tstm_loans_bridges_type ─────────────────────────────────────────────────────
#> Dimensions: 94907 rows × 47 columns(30.4 Mb)
#>
#> ── Column names (47) ──
#>
#> • 1. bridge_id
#> • 2. br_type
#> • 3. br_type_id
#> • 4. hhid_Num
#> • 5. hh_loan_id_nd_1t2
#> • 6. hh_loan_id_nd_paired_1t2
#> • 7. hh_loan_id_nd_paired_2t3
#> • 8. hh_br_la_n
#> • 9. hh_br_lb_n
#> • 10. hh_br_lc_n
#> • 11. loan_start_1t2
#> • 12. loan_end_1t2
#> • 13. loan_start_paired_1t2
#> • 14. loan_end_paired_1t2
#> • 15. loan_start_paired_2t3
#> • 16. loan_end_paired_2t3
#> • 17. forinfm4_1t2
#> • 18. forinfm4_paired_1t2
#> • 19. forinfm4_paired_2t3
#> • 20. loan_principal_1t2
#> • 21. loan_principal_paired_1t2
#> • 22. loan_principal_paired_2t3
#> • 23. loan_principal_last_1t2
#> • 24. loan_principal_last_paired_1t2
#> • 25. loan_principal_last_paired_2t3
#> • 26. loan_interest_monthly_1t2
#> • 27. loan_interest_monthly_paired_1t2
#> • 28. loan_interest_monthly_paired_2t3
#> • 29. ll_g12l
#> • 30. ll_g12m
#> • 31. ll_g12r
#> • 32. ll_g23l
#> • 33. ll_g23m
#> • 34. ll_g23r
#> • 35. ll_gw1
#> • 36. ll_gw2
#> • 37. ll_gw3
#> • 38. ll_grv
#> • 39. ll_gab
#> • 40. ll_gap
#> • 41. ll_gtt
#> • 42. bl_lender_type
#> • 43. bl_bridge_informal
#> • 44. bl_loan_size
#> • 45. bl_loan_dura_a
#> • 46. bl_loan_dura_b
#> • 47. bl_loan_dura_c
#>
#> ── Summary statistics (all variables) ──
#>
#> bridge_id br_type br_type_id hhid_Num
#> Min. : 1 Length :94907 Min. : 1 Min. :1003
#> 1st Qu.: 6940 N.unique : 7 1st Qu.: 833 1st Qu.:3133
#> Median :11285 N.blank : 0 Median :1707 Median :5272
#> Mean :10708 Min.nchar: 3 Mean :1847 Mean :5436
#> 3rd Qu.:14228 Max.nchar: 3 3rd Qu.:2828 3rd Qu.:7641
#> Max. :19758 NAs : 2011 Max. :4375 Max. :9996
#>
#> hh_loan_id_nd_1t2 hh_loan_id_nd_paired_1t2 hh_loan_id_nd_paired_2t3
#> Min. : 2 Min. : 5 Min. : 7
#> 1st Qu.: 5040 1st Qu.: 5041 1st Qu.: 5046
#> Median : 9721 Median : 9723 Median : 9726
#> Mean : 9882 Mean : 9887 Mean : 9892
#> 3rd Qu.:14656 3rd Qu.:14659 3rd Qu.:14661
#> Max. :19584 Max. :19585 Max. :19587
#>
#> hh_br_la_n hh_br_lb_n hh_br_lc_n loan_start_1t2
#> Min. : 1.00 Min. : 1.00 Min. : 1.00 Min. : 1.00
#> 1st Qu.: 7.00 1st Qu.: 6.00 1st Qu.: 7.00 1st Qu.: 48.00
#> Median : 12.00 Median : 13.00 Median : 12.00 Median : 74.00
#> Mean : 15.56 Mean : 16.84 Mean : 16.19 Mean : 72.61
#> 3rd Qu.: 20.00 3rd Qu.: 21.00 3rd Qu.: 20.00 3rd Qu.: 98.00
#> Max. :120.00 Max. :144.00 Max. :125.00 Max. :157.00
#>
#> loan_end_1t2 loan_start_paired_1t2 loan_end_paired_1t2
#> Min. : 2.00 Min. : 2.00 Min. : 3.00
#> 1st Qu.: 65.00 1st Qu.: 61.00 1st Qu.: 76.00
#> Median : 88.00 Median : 83.00 Median : 99.00
#> Mean : 87.87 Mean : 83.79 Mean : 99.67
#> 3rd Qu.:113.00 3rd Qu.:109.00 3rd Qu.:125.00
#> Max. :159.00 Max. :159.00 Max. :159.00
#>
#> loan_start_paired_2t3 loan_end_paired_2t3 forinfm4_1t2
#> Min. : 2.00 Min. : 4.0 Length :94907
#> 1st Qu.: 73.00 1st Qu.: 88.0 N.unique : 4
#> Median : 94.00 Median :111.0 N.blank : 0
#> Mean : 95.67 Mean :111.3 Min.nchar: 8
#> 3rd Qu.:122.00 3rd Qu.:139.0 Max.nchar: 15
#> Max. :159.00 Max. :160.0
#>
#> forinfm4_paired_1t2 forinfm4_paired_2t3 loan_principal_1t2
#> Length :94907 Length :94907 Min. : 150
#> N.unique : 4 N.unique : 4 1st Qu.: 5000
#> N.blank : 0 N.blank : 0 Median : 13280
#> Min.nchar: 8 Min.nchar: 8 Mean : 27032
#> Max.nchar: 15 Max.nchar: 15 3rd Qu.: 22000
#> Max. :3823531
#> NAs :2
#> loan_principal_paired_1t2 loan_principal_paired_2t3 loan_principal_last_1t2
#> Min. : 200 Min. : 200 Min. : 0
#> 1st Qu.: 5000 1st Qu.: 5000 1st Qu.: 3000
#> Median : 15000 Median : 15500 Median : 11000
#> Mean : 28541 Mean : 32773 Mean : 23009
#> 3rd Qu.: 25000 3rd Qu.: 30000 3rd Qu.: 20000
#> Max. :2000000 Max. :4100000 Max. :2000000
#> NAs :1 NAs :1
#> loan_principal_last_paired_1t2 loan_principal_last_paired_2t3
#> Min. : 0 Min. : 0
#> 1st Qu.: 3500 1st Qu.: 2450
#> Median : 13000 Median : 11000
#> Mean : 23989 Mean : 23430
#> 3rd Qu.: 20000 3rd Qu.: 20000
#> Max. :2000000 Max. :2000000
#>
#> loan_interest_monthly_1t2 loan_interest_monthly_paired_1t2
#> Min. :-1.000000 Min. :-1.000000
#> 1st Qu.: 0.003339 1st Qu.: 0.003274
#> Median : 0.004868 Median : 0.004844
#> Mean : 0.004857 Mean : 0.003878
#> 3rd Qu.: 0.007358 3rd Qu.: 0.006649
#> Max. : 0.414214 Max. : 0.311488
#> NAs :2 NAs :1
#> loan_interest_monthly_paired_2t3 ll_g12l ll_g12m
#> Min. :-1.000000 Min. : 1.00 Min. : 0.00
#> 1st Qu.: 0.002276 1st Qu.: 4.00 1st Qu.: 0.00
#> Median : 0.004492 Median : 9.00 Median : 3.00
#> Mean :-0.061221 Mean : 11.18 Mean : 4.08
#> 3rd Qu.: 0.005938 3rd Qu.: 12.00 3rd Qu.: 6.00
#> Max. : 0.311488 Max. :147.00 Max. :122.00
#> NAs :1
#> ll_g12r ll_g23l ll_g23m ll_g23r
#> Min. : 0.0 Min. : 0.00 Min. : 0.000 Min. : 1.00
#> 1st Qu.: 5.0 1st Qu.: 5.00 1st Qu.: 0.000 1st Qu.: 5.00
#> Median : 10.0 Median : 10.00 Median : 2.000 Median : 9.00
#> Mean : 11.8 Mean : 11.87 Mean : 4.001 Mean : 11.68
#> 3rd Qu.: 12.0 3rd Qu.: 12.00 3rd Qu.: 6.000 3rd Qu.: 12.00
#> Max. :148.0 Max. :137.00 Max. :130.000 Max. :154.00
#>
#> ll_gw1 ll_gw2 ll_gw3 ll_grv
#> Min. : 1.00 Min. : 0.00 Min. : 1.00 Min. : 0.000
#> 1st Qu.: 11.00 1st Qu.: 11.00 1st Qu.: 11.00 1st Qu.: 1.000
#> Median : 12.00 Median : 12.00 Median : 12.00 Median : 5.000
#> Mean : 15.26 Mean : 15.88 Mean : 15.68 Mean : 7.795
#> 3rd Qu.: 13.00 3rd Qu.: 13.00 3rd Qu.: 13.00 3rd Qu.: 10.000
#> Max. :156.00 Max. :148.00 Max. :154.00 Max. :137.000
#>
#> ll_gab ll_gap ll_gtt bl_lender_type
#> Min. : 0.000 Min. : 2.00 Min. : 2.00 Mode :logical
#> 1st Qu.: 3.000 1st Qu.: 13.00 1st Qu.: 24.00 FALSE:54844
#> Median : 7.000 Median : 17.00 Median : 30.00 TRUE :40063
#> Mean : 8.081 Mean : 22.86 Mean : 38.74
#> 3rd Qu.: 11.000 3rd Qu.: 24.00 3rd Qu.: 43.00
#> Max. :133.000 Max. :159.00 Max. :159.00
#>
#> bl_bridge_informal bl_loan_size bl_loan_dura_a bl_loan_dura_b
#> Mode :logical Mode :logical Mode :logical Mode :logical
#> FALSE:82316 FALSE:54653 FALSE:74409 FALSE:34986
#> TRUE :12591 TRUE :40250 TRUE :20498 TRUE :59921
#> NAs :4
#>
#>
#>
#> bl_loan_dura_c
#> Mode :logical
#> FALSE:52791
#> TRUE :42116
#>
#>
#>
#>
#> ── Sample rows (first 6) ──
#>
#> # A tibble: 6 × 47
#> # Groups: br_type, br_type_id [6]
#> bridge_id br_type br_type_id hhid_Num hh_loan_id_nd_1t2 hh_loan_id_nd_paired…¹
#> <int> <chr> <int> <int> <int> <int>
#> 1 17748 NA 1 1031 27 28
#> 2 17751 NA 4 1113 106 108
#> 3 17749 NA 2 1113 88 91
#> 4 17750 NA 3 1113 89 91
#> 5 17752 NA 5 1119 114 115
#> 6 17753 NA 6 1119 115 117
#> # ℹ abbreviated name: ¹hh_loan_id_nd_paired_1t2
#> # ℹ 41 more variables: hh_loan_id_nd_paired_2t3 <int>, hh_br_la_n <int>,
#> # hh_br_lb_n <int>, hh_br_lc_n <int>, loan_start_1t2 <dbl>,
#> # loan_end_1t2 <dbl>, loan_start_paired_1t2 <dbl>, loan_end_paired_1t2 <dbl>,
#> # loan_start_paired_2t3 <dbl>, loan_end_paired_2t3 <dbl>, forinfm4_1t2 <chr>,
#> # forinfm4_paired_1t2 <chr>, forinfm4_paired_2t3 <chr>,
#> # loan_principal_1t2 <dbl>, loan_principal_paired_1t2 <dbl>, …
if (requireNamespace("dplyr", quietly = TRUE)) {
tb_tally <- tstm_loans_bridges_type |>
dplyr::distinct(br_type, br_type_id) |>
dplyr::group_by(br_type) |>
dplyr::summarize(br_type_n = dplyr::n(), .groups = "drop")
print(tb_tally)
}
#> # A tibble: 8 × 2
#> br_type br_type_n
#> <chr> <int>
#> 1 --- 736
#> 2 --= 1631
#> 3 -=- 1824
#> 4 -== 4125
#> 5 =-- 1566
#> 6 =-= 3490
#> 7 ==- 4375
#> 8 NA 2011