Description Usage Arguments See Also Examples
View source: R/model-YrsAnnual.R
It's useful to visualize the results with retention estimates over time,
especially for comparing alternative methods. This function takes the result
of yrs_result
and plots with some useful labelling and scaling.
1 |
result_df |
results returned from |
include_label |
if TRUE, displays the method name and years estimate next to the line |
xlim |
maximum x-axis limit for plot |
grp |
unquoted name of grouping variable |
Other functions to estimate annual license buying: yrs_avidity
,
yrs_calc_avg
, yrs_calc
,
yrs_fit
, yrs_lifetime
,
yrs_predict_avg
, yrs_predict
,
yrs_result
, yrs_zero
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | library(dplyr)
library(ggplot2)
data(all_sports)
avg <- yrs_result_avg(all_sports)
df_split <- all_sports %>%
yrs_avidity(drop_na_yrs = FALSE) %>%
yrs_zero_split() %>%
yrs_zero_filter(function(x) filter(x, age_year %in% 25:35))
# comparing retention-based vs avg-years-based methods
observe <- yrs_result_observe(df_split)
retain <- yrs_result_retain(df_split)
max <- yrs_result_max(df_split)
bind_rows(retain, max, avg) %>% yrs_plot() + geom_point(data = observe)
# comparing retain & renew methods
renew <- yrs_result_renew(df_split)
bind_rows(retain, renew) %>% yrs_plot() + geom_point(data = observe)
# using a GAM for retain
retain <- df_split %>%
yrs_result_retain(model = function(x) yrs_fit_retain_gam(x))
bind_rows(retain, max, avg) %>% yrs_plot() + geom_point(data = observe)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.