mpdi_obj: objective function for probability of a prediciton interval...

Description Usage Arguments Details Value Examples

View source: R/max_prob_pred_int.R

Description

objective function for probability of a prediciton interval for 'small' sample sizes.

Usage

1
2
3
4
5
6
7
8
mpdi_obj(
  alpha,
  x,
  method = c("tdist", "conformal"),
  m.method = c("quantile", "deviation", "jackknife"),
  alpha.penalty = 0,
  scale = FALSE
)

Arguments

alpha

miscoverage or 'error rate'

x

a vector

method

either 'tdist' (assumes normality) or 'conformal' (distribution-free)

m.method

method used to compute conformal prediction interval: either "quantile", "deviation" or "jackknife"

alpha.penalty

whether to include an alpha penalty (default 0 or 'no')

scale

whether to scale the input vector. This only makes sense if the alpha.penalty is different from zero.

Details

Objective funciton for optimization

The idea is to find the maximum level of probability that will produce a prediction interval which matches the minimum and maximum values in the observed sample. The distance is calculated as abs(x.min - calc.lower.bound) + abs(x.max - calc.upper.bound).

Value

a single value which represents a value that should be minimized

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
set.seed(12345)
x <- rnorm(10)
alphas <- seq(0,1, 0.05)
objf <- numeric(length(alphas))
for(i in 1:length(objf)){
  objf[i] <- mpdi_obj(alphas[i], x = x, method = "conformal")
}
qplot(alphas, objf, geom = "line")
## Trying the t-distribution
y <- rt(10, df = 1)
alphas <- seq(0,1, 0.05)
objf <- numeric(length(alphas))
for(i in 1:length(objf)){
  objf[i] <- mpdi_obj(alphas[i], x = y, method = "conformal")
}
qplot(alphas, objf, geom = "line")

## End(Not run)

femiguez/predintma documentation built on July 5, 2021, 4:16 a.m.