Invest-loan roster with hooks and bridges, distinct bridges
Source:R/data-res.R
tstm_roster_invest2loan2bridge.RdBuilding on tstm_roster_invest_loan_linked, for which each investment has multiple bridges, with overlapping
loan components, we now delete subsets of rows so that in remaining bridges, there are no
loan set A duplicates in set B, and there are no set C duplicates in set B.
Format
Invest-loan roster with hooks and distinct bridges:
- thres_inv_mgap
Month gap allowed to merge investment jump together as one investment
- thres_inv_dfds
Standard deviation threshold for counting investment jump
- hhid_Num
household id
- ivars
Capital-asset variable for finding investment jumps
- hh_inv_asset_ctr
Unique household + capital-asset investment counter
- hh_inv_ctr
Unique household investment span counter across
ivars- mth_inv_start
Start time of investment span
- mth_inv_end
End time of investment span
- capital_prior
Capital-asset level prior to investment
- capital_end
Capital-asset level after investment
- capital_invest
Level of investment, difference of end and prior
- hh_loan_id_nd
Non-duplicate loan id, sequential for all loans
- loan_start
Loan start month
- loan_end
Loan end month
- number_indi_loan
Number of individual loans combined to generate a non-duplicate loan
- forinfm4
Name of categorical variable defining loan group types
- loan_principal_interest
Loan principal and interests aggregating over individual loans with the same dates and lender type
- loan_principal
loan_principal_interestbut without interests- loan_principal_last
Last month of principal repayment in loan panel
- loan_interest_monthly
monthly interest rate given aggregated interests and principals, monthly compounding rate (see Issue-24)
- merge_type
string equalling to
invest2loanorloan2invest.invest2loanbased on invest file left-joined by loan file.loan2investis non-duplicate loan file left-joined by investment file. The file stacks results from both types of files. Stacking is possible due to the datasets sharing subsets of variable names.- 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
- 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_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_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_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_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_gw1
GW1: loan A gap between end and start
- ll_gw2
GW2: loan B gap between end and start
- ll_gw3
GW3: loan C gap between end and start
- 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))- bl_m1t2_formal
If a set A loan is formal:
if_else(forinfm4 %in% c("BAAC-Commercial", "Village-Fund"), TRUE, FALSE))- bl_p1t2_formal
If a set B loan is formal:
if_else(forinfm4_paired_1t2 %in% c("BAAC-Commercial", "Village-Fund"), TRUE, FALSE))- bl_p2t3_formal
If a set C loan is formal:
if_else(forinfm4_paired_2t3 %in% c("BAAC-Commercial", "Village-Fund"), TRUE, FALSE))- bl_m1t2_formal_avg
Average formal boolean for set A loans:
bl_m1t2_formal_avg = mean(bl_m1t2_formal, na.rm = T)- bl_p1t2_formal_avg
Average formal boolean for set B loans:
bl_p1t2_formal_avg = mean(bl_p1t2_formal, na.rm = T)- bl_p2t3_formal_avg
Average formal boolean for set C loans:
bl_p2t3_formal_avg = mean(bl_p2t3_formal, na.rm = T)- bl_jnt_m1t2_p1t2_formal
If both hooked set A and set B loans formal:
bl_jnt_m1t2_p1t2_formal = if_else(bl_m1t2_formal & bl_p1t2_formal, TRUE, FALSE)- bl_jnt_p1t2_p2t3_formal
If both hooked set B and set C loans formal:
bl_jnt_p1t2_p2t3_formal = if_else(bl_p1t2_formal & bl_p2t3_formal, TRUE, FALSE)- bl_jnt_m1t2_p1t2_informal
If both hooked set A and set B loans not formal:
bl_jnt_m1t2_p1t2_informal = if_else(!bl_m1t2_formal & !bl_p1t2_formal, TRUE, FALSE)- bl_jnt_p1t2_p2t3_informal
If both hooked set B and set C loans not formal:
bl_jnt_p1t2_p2t3_informal = if_else(!bl_p1t2_formal & !bl_p2t3_formal, TRUE, FALSE)- bl_jnt_m1t2_p1t2_same
If both hooked set A and set B loans from same lender group:
bl_jnt_m1t2_p1t2_same = if_else(forinfm4 == forinfm4_paired_1t2, TRUE, FALSE)- bl_jnt_p1t2_p2t3_same
If both hooked set B and set C loans from same lender group:
bl_jnt_p1t2_p2t3_same = if_else(forinfm4_paired_1t2 == forinfm4_paired_2t3, TRUE, FALSE)- bl_jnt_m1t2_p1t2_formal_avg
Average formal only boolean for hooked set A and B loans:
bl_jnt_m1t2_p1t2_formal_avg = mean(bl_jnt_m1t2_p1t2_formal, na.rm = T)- bl_jnt_p1t2_p2t3_formal_avg
Average formal only boolean for hooked set B and C loans:
bl_jnt_p1t2_p2t3_formal_avg = mean(bl_jnt_p1t2_p2t3_formal, na.rm = T)- bl_jnt_m1t2_p1t2_informal_avg
Average informal only boolean for hooked set A and B loans:
bl_jnt_m1t2_p1t2_informal_avg = mean(bl_jnt_m1t2_p1t2_informal, na.rm = T)- bl_jnt_p1t2_p2t3_informal_avg
Average informal only boolean for hooked set B and C loans:
bl_jnt_p1t2_p2t3_informal_avg = mean(bl_jnt_p1t2_p2t3_informal, na.rm = T)- bl_jnt_m1t2_p1t2_same_avg
Average same lender group boolean for hooked set A and B loans:
bl_jnt_m1t2_p1t2_same_avg = mean(bl_jnt_m1t2_p1t2_same, na.rm = T)- bl_jnt_p1t2_p2t3_same_avg
Average same lender group boolean for hooked set B and C loans:
bl_jnt_p1t2_p2t3_same_avg = mean(bl_jnt_p1t2_p2t3_same, na.rm = T)- bl_bri_only_baac
All loans in bridge from BAAC or commercial banks:
if_else((forinfm4 == "BAAC-Commercial") & (forinfm4_paired_1t2 == "BAAC-Commercial") & (forinfm4_paired_2t3 == "BAAC-Commercial"), TRUE, FALSE)- bl_bri_only_vilfund
All loans in bridge from Village Fund:
if_else((forinfm4 == "Village-Fund") & (forinfm4_paired_1t2 == "Village-Fund") & (forinfm4_paired_2t3 == "Village-Fund"), TRUE, FALSE)- bl_bri_only_quasi
All loans in bridge from Quasi-formal sources:
if_else((forinfm4 == "Quasi-formal") & (forinfm4_paired_1t2 == "Quasi-formal") & (forinfm4_paired_2t3 == "Quasi-formal"), TRUE, FALSE)- bl_bri_only_informal
All loans in bridge from informal sources:
if_else((forinfm4 == "Informal") & (forinfm4_paired_1t2 == "Informal") & (forinfm4_paired_2t3 == "Informal"), TRUE, FALSE)- bl_bri_has_baac
At least one loan in bridge from BAAC or commercial banks:
if_else((forinfm4 == "BAAC-Commercial") | (forinfm4_paired_1t2 == "BAAC-Commercial") | (forinfm4_paired_2t3 == "BAAC-Commercial"), TRUE, FALSE)- bl_bri_has_vilfund
At least one loan in bridge from Village Fund:
if_else((forinfm4 == "Village-Fund") | (forinfm4_paired_1t2 == "Village-Fund") | (forinfm4_paired_2t3 == "Village-Fund"), TRUE, FALSE)- bl_bri_has_quasi
At least one loan in bridge from Quasi-formal sources:
if_else((forinfm4 == "Quasi-formal") | (forinfm4_paired_1t2 == "Quasi-formal") | (forinfm4_paired_2t3 == "Quasi-formal"), TRUE, FALSE)- bl_bri_has_informal
At least one loan in bridge from informal sources:
if_else((forinfm4 == "Informal") | (forinfm4_paired_1t2 == "Informal") | (forinfm4_paired_2t3 == "Informal"), TRUE, FALSE)- bl_bri_only_baac_mean
All loans in bridge from BAAC or commercial banks for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bri_only_baac_mean = mean(bl_bri_only_baac, na.rm = T))- bl_bri_has_baac_mean
At least one loan in bridge from BAAC or commercial banks for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bri_has_baac_mean = mean(bl_bri_has_baac, na.rm = T))- bl_bri_only_vilfund_mean
All loans in bridge from Village Fund for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bri_only_vilfund_mean = mean(bl_bri_only_vilfund, na.rm = T))- bl_bri_has_vilfund_mean
At least one loan in bridge from Village Fund for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bri_has_vilfund_mean = mean(bl_bri_has_vilfund, na.rm = T))- bl_bri_only_quasi_mean
All loans in bridge from Quasi-formal sources for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bri_only_quasi_mean = mean(bl_bri_only_quasi, na.rm = T))- bl_bri_has_quasi_mean
At least one loan in bridge from Quasi-formal sources for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bri_has_quasi_mean = mean(bl_bri_has_quasi, na.rm = T))- bl_bri_only_informal_mean
All loans in bridge from informal sources for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bri_only_informal_mean = mean(bl_bri_only_informal, na.rm = T))- bl_bri_has_informal_mean
At least one loan in bridge from informal sources for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bri_has_informal_mean = mean(bl_bri_has_informal, na.rm = T))- bl_bridge_informal_mean
Lender type informal as middle (component B) bridge component, with formal lender as component A and C of bridge for all bridges within hh-investment group:
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(bl_bridge_informal_mean = mean(bl_bridge_informal, na.rm = T)- ll_gw1
GW1: loan A gap between end and start
- ll_gw2
GW2: loan B gap between end and start
- ll_gw3
GW3: loan C gap between end and start
- hlin_m12_avg
Average of non-duplicate loan id sequential for all loans across all set A loans for investment k hh j. If this average is NA, that means there are no loans in set A for inv=k, hh=j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(hlin_m12_avg = mean(hh_loan_id_nd, na.rm = TRUE))- hlin_p12_avg
Average of non-duplicate loan id sequential for all loans across all set B loans for investment k hh j. If this average is NA, that means there are no loans in set B for inv=k, hh=j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(hlin_p12_avg = mean(hh_loan_id_nd_paired_1t2, na.rm = TRUE))- hlin_p23_avg
Average of non-duplicate loan id sequential for all loans across all set C loans for investment k hh j. If this average is NA, that means there are no loans in set C for inv=k, hh=j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(hlin_p23_avg = mean(hh_loan_id_nd_paired_2t3, na.rm = TRUE))- loan_start_min
Min of loan start time among set A loans for investment k hh j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(loan_start_min = min(loan_start, na.rm = T))- loan_start_paired_1t2_min
Min of loan start time among set B loans for investment k hh j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(loan_start_paired_1t2_min = min(loan_start_paired_1t2, na.rm = T))- loan_start_paired_2t3_min
Min of loan start time among set C loans for investment k hh j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(loan_start_paired_2t3_min = min(loan_start_paired_2t3, na.rm = T))- loan_end_max
Max of loan end time among set A loans for investment k hh j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(loan_end_max = max(loan_end, na.rm = T))- loan_end_paired_1t2_max
Max of loan end time among set B loans for investment k hh j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(loan_end_paired_1t2_max = max(loan_end_paired_1t2, na.rm = T))- loan_end_paired_2t3_max
Max of loan end time among set C loans for investment k hh j.
group_by(hhid_Num, ivars, hh_inv_asset_ctr) %>% mutate(loan_end_paired_2t3_max = max(loan_end_paired_2t3, na.rm = T))- il1_lgt
Define loan set A, contains informal only, formal only, or joint informal and formal.
mutate(il1_lgt = case_when(bl_m1t2_formal_avg == 0 ~ "s-inf", bl_m1t2_formal_avg == 1 ~ "s-for", (bl_m1t2_formal_avg > 0 & bl_m1t2_formal_avg < 1) ~ "s-fij", TRUE ~ NA))- il2_lgt
Define loan set B, contains informal only, formal only, or joint informal and formal.
mutate(il2_lgt = case_when(bl_p1t2_formal_avg == 0 ~ "s-inf", bl_p1t2_formal_avg == 1 ~ "s-for", (bl_p1t2_formal_avg > 0 & bl_p1t2_formal_avg < 1) ~ "s-fij", TRUE ~ NA))- il3_lgt
Define loan set C, contains informal only, formal only, or joint informal and formal.
mutate(il3_lgt = case_when(bl_p2t3_formal_avg == 0 ~ "s-inf", bl_p2t3_formal_avg == 1 ~ "s-for", (bl_p2t3_formal_avg > 0 & bl_p2t3_formal_avg < 1) ~ "s-fij", TRUE ~ NA))- ih1_lgt
Define loan set A + B joint structure, contains informal only, formal only, or joint informal and formal in A and B, or combinations of formal and informal in A and B.
mutate(ih1_lgt = case_when(bl_jnt_m1t2_p1t2_informal_avg == 1 ~ "h-inf", bl_jnt_m1t2_p1t2_formal_avg == 1 ~ "h-for", (bl_jnt_m1t2_p1t2_informal_avg == 0 & bl_jnt_m1t2_p1t2_formal_avg == 0) ~ "h-fij", ((bl_jnt_m1t2_p1t2_informal_avg > 0 & bl_jnt_m1t2_p1t2_informal_avg < 1) | (bl_jnt_m1t2_p1t2_formal_avg > 0 & bl_jnt_m1t2_p1t2_formal_avg < 1)) ~ "h-mfij", TRUE ~ NA))- ih2_lgt
Define loan set B +CB joint structure, contains informal only, formal only, or joint informal and formal in B and C, or combinations of formal and informal in B and C.
mutate(ih2_lgt = case_when(bl_jnt_p1t2_p2t3_informal_avg == 1 ~ "h-inf", bl_jnt_p1t2_p2t3_formal_avg == 1 ~ "h-for", (bl_jnt_p1t2_p2t3_informal_avg == 0 & bl_jnt_p1t2_p2t3_formal_avg == 0) ~ "h-fij", ((bl_jnt_p1t2_p2t3_informal_avg > 0 & bl_jnt_p1t2_p2t3_informal_avg < 1) | (bl_jnt_p1t2_p2t3_formal_avg > 0 & bl_jnt_p1t2_p2t3_formal_avg < 1)) ~ "h-mfij", TRUE ~ NA))- bl_ibr_single
BRIDGE-CATEGORY: Key bridge labeling variable, all components of A, B, and C elements of bridge from a single lender, boolean:
mutate(bl_ibr_single = case_when((bl_bri_only_baac_mean == 1) | (bl_bri_only_vilfund_mean == 1) | (bl_bri_only_quasi_mean == 1) | (bl_bri_only_informal_mean == 1) ~ TRUE, TRUE ~ FALSE))- st_ibr_single
BRIDGE-CATEGORY: Key bridge labeling variable, all components of A, B, and C elements of bridge from a single lender, string which lender:
mutate(st_ibr_single = case_when(bl_bri_only_baac_mean == 1 ~ "BAAC-Commercial", bl_bri_only_vilfund_mean == 1 ~ "Village-Fund", bl_bri_only_quasi_mean == 1 ~ "Quasi-formal", bl_bri_only_informal_mean == 1 ~ "Informal", TRUE ~ NA))- st_ibr_joint
BRIDGE-CATEGORY: Key bridge labeling variable, bridge structure from multiple lenders, formal lenders only, informal lenders only, formal and informal jointly, etc.
mutate(st_ibr_joint = case_when((bl_bri_has_baac_mean > 0) & (bl_bri_has_vilfund_mean > 0) & (bl_bri_has_quasi_mean == 0) & (bl_bri_has_informal_mean == 0) ~ "BAACComm-VilFund", (bl_bri_has_baac_mean == 0) & (bl_bri_has_vilfund_mean == 0) & (bl_bri_has_quasi_mean > 0) & (bl_bri_has_informal_mean > 0) ~ "Informal-Quasiformal", ((bl_bri_has_baac_mean > 0) | (bl_bri_has_vilfund_mean > 0)) & ((bl_bri_has_quasi_mean == 0) & (bl_bri_has_informal_mean > 0)) ~ "BAACorVilFUnd-Informal", ((bl_bri_has_baac_mean > 0) | (bl_bri_has_vilfund_mean > 0)) & ((bl_bri_has_quasi_mean > 0) & (bl_bri_has_informal_mean == 0)) ~ "BAACorVilFUnd-Qusiformal", ((bl_bri_has_baac_mean > 0) | (bl_bri_has_vilfund_mean > 0)) & ((bl_bri_has_quasi_mean > 0) & (bl_bri_has_informal_mean > 0)) ~ "BAACorVilFUnd-InfAndQuasiFor", ((bl_bri_has_baac_mean > 0) | (bl_bri_has_vilfund_mean > 0) | (bl_bri_has_quasi_mean > 0) | (bl_bri_has_informal_mean > 0)) ~ "Other-combo", TRUE ~ NA))- st_ibr_has_informal_bridge
BRIDGE-CATEGORY: Key bridge labeling variable, formal and informal joint bridge, if there is a linkage between one A, one B, and one C loans that contains informal in the middle B component, or informal anywhere:
mutate(st_ibr_has_informal_bridge = case_when(bl_bridge_informal_mean > 0 ~ "has-informal-bridge", ((bl_bri_has_quasi_mean > 0) | (bl_bri_has_informal_mean > 0)) ~ "has-informal-in-bridge", st_ibr_joint == "Informal-Quasiformal" ~ NA, TRUE ~ NA))
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).
Household IDs are anonymized tmid_hh (id or hhid_Num), aligned with tstm_asset_loan.
Three paper asset ivars only; hh_inv_ctr spans kept ivars (gateway early filter).
See also issue-22, step 3.
Downstream vignettes: consumed by ffv_bridge_timing for bridge-segment
timing figures (issue
#34).
Details
We create also various categories characterizing bridge loan formal and informal joint structures.
Examples
data(tstm_roster_invest2loan2bridge)
ffp_preview_dataset(tstm_roster_invest2loan2bridge)
#>
#> ── tstm_roster_invest2loan2bridge ──────────────────────────────────────────────
#> Dimensions: 10449 rows × 91 columns(6.4 Mb)
#>
#> ── Column names (91) ──
#>
#> • 1. hhid_Num
#> • 2. ivars
#> • 3. hh_inv_asset_ctr
#> • 4. forinfm4
#> • 5. hh_loan_id_nd
#> • 6. forinfm4_paired_1t2
#> • 7. hh_loan_id_nd_paired_1t2
#> • 8. forinfm4_paired_2t3
#> • 9. hh_loan_id_nd_paired_2t3
#> • 10. mth_inv_start
#> • 11. mth_inv_end
#> • 12. loan_start
#> • 13. loan_end
#> • 14. loan_start_paired_1t2
#> • 15. loan_end_paired_1t2
#> • 16. loan_start_paired_2t3
#> • 17. loan_end_paired_2t3
#> • 18. capital_prior
#> • 19. capital_end
#> • 20. capital_invest
#> • 21. loan_principal
#> • 22. loan_principal_last
#> • 23. loan_interest_monthly
#> • 24. loan_principal_paired_1t2
#> • 25. loan_principal_last_paired_1t2
#> • 26. loan_interest_monthly_paired_1t2
#> • 27. loan_principal_paired_2t3
#> • 28. loan_principal_last_paired_2t3
#> • 29. loan_interest_monthly_paired_2t3
#> • 30. bl_lender_type
#> • 31. bl_bridge_informal
#> • 32. bl_loan_size
#> • 33. bl_loan_dura_a
#> • 34. bl_loan_dura_b
#> • 35. bl_loan_dura_c
#> • 36. bl_m1t2_formal
#> • 37. bl_p1t2_formal
#> • 38. bl_p2t3_formal
#> • 39. bl_m1t2_formal_avg
#> • 40. bl_p1t2_formal_avg
#> • 41. bl_p2t3_formal_avg
#> • 42. bl_jnt_m1t2_p1t2_formal
#> • 43. bl_jnt_p1t2_p2t3_formal
#> • 44. bl_jnt_m1t2_p1t2_informal
#> • 45. bl_jnt_p1t2_p2t3_informal
#> • 46. bl_jnt_m1t2_p1t2_same
#> • 47. bl_jnt_p1t2_p2t3_same
#> • 48. bl_jnt_m1t2_p1t2_formal_avg
#> • 49. bl_jnt_p1t2_p2t3_formal_avg
#> • 50. bl_jnt_m1t2_p1t2_informal_avg
#> • 51. bl_jnt_p1t2_p2t3_informal_avg
#> • 52. bl_jnt_m1t2_p1t2_same_avg
#> • 53. bl_jnt_p1t2_p2t3_same_avg
#> • 54. bl_bri_only_baac
#> • 55. bl_bri_only_vilfund
#> • 56. bl_bri_only_quasi
#> • 57. bl_bri_only_informal
#> • 58. bl_bri_has_baac
#> • 59. bl_bri_has_vilfund
#> • 60. bl_bri_has_quasi
#> • 61. bl_bri_has_informal
#> • 62. bl_bri_only_baac_mean
#> • 63. bl_bri_has_baac_mean
#> • 64. bl_bri_only_vilfund_mean
#> • 65. bl_bri_has_vilfund_mean
#> • 66. bl_bri_only_quasi_mean
#> • 67. bl_bri_has_quasi_mean
#> • 68. bl_bri_only_informal_mean
#> • 69. bl_bri_has_informal_mean
#> • 70. bl_bridge_informal_mean
#> • 71. bl_ibr_single
#> • 72. ll_gw1
#> • 73. ll_gw2
#> • 74. ll_gw3
#> • 75. hlin_m12_avg
#> • 76. hlin_p12_avg
#> • 77. hlin_p23_avg
#> • 78. loan_start_min
#> • 79. loan_start_paired_1t2_min
#> • 80. loan_start_paired_2t3_min
#> • 81. loan_end_max
#> • 82. loan_end_paired_1t2_max
#> • 83. loan_end_paired_2t3_max
#> • 84. il1_lgt
#> • 85. il2_lgt
#> • 86. il3_lgt
#> • 87. ih1_lgt
#> • 88. ih2_lgt
#> • 89. st_ibr_single
#> • 90. st_ibr_joint
#> • 91. st_ibr_has_informal_bridge
#>
#> ── Summary statistics (all variables) ──
#>
#> hhid_Num ivars hh_inv_asset_ctr forinfm4
#> Min. :1031 Length :10449 Min. :1.000 Length :10449
#> 1st Qu.:3155 N.unique : 3 1st Qu.:1.000 N.unique : 4
#> Median :5601 N.blank : 0 Median :2.000 N.blank : 0
#> Mean :5531 Min.nchar: 11 Mean :2.088 Min.nchar: 8
#> 3rd Qu.:7705 Max.nchar: 11 3rd Qu.:3.000 Max.nchar: 15
#> Max. :9996 Max. :8.000 NAs : 874
#>
#> hh_loan_id_nd forinfm4_paired_1t2 hh_loan_id_nd_paired_1t2
#> Min. : 23 Length :10449 Min. : 24
#> 1st Qu.: 5076 N.unique : 4 1st Qu.: 5158
#> Median :10127 N.blank : 0 Median :10305
#> Mean :10016 Min.nchar: 8 Mean :10127
#> 3rd Qu.:14957 Max.nchar: 15 3rd Qu.:15170
#> Max. :19580 NAs : 2798 Max. :19581
#> NAs :874 NAs :2798
#> forinfm4_paired_2t3 hh_loan_id_nd_paired_2t3 mth_inv_start mth_inv_end
#> Length :10449 Min. : 25 Min. : 14.0 Min. : 14.00
#> N.unique : 4 1st Qu.: 5484 1st Qu.: 53.0 1st Qu.: 53.00
#> N.blank : 0 Median :10316 Median : 77.0 Median : 77.00
#> Min.nchar: 8 Mean :10238 Mean : 76.7 Mean : 76.78
#> Max.nchar: 15 3rd Qu.:15412 3rd Qu.: 98.0 3rd Qu.: 98.00
#> NAs : 3419 Max. :19582 Max. :144.0 Max. :144.00
#> NAs :3419
#> loan_start loan_end loan_start_paired_1t2 loan_end_paired_1t2
#> Min. : 8.00 Min. : 11.00 Min. : 11.00 Min. : 11.00
#> 1st Qu.: 50.00 1st Qu.: 66.00 1st Qu.: 62.00 1st Qu.: 73.00
#> Median : 74.00 Median : 89.00 Median : 82.00 Median : 95.00
#> Mean : 74.46 Mean : 90.49 Mean : 84.54 Mean : 96.25
#> 3rd Qu.: 95.00 3rd Qu.:113.00 3rd Qu.:106.00 3rd Qu.:119.00
#> Max. :144.00 Max. :160.00 Max. :160.00 Max. :160.00
#> NAs :874 NAs :874 NAs :1578 NAs :1578
#> loan_start_paired_2t3 loan_end_paired_2t3 capital_prior
#> Min. : 17.0 Min. : 19.0 Min. : 0
#> 1st Qu.: 71.0 1st Qu.: 83.0 1st Qu.: 51044
#> Median : 90.0 Median :103.0 Median : 228080
#> Mean : 92.3 Mean :104.3 Mean : 1026880
#> 3rd Qu.:113.0 3rd Qu.:126.0 3rd Qu.: 718439
#> Max. :159.0 Max. :160.0 Max. :141177726
#> NAs :2365 NAs :2365
#> capital_end capital_invest loan_principal loan_principal_last
#> Min. : 10000 Min. : 10000 Min. : 100 Min. : 0
#> 1st Qu.: 98282 1st Qu.: 24645 1st Qu.: 10000 1st Qu.: 4000
#> Median : 317238 Median : 47491 Median : 20000 Median : 15000
#> Mean : 1154101 Mean : 127221 Mean : 40305 Mean : 24175
#> 3rd Qu.: 861308 3rd Qu.: 112140 3rd Qu.: 38490 3rd Qu.: 25000
#> Max. :141635206 Max. :11555926 Max. :4100000 Max. :1600000
#> NAs :875 NAs :874
#> loan_interest_monthly loan_principal_paired_1t2 loan_principal_last_paired_1t2
#> Min. :-1.000000 Min. : 450 Min. : 0
#> 1st Qu.: 0.002466 1st Qu.: 5000 1st Qu.: 2500
#> Median : 0.004492 Median : 15000 Median : 11000
#> Mean :-0.004855 Mean : 25760 Mean : 21618
#> 3rd Qu.: 0.006293 3rd Qu.: 20000 3rd Qu.: 20000
#> Max. : 0.462500 Max. :2000000 Max. :2000000
#> NAs :875 NAs :1578 NAs :1578
#> loan_interest_monthly_paired_1t2 loan_principal_paired_2t3
#> Min. :-1.000000 Min. : 415
#> 1st Qu.: 0.003274 1st Qu.: 5730
#> Median : 0.004844 Median : 16500
#> Mean :-0.017256 Mean : 28050
#> 3rd Qu.: 0.006434 3rd Qu.: 29270
#> Max. : 0.391941 Max. :1600000
#> NAs :1578 NAs :2365
#> loan_principal_last_paired_2t3 loan_interest_monthly_paired_2t3
#> Min. : 0 Min. :-1.000000
#> 1st Qu.: 3000 1st Qu.: 0.003182
#> Median : 15000 Median : 0.004492
#> Mean : 23749 Mean :-0.037408
#> 3rd Qu.: 20000 3rd Qu.: 0.005938
#> Max. :1600000 Max. : 0.259921
#> NAs :2365 NAs :2365
#> bl_lender_type bl_bridge_informal bl_loan_size bl_loan_dura_a
#> Mode :logical Mode :logical Mode :logical Mode :logical
#> FALSE:4304 FALSE:7105 FALSE:4104 FALSE:6289
#> TRUE :4567 TRUE :1766 TRUE :4766 TRUE :2582
#> NAs :1578 NAs :1578 NAs :1579 NAs :1578
#>
#>
#>
#> bl_loan_dura_b bl_loan_dura_c bl_m1t2_formal bl_p1t2_formal
#> Mode :logical Mode :logical Mode :logical Mode :logical
#> FALSE:3426 FALSE:4477 FALSE:4928 FALSE:6405
#> TRUE :5445 TRUE :3607 TRUE :5521 TRUE :4044
#> NAs :1578 NAs :2365
#>
#>
#>
#> bl_p2t3_formal bl_m1t2_formal_avg bl_p1t2_formal_avg bl_p2t3_formal_avg
#> Mode :logical Min. :0.0000 Min. :0.0000 Min. :0.0000
#> FALSE:5908 1st Qu.:0.2000 1st Qu.:0.0000 1st Qu.:0.0000
#> TRUE :4541 Median :0.5556 Median :0.3333 Median :0.4667
#> Mean :0.5284 Mean :0.3870 Mean :0.4346
#> 3rd Qu.:0.8750 3rd Qu.:0.7500 3rd Qu.:0.6667
#> Max. :1.0000 Max. :1.0000 Max. :1.0000
#>
#> bl_jnt_m1t2_p1t2_formal bl_jnt_p1t2_p2t3_formal bl_jnt_m1t2_p1t2_informal
#> Mode :logical Mode :logical Mode :logical
#> FALSE:7997 FALSE:7939 FALSE:7113
#> TRUE :2452 TRUE :2510 TRUE :3336
#>
#>
#>
#>
#> bl_jnt_p1t2_p2t3_informal bl_jnt_m1t2_p1t2_same bl_jnt_p1t2_p2t3_same
#> Mode :logical Mode :logical Mode :logical
#> FALSE:6075 FALSE:5436 FALSE:4432
#> TRUE :4374 TRUE :2215 TRUE :2598
#> NAs :2798 NAs :3419
#>
#>
#>
#> bl_jnt_m1t2_p1t2_formal_avg bl_jnt_p1t2_p2t3_formal_avg
#> Min. :0.0000 Min. :0.0000
#> 1st Qu.:0.0000 1st Qu.:0.0000
#> Median :0.0000 Median :0.1250
#> Mean :0.2347 Mean :0.2402
#> 3rd Qu.:0.4286 3rd Qu.:0.4444
#> Max. :1.0000 Max. :1.0000
#>
#> bl_jnt_m1t2_p1t2_informal_avg bl_jnt_p1t2_p2t3_informal_avg
#> Min. :0.0000 Min. :0.0000
#> 1st Qu.:0.0000 1st Qu.:0.1000
#> Median :0.2000 Median :0.3333
#> Mean :0.3193 Mean :0.4186
#> 3rd Qu.:0.5000 3rd Qu.:0.7500
#> Max. :1.0000 Max. :1.0000
#>
#> bl_jnt_m1t2_p1t2_same_avg bl_jnt_p1t2_p2t3_same_avg bl_bri_only_baac
#> Min. :0.0000 Min. :0.0000 Mode :logical
#> 1st Qu.:0.0000 1st Qu.:0.2105 FALSE:9031
#> Median :0.2500 Median :0.3333 TRUE :102
#> Mean :0.3012 Mean :0.3744 NAs :1316
#> 3rd Qu.:0.5000 3rd Qu.:0.5000
#> Max. :1.0000 Max. :1.0000
#> NAs :1719 NAs :2275
#> bl_bri_only_vilfund bl_bri_only_quasi bl_bri_only_informal bl_bri_has_baac
#> Mode :logical Mode :logical Mode :logical Mode :logical
#> FALSE:8538 FALSE:8473 FALSE:9021 FALSE:3914
#> TRUE :591 TRUE :285 TRUE :72 TRUE :3729
#> NAs :1320 NAs :1691 NAs :1356 NAs :2806
#>
#>
#>
#> bl_bri_has_vilfund bl_bri_has_quasi bl_bri_has_informal bl_bri_only_baac_mean
#> Mode :logical Mode :logical Mode :logical Min. :0.00000
#> FALSE:1807 FALSE:2631 FALSE:5342 1st Qu.:0.00000
#> TRUE :5867 TRUE :5425 TRUE :2308 Median :0.00000
#> NAs :2775 NAs :2393 NAs :2799 Mean :0.01118
#> 3rd Qu.:0.00000
#> Max. :1.00000
#> NAs :966
#> bl_bri_has_baac_mean bl_bri_only_vilfund_mean bl_bri_has_vilfund_mean
#> Min. :0.0000 Min. :0.00000 Min. :0.0000
#> 1st Qu.:0.0000 1st Qu.:0.00000 1st Qu.:0.6500
#> Median :0.5385 Median :0.00000 Median :0.8500
#> Mean :0.4885 Mean :0.06663 Mean :0.7724
#> 3rd Qu.:0.8000 3rd Qu.:0.05556 3rd Qu.:1.0000
#> Max. :1.0000 Max. :1.00000 Max. :1.0000
#> NAs :1624 NAs :977 NAs :1628
#> bl_bri_only_quasi_mean bl_bri_has_quasi_mean bl_bri_only_informal_mean
#> Min. :0.00000 Min. :0.0000 Min. :0.000000
#> 1st Qu.:0.00000 1st Qu.:0.5000 1st Qu.:0.000000
#> Median :0.00000 Median :0.7143 Median :0.000000
#> Mean :0.03244 Mean :0.6785 Mean :0.007706
#> 3rd Qu.:0.00000 3rd Qu.:1.0000 3rd Qu.:0.000000
#> Max. :1.00000 Max. :1.0000 Max. :1.000000
#> NAs :1107 NAs :1366 NAs :961
#> bl_bri_has_informal_mean bl_bridge_informal_mean bl_ibr_single
#> Min. :0.0000 Min. :0.0000 Mode :logical
#> 1st Qu.:0.0000 1st Qu.:0.0000 FALSE:10261
#> Median :0.1818 Median :0.1111 TRUE :188
#> Mean :0.3101 Mean :0.2010
#> 3rd Qu.:0.5333 3rd Qu.:0.3333
#> Max. :1.0000 Max. :1.0000
#> NAs :1814 NAs :1177
#> ll_gw1 ll_gw2 ll_gw3 hlin_m12_avg
#> Min. : 0.00 Min. : 0.00 Min. : 1.00 Min. : 23
#> 1st Qu.:11.00 1st Qu.:10.00 1st Qu.:11.00 1st Qu.: 5078
#> Median :12.00 Median :12.00 Median :12.00 Median :10128
#> Mean :13.75 Mean :11.72 Mean :12.02 Mean :10016
#> 3rd Qu.:13.00 3rd Qu.:12.00 3rd Qu.:12.00 3rd Qu.:14956
#> Max. :48.00 Max. :48.00 Max. :48.00 Max. :19580
#> NAs :1578 NAs :1578 NAs :2365 NAs :874
#> hlin_p12_avg hlin_p23_avg loan_start_min loan_start_paired_1t2_min
#> Min. : 24 Min. : 25 Min. : 8.00 Min. : 11.00
#> 1st Qu.: 5118 1st Qu.: 5172 1st Qu.: 50.00 1st Qu.: 56.00
#> Median :10126 Median :10130 Median : 72.00 Median : 79.00
#> Mean :10054 Mean :10103 Mean : 73.08 Mean : 79.53
#> 3rd Qu.:15066 3rd Qu.:15118 3rd Qu.: 94.00 3rd Qu.:100.00
#> Max. :19581 Max. :19582 Max. :144.00 Max. :158.00
#> NAs :1719 NAs :2275 NAs :874 NAs :1177
#> loan_start_paired_2t3_min loan_end_max loan_end_paired_1t2_max
#> Min. : 17.00 Min. : 16.0 Min. : 18.0
#> 1st Qu.: 64.00 1st Qu.: 76.0 1st Qu.: 77.0
#> Median : 85.00 Median :101.0 Median :101.0
#> Mean : 86.77 Mean :103.7 Mean :101.5
#> 3rd Qu.:106.00 3rd Qu.:136.0 3rd Qu.:125.0
#> Max. :159.00 Max. :160.0 Max. :160.0
#> NAs :1637 NAs :874 NAs :1177
#> loan_end_paired_2t3_max il1_lgt il2_lgt il3_lgt
#> Min. : 19.0 Length :10449 Length :10449 Length :10449
#> 1st Qu.: 90.0 N.unique : 3 N.unique : 3 N.unique : 3
#> Median :113.0 N.blank : 0 N.blank : 0 N.blank : 0
#> Mean :112.5 Min.nchar: 5 Min.nchar: 5 Min.nchar: 5
#> 3rd Qu.:136.0 Max.nchar: 5 Max.nchar: 5 Max.nchar: 5
#> Max. :160.0
#> NAs :1637
#> ih1_lgt ih2_lgt st_ibr_single st_ibr_joint
#> Length :10449 Length :10449 Length :10449 Length :10449
#> N.unique : 4 N.unique : 4 N.unique : 4 N.unique : 6
#> N.blank : 0 N.blank : 0 N.blank : 0 N.blank : 0
#> Min.nchar: 5 Min.nchar: 5 Min.nchar: 8 Min.nchar: 11
#> Max.nchar: 6 Max.nchar: 6 Max.nchar: 15 Max.nchar: 28
#> NAs :10261 NAs : 874
#>
#> st_ibr_has_informal_bridge
#> Length :10449
#> N.unique : 2
#> N.blank : 0
#> Min.nchar: 19
#> Max.nchar: 22
#> NAs : 1594
#>
#> ── Sample rows (first 6) ──
#>
#> # A tibble: 6 × 91
#> # Groups: hhid_Num, ivars, hh_inv_asset_ctr [5]
#> hhid_Num ivars hh_inv_asset_ctr forinfm4 hh_loan_id_nd forinfm4_paired_1t2
#> <int> <chr> <int> <chr> <int> <chr>
#> 1 1031 agg_BS_1… 2 Quasi-f… 23 Quasi-formal
#> 2 1078 agg_BS_1… 1 Quasi-f… 40 NA
#> 3 1078 agg_BS_1… 1 Quasi-f… 40 NA
#> 4 1099 agg_BS_1… 1 Quasi-f… 75 NA
#> 5 1099 agg_BS_1… 2 Quasi-f… 75 NA
#> 6 1099 agg_BS_1… 2 Village… 76 NA
#> # ℹ 85 more variables: hh_loan_id_nd_paired_1t2 <int>,
#> # forinfm4_paired_2t3 <chr>, hh_loan_id_nd_paired_2t3 <int>,
#> # mth_inv_start <dbl>, mth_inv_end <dbl>, loan_start <dbl>, loan_end <dbl>,
#> # loan_start_paired_1t2 <dbl>, loan_end_paired_1t2 <dbl>,
#> # loan_start_paired_2t3 <dbl>, loan_end_paired_2t3 <dbl>,
#> # capital_prior <dbl>, capital_end <dbl>, capital_invest <dbl>,
#> # loan_principal <dbl>, loan_principal_last <dbl>, …
if (requireNamespace("dplyr", quietly = TRUE)) {
print(tstm_roster_invest2loan2bridge |>
dplyr::count(st_ibr_joint, sort = TRUE))
}
#> # A tibble: 2,990 × 5
#> # Groups: hhid_Num, ivars, hh_inv_asset_ctr [2,990]
#> hhid_Num ivars hh_inv_asset_ctr st_ibr_joint n
#> <int> <chr> <int> <chr> <int>
#> 1 5117 agg_BS_1011 1 BAACorVilFUnd-InfAndQuasiFor 60
#> 2 9422 agg_BS_1011 3 BAACorVilFUnd-InfAndQuasiFor 51
#> 3 9422 agg_BS_1012 3 BAACorVilFUnd-InfAndQuasiFor 51
#> 4 9422 agg_BS_1021 3 BAACorVilFUnd-InfAndQuasiFor 51
#> 5 8422 agg_BS_1011 1 BAACorVilFUnd-InfAndQuasiFor 44
#> 6 1435 agg_BS_1011 2 BAACorVilFUnd-InfAndQuasiFor 32
#> 7 4256 agg_BS_1011 5 BAACorVilFUnd-InfAndQuasiFor 32
#> 8 4256 agg_BS_1012 3 BAACorVilFUnd-InfAndQuasiFor 32
#> 9 4256 agg_BS_1021 3 BAACorVilFUnd-InfAndQuasiFor 32
#> 10 8459 agg_BS_1011 2 BAACorVilFUnd-InfAndQuasiFor 31
#> # ℹ 2,980 more rows