| Title: | R Package for Pairwise Preference Elicitation |
|---|---|
| Description: | Allows users to derive multi-objective weights from pairwise comparisons, which research shows is more repeatable, transparent, and intuitive other techniques. These weights can be rank existing alternatives or to define a multi-objective utility function for optimization. |
| Authors: | John Lepird |
| Maintainer: | John Lepird <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.3 |
| Built: | 2026-05-19 07:58:56 UTC |
| Source: | https://github.com/jlepird/prefer |
Calculates the log probability of seeing a given set of preferences
.calculateLogProb(x, p).calculateLogProb(x, p)
x |
A guess for our weight vector |
p |
An object of the Bayes preference class |
A scalar log-likelihood of the guess x
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.
.estimateEntropy(p, currentGuess, x, y).estimateEntropy(p, currentGuess, x, y)
p |
An object of class BayesPrefClass. |
currentGuess |
The current best estimate for our weight vector. |
x |
Possible comparison 1 |
y |
Possible comparison 2 |
Evaluates the likelihood of the observed indifference preferences
.getLogIndifProb(x, pref, p).getLogIndifProb(x, pref, p)
x |
the underlying data |
pref |
the stated preference |
p |
the preference elication object |
Evaluates the likelihood of the observed strict preferences
.getLogStrictProb(x, pref, p).getLogStrictProb(x, pref, p)
x |
the underlying data |
pref |
the stated preference |
p |
the preference elication object |
Calculates the entropy of a matrix of samples.
.sampleEntropy(X).sampleEntropy(X)
X |
a matrix where each row is a sample of variables in different columns |
A helper function to add in preferences in a user-friendly way.
a %<% ba %<% b
a |
The non-preferred row |
b |
The preferred row |
Other preferences:
%=%(),
%>%()
1 %<% 2 # prefer row 2 to row 11 %<% 2 # prefer row 2 to row 1
A helper function to add in preferences in a user-friendly way.
a %=% ba %=% b
a |
The first alternative |
b |
The second alternative |
Other preferences:
%<%(),
%>%()
1 %=% 2 # indifferent between 1 and 21 %=% 2 # indifferent between 1 and 2
A helper function to add in preferences in a user-friendly way.
a %>% ba %>% b
a |
The preferred row |
b |
The non-preferred row |
Other preferences:
%<%(),
%=%()
1 %>% 2 # prefer row 1 to row 21 %>% 2 # prefer row 1 to row 2
An object containing all data necessary for preference elicitation.
dataA matrix or dataframe of data.
priorsA list of functions that give the prior on each variable.
sigmaA scalar value to use for the confusion factor (default 0.1).
Sigma(Internal use only) A matrix of sigma * diag(ncol(data)).
strictA list of lists of preferences. For each element x, x[[1]] > x[[2]].
indifA list of lists of indifference preferences. For each element x, x[[1]] = x[[2]].
weightsA vector of weights determined by the inference algorithm.
addPref(x)Adds a preference created using %>%, %<%, or %=%.
infer(estimate = "recommended")Calls the “infer” function to guess weights
rank()Calculates the utility of each row in our dataset
suggest(maxComparisons = 10)Calls the “suggest” function to guess weights
A convenience function for generating Exponential priors.
Exp(mu = 1)Exp(mu = 1)
mu |
The mean of the exponential distribution, i.e. |
A function yielding the log-PDF at x of a exponential distribution with given statistics.
Other priors:
Flat(),
Normal()
Exp(1)(1) == dexp(1,1, log = TRUE)Exp(1)(1) == dexp(1,1, log = TRUE)
A convenience function for generating a flat prior.
Flat()Flat()
The zero function.
Flat()(1) == 0.0Flat()(1) == 0.0
A function that estimates the user's underlying utility function.
infer(p, estimate = "recommended", nbatch = 1000)infer(p, estimate = "recommended", nbatch = 1000)
p |
A BayesPrefClass instance. |
estimate |
The type of posterior point-estimate returned. Valid options are "recommended" (default), "MAP", and "mean". |
nbatch |
If using Monte Carlo estimates, the number of samples. Defaults to 1000. |
A vector of parameters that best fits the observed preferences.
p <- prefEl(data = data.frame(c(1,0,1), c(0,1,1), c(1,1,1)), priors = c(Normal(0, 1), Exp(0.5), Flat())) p$addPref(1 %>% 2) infer(p, estimate = "MAP")p <- prefEl(data = data.frame(c(1,0,1), c(0,1,1), c(1,1,1)), priors = c(Normal(0, 1), Exp(0.5), Flat())) p$addPref(1 %>% 2) infer(p, estimate = "MAP")
A convenience function for generating Normal priors.
Normal(mu = 0, sigma = 1)Normal(mu = 0, sigma = 1)
mu |
The mean of the normal distribution |
sigma |
The standard deviation of the prior |
A function yielding the log-PDF at x of a normal distribution with given statistics.
Normal(0, 1)(1) == dnorm(1, log = TRUE)Normal(0, 1)(1) == dnorm(1, log = TRUE)
A shortcut to create objects of the class BayesPrefClass.
prefEl(data = NA, priors = list(), ...)prefEl(data = NA, priors = list(), ...)
data |
A matrix or dataframe of data. Each column should be a variable, each row an observation. |
priors |
A list of functions that give the prior on each variable. E.g. see help(Flat) |
... |
Other parameters to pass to the class constructor. Not recommended. |
p <- prefEl(data = data.frame(x = c(1,0,1), y = c(0, 1, 1)), priors = c(Normal(0,1), Flat()))p <- prefEl(data = data.frame(x = c(1,0,1), y = c(0, 1, 1)), priors = c(Normal(0,1), Flat()))
Suggests a good comparison for the user to make next.
suggest(p, maxComparisons = 10)suggest(p, maxComparisons = 10)
p |
An object of class BayesPrefClass. |
maxComparisons |
The maximum number of possible comparisons to check. Default: 10. |
A two-element vector of recommended comparisons.