Description Usage Arguments Functions See Also Examples
These are convenience functions to wrap calculating, fitting, and predicting.
1 2 3 4 5 6 7 8 9 10 11 | yrs_result_observe(history_split, predict_age = 30)
yrs_result_retain(history_split, predict_age = 30, end_age = 64,
model = function(x) yrs_fit_retain(x))
yrs_result_renew(history_split, history_predict = NULL,
predict_age = 30, end_age = 64)
yrs_result_max(history_split, predict_age = 30, end_age = 64)
yrs_result_avg(history, predict_age = 30, end_age = 64)
|
history_split |
license history list produced by yrs_zero_split() |
predict_age |
target age for prediction (year zero) |
end_age |
last age for prediction |
model |
function for modelling |
history_predict |
prediction dataset. If NULL, uses the training dataset |
history |
training dataset |
yrs_result_observe
: Results for predicting license buying - observed retention
yrs_result_retain
: Results for predicting license buying - predicted retention
yrs_result_renew
: Results for predicting license buying - predicted renewal
yrs_result_max
: Results for predicting license buying - maximum retention
Based on observed retention, assume the retention rate remains level after the last observed year. This defines a maximum estimate because retention curves never begin sloping upward.
yrs_result_avg
: Results for predicting license buying - predicted avg years
Different than the renew & retain functions since it uses all available ages to estimate average years purchased in five, so no train_ages arguments are needed.
Other functions to estimate annual license buying: yrs_avidity
,
yrs_calc_avg
, yrs_calc
,
yrs_fit
, yrs_lifetime
,
yrs_plot
, yrs_predict_avg
,
yrs_predict
, yrs_zero
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | library(dplyr)
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))
observe <- yrs_result_observe(df_split)
retain <- yrs_result_retain(df_split)
renew <- yrs_result_renew(df_split)
max <- yrs_result_max(df_split)
library(ggplot2)
ggplot(observe, aes(age_year, pct, color = method)) + geom_point() +
geom_line(data = retain) +
geom_line(data = renew) +
geom_line(data = avg) +
geom_line(data = max)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.