Function to calculate investment thresholds and identify large deviation jumps
Source:R/ffp_invest.R
ffp_hfid_invest_jump.RdThis function takes a data frame of asset loan data and calculates investment thresholds based on standard deviation. It then identifies large deviation jumps in the investment variables.
Usage
ffp_hfid_invest_jump(
df_asset,
fl_sd_ithres = stats::qnorm(0.99),
svr_hhid = "id",
svr_time = "month",
verbose = FALSE,
verbose_detail = FALSE,
it_verbose_detail_nrow = 100
)Arguments
- df_asset
A data frame containing asset data
- fl_sd_ithres
Standard deviation threshold for investments
- svr_hhid
Variable name for household ID
- svr_time
Variable name for time
- verbose
Logical indicating whether to print verbose output (default is TRUE)
- verbose_detail
Logical indicating whether to print detailed verbose output (default is TRUE)
- it_verbose_detail_nrow
Number of rows to print for detailed verbose output (default is 100)
See also
Used by vignette(s) ffv_invest_loan_bridge. Related issue(s):
PrjThaiHFID-#32,
PrjThaiHFID-#1.
Author
Fan Wang, http://fanwangecon.github.io
Examples
df <- tstm_asset_loan
fl_sd_ithres <- stats::qnorm(0.99)
ffp_hfid_invest_jump(df, fl_sd_ithres = fl_sd_ithres)
#> # A tibble: 1,352,616 × 8
#> # Groups: id, ivars [9,492]
#> id month ivars value value_df value_df_sd bl_value_jump thres_inv_dfsd
#> <int> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1003 0 agg_BS_… 1.11e5 NA 11896. 0 2.33
#> 2 1003 1 agg_BS_… 1.67e5 55691. 11896. 1 2.33
#> 3 1003 2 agg_BS_… 1.64e5 -2352. 11896. 0 2.33
#> 4 1003 3 agg_BS_… 1.78e5 13788. 11896. 0 2.33
#> 5 1003 4 agg_BS_… 1.75e5 -2676. 11896. 0 2.33
#> 6 1003 5 agg_BS_… 1.73e5 -2628. 11896. 0 2.33
#> 7 1003 6 agg_BS_… 1.70e5 -2580. 11896. 0 2.33
#> 8 1003 7 agg_BS_… 1.68e5 -2534. 11896. 0 2.33
#> 9 1003 8 agg_BS_… 1.61e5 -6358. 11896. 0 2.33
#> 10 1003 9 agg_BS_… 1.59e5 -2344. 11896. 0 2.33
#> # ℹ 1,352,606 more rows