sampleMarginalFit: Sample from the marginal distribution of the target variable

View source: R/extensionScripts.R

sampleMarginalFitR Documentation

Sample from the marginal distribution of the target variable

Description

As part of the Extension Method, this function will generate a random sample from the marginal distribution of the target variable, using a sample from the marginal distribution of the extension variable, the specified c-distribution, and the appropriate judgements used to construct the median model.

Usage

sampleMarginalFit(
  fitX,
  sampleY,
  medianY,
  yCP,
  xMed,
  dist = "best",
  link = "identity"
)

Arguments

fitX

an object of class elicitation specifying the c-distribution: the distribution of the target variable, conditional on the extension variable taking its median value.

sampleY

a sample from the marginal distribution of the extension variable.

medianY

the median value of the extension variable.

yCP

vector of conditioning points for the extension variable.

xMed

vector of medians of the target variable, corresponding to each value of the extension variable in yCP.

dist

choice of parametric distribution for the c-distribution. Options are "normal", "t", "gamma", "lognormal", "logt","beta", "hist" (for a histogram fit), and "best" (for best fitting).

link

link in the median function. One of "identity", "log" or "logit"

Value

a vector containing a sample from the marginal distribution of the target variable.

Examples

## Not run: 

myfitX <- fitdist(vals = c(5.5, 9, 14),
 probs = c(0.25, 0.5, 0.75),
 lower = 0)
ry <- rgamma(10, 5.19, 0.694)
sampleMarginalFit(fitX = myfitX, 
 sampleY = ry,
 medianY = 7,
 yCP = c(3, 5, 7, 9.5, 13.5),
 xMed = c(2, 6.5, 9, 13, 20),
 dist = "lognormal",
 link = "log")
 
## End(Not run)

OakleyJ/SHELF documentation built on March 17, 2024, 8:13 p.m.