Combine investment data from jump and dura files, final investment file
Source:R/ffp_invest.R
ffp_hfid_invest_combine.Rd
This function combines investment data from two data frames: df_invest_ivar_jump
and df_invest_ivar_dura
.
It performs several steps to merge the data frames and calculate the difference between the last month's investment and the prior month's investment.
Usage
ffp_hfid_invest_combine(
df_invest_ivar_jump,
df_invest_ivar_dura,
verbose = FALSE,
verbose_detail = FALSE,
it_verbose_detail_nrow = 100
)
Arguments
- df_invest_ivar_jump
A data frame containing investment data for each household, time period, and investment variable, when investment jumps
- df_invest_ivar_dura
A data frame containing investment data for each household, time period, and investment variable, start and end months for each
- verbose
A logical value indicating whether to print verbose output. Default is FALSE.
- verbose_detail
A logical value indicating whether to print detailed verbose output. Default is FALSE.
- it_verbose_detail_nrow
An integer specifying the number of rows to print when verbose_detail is TRUE. Default is 100.
Value
A data frame with the combined investment data, including the difference between the last month's investment and the prior month's investment.
Author
Fan Wang, http://fanwangecon.github.io
Examples
df <- tstm_asset_loan
fl_sd_ithres <- stats::qnorm(0.99)
it_thres_invest_mth_gap <- 2
df_invest_ivar_jump <- ffp_hfid_invest_jump(df, fl_sd_ithres = fl_sd_ithres)
ls_return <- ffp_hfid_invest_unique_dura(
df_invest_ivar_jump, it_thres_invest_mth_gap = it_thres_invest_mth_gap
)
df_invest_ivar_dura <- ls_return$tstm_invest_ivar_dura
ffp_hfid_invest_combine(df_invest_ivar_jump, df_invest_ivar_dura)
#> # A tibble: 8,414 × 11
#> thres_inv_mgap thres_inv_dfsd id ivars hh_inv_asset_ctr hh_inv_ctr
#> <dbl> <dbl> <dbl> <chr> <int> <int>
#> 1 2 2.33 70201 agg_BS_1011 1 1
#> 2 2 2.33 70201 agg_BS_3011 1 1
#> 3 2 2.33 70202 agg_BS_1011 1 1
#> 4 2 2.33 70202 agg_BS_1011 2 2
#> 5 2 2.33 70202 agg_BS_1011 3 3
#> 6 2 2.33 70202 agg_BS_1011 4 4
#> 7 2 2.33 70202 agg_BS_1011 5 5
#> 8 2 2.33 70202 agg_BS_1011 6 7
#> 9 2 2.33 70202 agg_BS_1012 1 8
#> 10 2 2.33 70202 agg_BS_1021 1 8
#> # ℹ 8,404 more rows
#> # ℹ 5 more variables: mth_inv_start <dbl>, mth_inv_end <dbl>,
#> # capital_prior <dbl>, capital_end <dbl>, capital_invest <dbl>