
Compute qmoms for a single grouped surface (convenience wrapper)
Source:R/qmoms.R
qmoms_compute_bygroup.Rd
Accepts one (id, date, days) option surface and returns a one-row tibble with
the keys plus all qmoms metrics. Column names can be remapped via cols_map
.
Usage
qmoms_compute_bygroup(
groupparams,
id = NULL,
rate = NULL,
days = NULL,
date = NULL,
cols_map = list(id = "id", date = "date", days = "days", rate = "rate", mnes = "mnes",
impl_volatility = "impl_volatility")
)
Arguments
- groupparams
A two-element list:
list(group_df, params)
wheregroup_df
is a data.frame/tibble containing a single surface (sameid
/date
/days
);params
is the list returned byrq_default_params()
.group_df
must include columns for moneyness and IV (defaults:mnes
,impl_volatility
); optionallyrate
if you do not passrate
explicitly.- id, date, days, rate
Optional scalar overrides for the group keys and rate. If
rate
isNULL
, the function looks for arate
column ingroup_df
.- cols_map
Optional named list mapping required columns in
group_df
to the expected names, e.g.list(id = "ID", date = "Date", days = "Days", rate = "Rate", mnes = "M", impl_volatility = "IV")
.
Examples
g_all <- get_rate_for_maturity(qmoms_zerocd, df_surf = qmoms_surface)
g <- subset(g_all, id == g_all$id[1] & days == g_all$days[1])
qmoms_compute_bygroup(list(g, rq_default_params()))
#> # A tibble: 1 × 20
#> id date days nopt smfiv mfiv_bkm mfiv_bjn smfivd mfivd_bkm
#> <int> <date> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 10078 1996-01-04 30 234 6.39 3.10 3.92 0.00760 0.0115
#> # ℹ 11 more variables: mfivd_bjn <dbl>, mfis <dbl>, mfik <dbl>,
#> # cvix_sigma2 <dbl>, cvix_mnes20 <dbl>, rix <dbl>, rixnorm <dbl>,
#> # tlm_sigma2 <dbl>, tlm_delta20 <dbl>, slopedn <dbl>, slopeup <dbl>