make_willingness_utility_group_by: Generate a 1-ecdf willing to pay + utility table

Description Usage Arguments Value Examples

View source: R/make_willingness_utility_group_by.R

Description

Function accepts from a numeric variable of payment the respondent is willing to make. The function produces table with four variables: price- this is a spreading of the willing to pay price on a new scale prop_willing- proportion of respondents that are willing to pay any given price utility- prop_willing * price group- the group for which the curve is relevant

Usage

1
2
3
4
5
6
7
8
make_willingness_utility_group_by(
  x,
  money_pay_var_string,
  group_var_string,
  jump = 1,
  var_min = NA,
  var_max = NA
)

Arguments

x

a tbl() with the data.

money_pay_var_string

Target variable name as string, represents money.

group_var_string

the grouping variable as string for which the process needs to be repeated

jump

by default ==1 jumps on the cost axis

var_min

by default = NA, allows you to specify the minimal value

var_max

by default = NA, allows you to specify the maximal value

Value

the function generates the cost, 1-ecdf willingness to pay cost value, and utility

Examples

1
2
3
4
5
6
7
8
quality_assurance <- data.frame(
ID = 1:500,
money_willing_to_pay = sample(seq(0,20,5), size = 500, replace = T),
year = sample(c("2018", "2019", "2020"), size = 500, replace = T))

quality_assurance %>%
  make_willingness_utility_group_by(money_pay_var_string = "money_willing_to_pay",
                                   group_var_string = "year")

sarid-ins/saridr documentation built on Nov. 10, 2020, 9:07 p.m.