This function bridges loans from hook data by merging loan attributes and computing various statistics.
Usage
ffp_hfid_bridge_from_hook(
df_loans_pn_nd,
df_loans_hooks,
svr_lender_var = "forinfm4",
bl_filter_bridge_grvgr0 = TRUE,
it_ll_grv_min = -1,
bl_filter_loan_duration_a = FALSE,
bl_filter_loan_duration_b = FALSE,
bl_filter_lender_type = FALSE,
bl_filter_bridge_informal = FALSE,
bl_filter_loan_size = FALSE,
bl_filter_loan_duration_more = FALSE,
verbose = FALSE,
verbose_detail = FALSE,
it_verbose_detail_nrow = 100
)
Arguments
- df_loans_pn_nd
Data frame containing loan attributes for main loans
- df_loans_hooks
Data frame containing hook data
- svr_lender_var
Name of the variable indicating lender type in the loan attributes data frame
- bl_filter_bridge_grvgr0
Logical indicating whether to filter out non-bridge loans based on GRV > 0 condition
- it_ll_grv_min
Minimum value of GRV for a loan to be considered a bridge loan
- bl_filter_loan_duration_a
Logical indicating whether to filter out non-bridge loans based on duration condition a
- bl_filter_loan_duration_b
Logical indicating whether to filter out non-bridge loans based on duration condition b
- bl_filter_lender_type
Logical indicating whether to filter out non-bridge loans based on lender type condition
- bl_filter_bridge_informal
Logical indicating whether to filter out non-bridge loans based on informal bridge condition
- bl_filter_loan_size
Logical indicating whether to filter out non-bridge loans based on loan size condition
- bl_filter_loan_duration_more
Logical indicating whether to filter out non-bridge loans based on additional duration condition
- verbose
Logical indicating whether to print verbose output
- verbose_detail
Logical indicating whether to print detailed verbose output
- it_verbose_detail_nrow
Number of rows to print for detailed verbose output
Author
Fan Wang, http://fanwangecon.github.io
Examples
df_loans_pn_nd <- PrjThaiHFID::tstm_loans_pn_nd
ls_return <- ffp_hfid_hook_pairs(df_loans_pn_nd)
df_loans_hooks <- ls_return$tstm_loans_hooks
ffp_hfid_bridge_from_hook(df_loans_pn_nd, df_loans_hooks)
#> $tstm_loans_bridges_1t2
#> # A tibble: 47,754 × 23
#> hhid_Num hh_loan_id_nd_1t2 hh_loan_id_nd_paired…¹ loan_start_1t2 loan_end_1t2
#> <dbl> <int> <int> <dbl> <dbl>
#> 1 70203 3 4 39 51
#> 2 70203 4 5 51 65
#> 3 70203 4 6 51 65
#> 4 70203 4 7 51 65
#> 5 70203 5 6 64 65
#> 6 70203 5 7 64 65
#> 7 70203 6 7 64 67
#> 8 70203 7 8 65 74
#> 9 70203 7 9 65 74
#> 10 70203 8 9 74 78
#> # ℹ 47,744 more rows
#> # ℹ abbreviated name: ¹hh_loan_id_nd_paired_1t2
#> # ℹ 18 more variables: loan_start_paired_1t2 <dbl>, loan_end_paired_1t2 <dbl>,
#> # forinfm4_1t2 <chr>, forinfm4_paired_1t2 <chr>, loan_principal_1t2 <dbl>,
#> # loan_principal_paired_1t2 <dbl>, loan_interest_monthly_1t2 <dbl>,
#> # loan_interest_monthly_paired_1t2 <dbl>, ll_g12l <dbl>, ll_g12m <dbl>,
#> # ll_g12r <dbl>, ll_gw1 <dbl>, ll_gw2 <dbl>, bl_lender_type <lgl>, …
#>
#> $tstm_loans_bridges
#> # A tibble: 131,071 × 38
#> hhid_Num hh_loan_id_nd_1t2 hh_loan_id_nd_paired_1t2 hh_loan_id_nd_paired_2t3
#> <dbl> <int> <int> <int>
#> 1 70203 3 4 5
#> 2 70203 3 4 6
#> 3 70203 3 4 7
#> 4 70203 4 5 6
#> 5 70203 4 5 7
#> 6 70203 4 6 7
#> 7 70203 4 7 8
#> 8 70203 4 7 9
#> 9 70203 5 6 7
#> 10 70203 5 7 8
#> # ℹ 131,061 more rows
#> # ℹ 34 more variables: 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>,
#> # loan_principal_paired_2t3 <dbl>, loan_interest_monthly_1t2 <dbl>, …
#>