F_exp: Expectation on A Given Interval

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/F_exp.R

Description

This functions returns an approximated expectation of a given underlying distribution on a bound interval. Specifically, the function tackles with distribution misspecification issue by applying fhat. The approximation is done by Trapezoid Rule.

Usage

1
F_exp(a, b, N, fhat = NULL, unit = b-a, dist_null = "norm", ...)

Arguments

a

lower bound of interval

b

upper bound of interval

N

number of observations

fhat

a function adjust the distribution misspecification. The default value is NULL, means no adjustment.

unit

width of subintervals. The default unit is b-a, means approximation is done in one piece.

dist_null

a character string giving the underlying distribution in null hypothesis. Distribution options are shown in details.

...

further arguments for distribution parameters.

Details

Trapezoid Rule

\int_{a}^{b}xf(x)dx = ∑(a-b)(f(a)+f(b))/2

For more precisely results, set small value of unit which means cut interval(a,b) into small piece.

As for the distribution misspecification,

f_x = f_ydy/dx

where f_y is underlying distribution density function and dy/dx is fhat. Even though f_x in unknown, it is estimable by equation above.

The dist_null indicates the underlying distribution class. The options follow the distributions regular abbreviation in R, Like norm is normal distribution, unif is uniform distribution, gpd is generalized pareto distribution. Distributions for more distribution options.

Value

This function returns the approximated expectation.

Note

To use gpd, package POT https://cran.r-project.org/package=POT needs to be installed first.

Author(s)

Zhicong Zhao

See Also

HRR_pt_est for fhat estimation.

Examples

1
2
3
F_exp(0,1,1000,mean = 0, sd = 1,unit = 1) ## integral on (0,1) by width 1
F_exp(0,1,1000,mean = 0, sd = 1,unit = 0.1) ## integral on (0,1) by width 0.1
F_exp(0,1,1000,mean = 0, sd = 1,unit = 0.01) ## integral on (0,1) by width 0.01

zhicongz/AnomDetct documentation built on Dec. 12, 2019, 9:16 a.m.