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

Description Usage Arguments Value Examples

View source: R/make_willingness_utility.R

Description

Function accepts from a numeric variable of payment the respondent is willing to make. The function produces table with three 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

Usage

1
2
3
4
5
6
7
make_willingness_utility(
  x,
  money_pay_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.

jump

by defoult ==1 jumps on the cost axis

var_min

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

var_max

by defoult = 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
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(money_pay_var_string = "money_willing_to_pay")

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