Learn R Programming

logcondens (version 2.1.8)

evaluateLogConDens: Evaluates the Log-Density MLE and Smoothed Estimator at Arbitrary Real Numbers xs

Description

Based on a "dlc" object generated by logConDens, this function computes the values of

$$\widehat \phi_m(t)$$ $$\widehat f_m(t) = \exp(\widehat \phi_m(t))$$ $$\widehat F_m(t) = \int_{x_1}^t \exp(\widehat \phi_m(x)) dx$$ $$\widehat f_m^*(t) = \exp(\widehat \phi_m^*(t))$$ $$\widehat F_m^*(t) = \int_{x_1}^t \exp(\widehat \phi_m^*(x)) dx$$

at all real number \(t\) in xs. The exact formula for \(\widehat F_m\) and \(t \in [x_j,x_{j+1}]\) is

$$\widehat F_m(t) = \widehat F_m(x_j) + (x_{j+1}-x_j) J\Big(\widehat \phi_j, \widehat \phi_{j+1}, \frac{t-x_j}{x_{j+1}-x_j} \Big)$$

for the function \(J\) introduced in Jfunctions. Closed formulas can also be given for \(\widehat f_m^*(t)\) and \(\widehat F_m^*(t)\).

Usage

evaluateLogConDens(xs, res, which = 1:5, gam = NULL, print = FALSE)

Value

Matrix with rows \((x_{0, i}, \widehat \phi_m(x_{0, i}), \widehat f_m(x_{0, i}), \widehat F_m(x_{0, i}), \widehat f_m^*(x_{0, i}), \widehat F_m^*(x_{0, i}))\)

where \(x_{0,i}\) is the \(i\)-th entry of xs.

Arguments

xs

Vector of real numbers where the functions should be evaluated at.

res

An object of class "dlc", usually a result of a call to logConDens.

which

A (sub-)vector of 1:5 specifying which of the above quantities should be computed.

gam

Only necessary if smoothed = TRUE. The standard deviation of the normal kernel. If equal to NULL, gam is chosen such that the variances of the original sample \(x_1, \ldots, x_n\) and \(\widehat f_n^*\) coincide. See logConDens for details.

print

Progress in computation of smooth estimates is shown.

Examples

Run this code
## estimate gamma density
set.seed(1977)
x <- rgamma(200, 2, 1)
res <- logConDens(x, smoothed = TRUE, print = FALSE)

## compute function values at an arbitrary point
xs <- (res$x[100] + res$x[101]) / 2
evaluateLogConDens(xs, res)

## only compute function values for non-smooth estimates
evaluateLogConDens(xs, res, which = 1:3)

Run the code above in your browser using DataLab