Last data update: 2014.03.03

R: Simulate from the expert's distribution
rvSELR Documentation

Simulate from the expert's distribution

Description

Simulate random variables from an SEL object.

Usage

rvSEL(n, object, nPoints = 1000)

Arguments

n

Number of simulated values.

object

An SEL object.

nPoints

Number of evaluations for the brute force inversion of the expert cdf.

Details

The inverse of the distribution function is formed by evaluating the distribution function at nPoints points and interchanging the role of dependent and independent variable when building an function interpolating the data (using splinefun with "monoH.FC" option). Note that there are also direct ways of inverting a B-spline function, which however turned out to be less efficient for our purposes.

Value

A numeric vector containing pseudo-random variates from the expert's density.

Author(s)

Bjoern Bornkamp

References

Bornkamp, B. and Ickstadt, K. (2009). A Note on B-Splines for Semiparametric Elicitation. The American Statistician, 63, 373–377

See Also

SEL, splinefun

Examples

## bimodal example 
x2 <- c(0.1, 0.2, 0.5, 0.8, 0.9)
y2 <- c(0.2, 0.4, 0.45, 0.85, 0.99)

fit1 <- SEL(x2, y2, Delta=0.05, d = 4, inknts = x2)
fit2 <- SEL(x2, y2, Delta=0.05, d = 15, N = 0)
comparePlot(fit1, fit2, superpose = TRUE)

## sample from SEL object
xxx <- rvSEL(50000, fit1)
hist(xxx, breaks=100, freq=FALSE)
curve(predict(fit1, newdata=x), add=TRUE)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SEL)
Loading required package: splines
Loading required package: quadprog
Loading required package: lattice
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SEL/rvSEL.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rvSEL
> ### Title: Simulate from the expert's distribution
> ### Aliases: rvSEL
> ### Keywords: misc
> 
> ### ** Examples
> 
> ## bimodal example 
> x2 <- c(0.1, 0.2, 0.5, 0.8, 0.9)
> y2 <- c(0.2, 0.4, 0.45, 0.85, 0.99)
> 
> fit1 <- SEL(x2, y2, Delta=0.05, d = 4, inknts = x2)
> fit2 <- SEL(x2, y2, Delta=0.05, d = 15, N = 0)
> comparePlot(fit1, fit2, superpose = TRUE)
> 
> ## sample from SEL object
> xxx <- rvSEL(50000, fit1)
> hist(xxx, breaks=100, freq=FALSE)
> curve(predict(fit1, newdata=x), add=TRUE)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>