yrs_lifetime: Prepare data for comparing lifetime vs annual buyers

Description Usage Arguments Functions See Also Examples

Description

For preparing to run yrs_result_renew (logistic regression) with annual vs. lifetime buyers separately.

Usage

1
2
3
yrs_lifetime_join(history, sale, lic, life_slct)

yrs_lifetime_split(history_split)

Arguments

history

license history data frame

sale, lic

license data frames

life_slct

name of group to include from lic$life_group (e.g., "sportsman"). Only one value should be specified.

history_split

license history list produced by yrs_zero_split()

Functions

See Also

Other functions to estimate annual license buying: yrs_avidity, yrs_calc_avg, yrs_calc, yrs_fit, yrs_plot, yrs_predict_avg, yrs_predict, yrs_result, yrs_zero

Examples

 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
26
27
28
## Not run: 
library(DBI)
library(tidyverse)
f <- "E:/SA/Data-production/NCWRC-19-01/license.sqlite3"
con <- dbConnect(RSQLite::SQLite(), f)
all_sports <- tbl(con, "all_sports") %>% collect()
lic <- tbl(con, "lic") %>% select(lic_id, life_group, duration) %>% collect()
sale <- tbl(con, "sale") %>% select(lic_id, year, cust_id) %>% collect()
dbDisconnect(con)

all_sports <- all_sports %>%
    yrs_avidity() %>%
    yrs_lifetime_join(sale, lic, "sportsman")

df_split <- all_sports %>%
    yrs_zero_split() %>%
    yrs_zero_filter(function(x) filter(x, age_year %in% 25:35,
                    life_group == "sportsman"))
life_split <- yrs_lifetime_split(df_split)

renew_life <- yrs_result_renew(life_split$annual, life_split$lifetime) %>%
    mutate(method = "renew_life")
renew <- yrs_result_renew(life_split$annual)

bind_rows(renew, renew_life) %>% yrs_plot() +
   ggtitle("Sportsman annual vs lifetime estimated years")

## End(Not run)

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