Learn R Programming

SHELF (version 1.0.1)

fitdist: Fit distributions to elicited probabilities

Description

Takes elicited probabilities as inputs, and fits parametric distributions using least squares on the cumulative distribution function. If separate judgements from multiple experts are specified, the function will fit one set of distributions per expert.

Usage

fitdist(vals, probs, lower = -Inf, upper = Inf, weights = 1, tdf = 3)

Arguments

vals
A vector of elicited values for one expert, or a matrix of elicited values for multiple experts (one column per expert). Note that the an elicited judgement about X should be of the form P(X
probs
A vector of elicited probabilies for one expert, or a matrix of elicited values for multiple experts (one column per expert). A single vector can be used if the probabilities are the same for each expert. For each expert, the smallest elicited probability
lower
A single lower limit for the uncertain quantity X, or a vector of different lower limits for each expert. Specifying a lower limit will allow the fitting of distributions bounded below.
upper
A single upper limit for the uncertain quantity X, or a vector of different lower limits for each expert. Specifying both a lower limit and an upper limit will allow the fitting of a Beta distribution.
weights
A vector or matrix of weights corresponding to vals if weighted least squares is to be used in the parameter fitting.
tdf
The number of degrees of freedom to be used when fitting a t-distribution.

Value

  • NormalParameters of the fitted normal distributions.
  • Student.tParameters of the fitted t distributions. Note that (X - location) / scale has a standard t distribution. The degrees of freedom is not fitted; it is specified as an argument to fitdist.
  • GammaParameters of the fitted gamma distributions. Note that E(X) = shape / rate.
  • Log.normalParameters of the fitted log normal distributions: the mean and standard deviation of log X.
  • Log.Student.tParameters of the fitted log student t distributions. Note that (log(X) - location) / scale has a standard t distribution. The degrees of freedom is not fitted; it is specified as an argument to fitdist.
  • BetaParameters of the fitted beta distributions. X is scaled to the interval [0,1] via Y = (X - lower)/(upper - lower), and E(Y) = shape1 / (shape1 + shape2).
  • ssqSum of squared errors for each fitted distribution and expert. Each error is the different between an elicited cumulative probability and the corresponding fitted cumulative probability.
  • best.fittingThe best fitting distribution for each expert, determined by the smallest sum of squared errors.
  • valsThe elicited values used to fit the distributions.
  • probsThe elicited probabilities used to fit the distributions.
  • limitsThe lower and upper limits specified by each expert (+/- Inf if not specified).

See Also

elicit, feedback, plinearpool, plotfit, qlinearpool, roulette

Examples

Run this code
# One expert, with elicited probabilities
# P(X<20)=0.25, P(X<30)=0.5, P(X<50)=0.75
# and X>0.
v <- c(20,30,50)
p <- c(0.25,0.5,0.75)
fitdist(vals=v, probs=p, lower=0)

# Now add a second expert, with elicited probabilities
# P(X<55)=0.25, P(X<60=0.5), P(X<70)=0.75
v <- matrix(c(20,30,50,55,60,70),3,2)
p <- c(0.25,0.5,0.75)
fitdist(vals=v, probs=p, lower=0)

# Two experts, different elicited quantiles and limits.
# Expert 1: P(X<50)=0.25, P(X<60=0.5), P(X<65)=0.75, and provides bounds 10<X<100
# Expert 2: P(X<40)=0.33, P(X<50=0.5), P(X<60)=0.66, and provides bounds 0<X
v <- matrix(c(50,60,65,40,50,60),3,2)
p <- matrix(c(.25,.5,.75,.33,.5,.66),3,2)
l <- c(10,0)
u <- c(100, Inf)
fitdist(vals=v, probs=p, lower=l, upper=u)

Run the code above in your browser using DataLab