yrs_result: Results of license buying

Description Usage Arguments Functions See Also Examples

Description

These are convenience functions to wrap calculating, fitting, and predicting.

Usage

 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)

Arguments

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

Functions

See Also

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

Examples

 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)

southwick-associates/lifetime documentation built on Feb. 24, 2020, 9:33 a.m.