Skip to contents

[Stable]

cont_sample_data() samples data based on expert estimates stored in the elic_cont object.

Usage

cont_sample_data(
  x,
  round,
  ...,
  method = "PERT",
  var = "all",
  n_votes = 1000,
  weights = NULL,
  scale_conf = 100,
  verbose = TRUE
)

Arguments

x

an object of class elic_cont created with cont_start.

round

integer (1 or 2) indicating if the data belongs to the first or second elicitation round. See section rounds for more detail.

...

Unused arguments, included only for future extensions of the function.

method

character string with the name of the method to sample the data, only the PERT Method is implemented, see Method below.

var

character string with the name of the variable or character vector with more variable names that you want to extract from the data. Use all for all variables.

n_votes

numeric indicating the number of votes to consider.

weights

numeric vector with the weights to apply to the estimates. If equal to 1, each experts get n_votes votes, see Weights below.

scale_conf

numeric, the scale factor for the confidence interval.

verbose

logical, if TRUE it prints informative messages.

Value

A tibble with the sampled data. This object has an additional class cont_sample used to implement the plotting method.

Details

Weighted allocations distribute the full budget among answering experts. Thus, the number of row in the sampled data will n_experts * n_votes. If an expert doesn't provide data for the sampled variable, a placeholder row is added. In such case, row counts can exceed n_experts * n_votes.

Weights

To provide a different number of votes to each expert use the weights argument. The length of the vector must be equal to the number of experts or have a length of one. Default is NULL, when no weight is provided.

If provided when the elicitation type is a four points elicitation, the weight values overwrite the confidence estimates.

Method

The function samples the data differently depending on the elicitation type:

  • one point elicitation: the estimate provided by each expert is repeated n_votes number of times. The weights argument can be used to weight the estimates of each expert (give a certain number of vote to each expert) in the overall distribution.

  • three points elicitation: the minimum, best, and maximum estimates of each expert are used as scaling parameters of the PERT distribution from which the data are sampled. The weights argument can be used to weight the estimates of each expert (give a certain number of vote to each expert) in the overall distribution.

  • four points elicitation: the minimum, best, and maximum estimates of each expert are rescaled according to their confidence and used as scaling parameters of the PERT distribution from which the data are sampled. Furthermore, their confidence is used as the weights argument to weight the estimates of each expert (give a number of vote to each expert) in the overall distribution.

scale_conf

If the variable plotted is the result of a four points elicitation where expert confidence is provided, the minimum and maximum values provided by each expert are rescaled using their provided confidence categories. Users can choose how they want to rescale minimum and maximum values by providing a value for the scale_conf argument. If no argument is provided, a default value of 100 is used for scale_conf.

The scaled minimum and maximum values are obtained with:

\(minimum = best\ guess - (best\ guess - minimum)\frac{scale\_conf} {confidence}\)

\(maximum = best\ guess + (maximum - best\ guess) \frac{scale\_conf} {confidence}\)

For probability variables (var_types = "p"), confidence scaling may extend the estimated minimum and maximum value below zero or above one. To keep the interval within the valid probability range, any scaled minimum below zero is set to zero, and any scaled maximum above one is set to one. A warning is issued when this adjustment is needed.

The best estimate and the original responses stored in the elicitation object remain unchanged. The adjusted bounds are used to define the PERT distribution when sampling and the displayed intervals when plotting.

See also

Author

Sergio Vignali and Maude Vernet

Examples

# Create the elict object and add data for the first and second round from a
# data.frame.
my_elicit <- cont_start(var_names = c("var1", "var2", "var3"),
                        var_types = "ZNp",
                        elic_types = "134",
                        experts = 6) |>
  cont_add_data(data_source = round_1, round = 1) |>
  cont_add_data(data_source = round_2, round = 2)
#> ✔ <elic_cont> object for "Elicitation" correctly initialised
#> ✔ Data added to "Round 1" from "data.frame"
#> ✔ Data added to "Round 2" from "data.frame"

# Sample data for the second round for all variables
samp <- cont_sample_data(my_elicit, round = 2)
#> ✔ Rescaled min and max based on confidence estimates for variable "var3".
#> ✔ Data for "var1", "var2", and "var3" sampled successfully using the "PERT" method.
samp
#> # A tibble: 18,000 × 3
#>    id      var   value
#>    <chr>   <chr> <dbl>
#>  1 5ac97e0 var1      0
#>  2 5ac97e0 var1      0
#>  3 5ac97e0 var1      0
#>  4 5ac97e0 var1      0
#>  5 5ac97e0 var1      0
#>  6 5ac97e0 var1      0
#>  7 5ac97e0 var1      0
#>  8 5ac97e0 var1      0
#>  9 5ac97e0 var1      0
#> 10 5ac97e0 var1      0
#> # ℹ 17,990 more rows

# Sample data for the first round for the variable `var1` and `var2`
samp <- cont_sample_data(my_elicit, round = 1, var = c("var1", "var2"))
#> ✔ Data for "var1" and "var2" sampled successfully using the "PERT" method.

# Sample data for the second round for the variable `var3`. Notice that the
# data are rescaled using the expert confidence before sampling.
samp <- cont_sample_data(my_elicit, round = 2, var = "var3")
#> ✔ Rescaled min and max based on confidence estimates for variable "var3".
#> ✔ Data for "var3" sampled successfully using the "PERT" method.

# Sample data for the first round for the variable `var3` providing the
# weights. Notice that the weights overwrite the confidence estimates and
# that some values are constrained to be between 0 and 1 after rescaling.
samp <- cont_sample_data(my_elicit, round = 1, var = "var3",
                         weights = c(0.8, 0.7, 0.9, 0.7, 0.6, 0.9))
#> ℹ Weights provided in argument `weights` used instead of confidence estimates to calculate the number of vote attributed to each expert in variable "var3".
#> Warning: ! Some values have been constrained to be between 0 and 1.
#>   See the scale_conf section in the help page for `elicitr::cont_sample_data()`
#>   for more information.
#> ✔ Rescaled min and max based on confidence estimates for variable "var3".
#> ✔ Data for "var3" sampled successfully using the "PERT" method.