Learn R Programming

Package Status

What is preference elicitation?

Most real-world decisions must reconcile multiple, competing objectives. In buying a car, you might be concerned about cost, reliability, and performance, but before you can make a decision, you must establish the relative importance of these goals. A common mathematical approach to this problem is to define weights for each of these objectives. Although you might have a ballpark intuition for the weights, it is difficult to set them in a repeatable and defendable manner.

Preference elicitation relieves some of this burden. Instead of determining the weights directly, you make a series of pairwise comparisons between alternatives: do you prefer car A, car B, or are you indifferent? Research has shown that these pairwise comparisons are far easier to make and much easier to justify than explicitly setting the weights directly. This package implements a preference elicitation algorithm that takes your stated preferences and uses them to calculate an optimal set of weights. It can even suggest which comparisons you should make to get the most accurate weights with the fewest number of queries.

Technical details about how this package works can be found in the article here.

Installation

This package is on CRAN, so you can install it directly through install.packages().

install.packages("prefeR")

Examples

Hello, World

library(prefeR)

Sys.sleep(20)

# Each column of data is a variable, i.e. objective, 
# and each row is an alternative.
p <- prefEl(data = data.frame(x = c(1, 0, 1), 
                              y = c(0, 1, 1)))
# Set the prior belief on the weights for objectives x and y
p$priors <- c(Normal(0, 1), 
              Normal(0, 1))

# Add in some pairwise preferences
p$addPref(1 %>% 3) # prefer row 1 to row 3
p$addPref(3 %<% 2) # prefer row 2 to row 3

# Run the inference
p$infer()   # returns that x and y are of equal importance

# What comparision should you make next?
p$suggest() # suggest compare 1 to 2
p$addPref(1 %=% 2)

# Re-run the infernence algorithm 
p$infer()   # maintains belief that 1 and 2 are equal
p$rank()    # calculates the value of all three alternatives

More Examples

Choosing a car from the mtcars dataset

Copy Link

Version

Install

install.packages('prefeR')

Monthly Downloads

155

Version

0.1.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

John Lepird

Last Published

April 24th, 2022

Functions in prefeR (0.1.3)

Normal

A convenience function for generating Normal priors.
.getLogIndifProb

Evaluates the likelihood of the observed indifference preferences
.calculateLogProb

Calculates the log probability of seeing a given set of preferences
Exp

A convenience function for generating Exponential priors.
.sampleEntropy

Calculates the entropy of a matrix of samples.
Flat

A convenience function for generating a flat prior.
infer

A function that estimates the user's underlying utility function.
.getLogStrictProb

Evaluates the likelihood of the observed strict preferences
%>%

A helper function to add in preferences in a user-friendly way.
prefEl

A shortcut to create objects of the class BayesPrefClass.
%=%

A helper function to add in preferences in a user-friendly way.
.estimateEntropy

Calculates the expected posterior entropy of the prefel object if x and y are compared. Ignores the odds of indifference preferences, as using them would increase runtime 50% without much gain.
BayesPrefClass

An object containing all data necessary for preference elicitation.
%<%

A helper function to add in preferences in a user-friendly way.
suggest

Suggests a good comparison for the user to make next.