getCIMomentAndDerivatives: Build confidence intervals for the quantities E[(X-a)^m I(X...

Description Usage Arguments Value Examples

View source: R/EstimateOptimizationParameters.R

Description

Using bootstrap, this function builds (1-alpha)-confidence intervals for the truncated moments E[X^m I(X => a)] and derivatives f^(d)(a) for a given sample and threshold a. The confidence intervals can be either hyperrectangles, or ellipsoids.

Usage

1
2
3
getCIMomentAndDerivatives(sample, a, m = NULL, d = NULL, nboot = 1000,
  alpha = 0.05, method = c("hyperrectangle", "ellipsoid", "both"),
  mc.cores = 1, bootSample = FALSE, bonferroni = FALSE, seed = NULL)

Arguments

sample

Vector containing the sample values of the random variable X

a

Vector of values at which the derivatives and moments are estimated

m

Vector of real numbers

d

Vector of positive integers

nboot

The number of bootstrap samples desired

alpha

Desired accuracy level for the confidence interval. Default value is 5%

method

A string either equal to hyperrectangle, ellipsoid, or both defining the type of confidence intervals. Default value is hyperrectangle

mc.cores

Number of cores used in the computation of the confidence intervals. Default value is 1. If mc.cores > 1, parallel computing takes place with a total of mc.cores

bootSample

Logical value indicating wether the bootstraped sample should be returned by the function

Value

A list of with the same length as the vector a of the argument list. Each cell of the list is also a list which contains

hyperrectangle

A data.frame containing the lower bounds and upper bounds of the derivatives and truncated moments. Only in the case when the argument method = hyperrectangle or both

ellipsoid

A list containing the vecor of means, the covariance matrix, and the radius of the ellipsoid describing the confidence interval. Only in the case when the argument method = ellipsoid or both

a

scalar value giving the threshold a for the associated confidence interval

bootSample

Matrix containing the bootstrapped samples used to build the confidence intervals. Each row contains one bootstrap of the original sample

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
a <- c(0,1) ; m <- c(0, 1) ; d <- 1 ; nboot <- 1000
set.seed(100) ; sample <- rnorm(100, 0, 1)
hist(sample)
CI <- getCIMomentAndDerivatives(sample, a,m,d,nboot = nboot,mc.cores = 1, method = "both", bootSample = TRUE)

library(ggplot2)
i <- 1
title <- paste0("95%-CI of the Estimated Parameters when a = ",a[i])
plot <- plotCI(CI[[i]]$bootSample, CI[[i]])
plot + geom_point(aes(x = dnorm(a[i]), y = 1-pnorm(a[i])), colour = "blue") +
geom_text(aes(x = 1.009*dnorm(a[i]), y = 1-pnorm(a[i]), label = "True Value"), colour = "blue")+
labs(x = "Derivative of order 1", y = "Moment of order 0") + ggtitle(title)

i <- 2
title <- paste0("95%-CI of the Estimated Parameters when a = ",a[i])
plot <- plotCI(CI[[i]]$bootSample, CI[[i]])
plot + geom_point(aes(x = dnorm(a[i]), y = 1-pnorm(a[i])), colour = "blue") +
geom_text(aes(x = 1.009*dnorm(a[i]), y = 1-pnorm(a[i]), label = "True Value"), colour = "blue")+
labs(x = "Derivative of order 1", y = "Moment of order 0") + ggtitle(title)

cmottet/GLP documentation built on May 6, 2019, 12:05 a.m.