est_part: Estimate participants by year from license history

Description Usage Arguments Value See Also Examples

View source: R/dashboard.R

Description

This function requires a correctly formated history table (see history). It produces a simple count of records per year, optionally by segment, & runs a validation test: pct change per year.

Usage

1
2
3
4
5
6
7
est_part(history, segment = "tot", test_threshold = 20,
  show_test_stat = FALSE, suppress_warning = FALSE,
  outvar = "participants")

est_recruit(history, segment = "tot", test_threshold = 35,
  show_test_stat = FALSE, suppress_warning = FALSE,
  outvar = "recruits")

Arguments

history

data frame: input license history table

segment

character: defaults to "tot", which indicates no segmentation. Alternatively specifiy other license history variables ("res", "sex", etc.)

test_threshold

numeric: threshold in whole number percentage points for pct change per year. A warning will be printed if the absolute value of the change for any year exceeds the threshold.

show_test_stat

logical: If TRUE, the output table will include a variable holding the test statistic for each row.

suppress_warning

logical: If TRUE, no test warning will be displayed (even if threshold is exceeded). Test statistics can still be included by setting show_test_stat = TRUE.

outvar

character: name of variable that stores metric

Value

Returns a data frame with 3 variables (segment, "year", outvar), and optionally with 2 extra variables ("change", "pct_change") if show_test_stat = TRUE

See Also

Salic Function Reference: salic

Other dashboard functions: check_threshold, est_churn, format_result, scaleup_part

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
library(dplyr)
data(history)
history <- history %>%
    label_categories() %>%
    recode_agecat() %>%
    filter(!agecat %in% c("0-17", "65+"))
    
# participants
est_part(history)

# by segment
# produces a warning
est_part(history, "agecat") 

# suppress warning
x <- est_part(history, "agecat", test_threshold = 25)

# new recruits
history_new <- filter(history, !is.na(R3), R3 == "Recruit")
est_recruit(history_new)

# apply over multiple segments 
segs <- c("tot", "res", "sex", "agecat")
part <- sapply(segs, function(x) est_part(history, x), simplify = FALSE)

# specify test thesholds by segment to suppress warnings
tests <- c(tot = 20, res = 45, sex = 30, agecat = 40)
part <- sapply(segs, function(x) est_part(history, x, tests[x]), simplify = FALSE)

southwick-associates/salic documentation built on Nov. 5, 2019, 9:13 a.m.