logdensity_deriv2: Computation and Plotting the Second Derivative of the...

logdensity_deriv2R Documentation

Computation and Plotting the Second Derivative of the Logarithm of the Log-concave Score Matching Density Estimate

Description

Based on a "LogConcaveDESM" object, evaluates and plots the second derivative of the logarithm of the (penalized) log-concave score matching density estimate.

Usage

evaluate_logdensity_deriv2(scorematching_logconcave, newx)

evaluate_logdensity_deriv2_bounded(scorematching_logconcave, newx)

evaluate_logdensity_deriv2_R(scorematching_logconcave, newx)

evaluate_logdensity_deriv2_ninfb(scorematching_logconcave, newx)

evaluate_logdensity_deriv2_ainf(scorematching_logconcave, newx)

plot_logdensity_deriv2(
  scorematching_logconcave,
  plot_domain,
  plot_points_cnt = 100
)

Arguments

scorematching_logconcave

An object of class "LogConcaveDESM", usually the output of lcd_scorematching or cv_optimal_density_estimate.

newx

A numeric vector of real numbers at which the second derivative of the logarithm of the log-concave score matching density estimate should be evaluated.

plot_domain

A numeric vector to indicate the domain of the plot.

plot_points_cnt

A numeric to indicate the number of points for evaluating and plotting. Default is 100.

Details

The functions evaluate_logdensity_deriv2_bounded, evaluate_logdensity_deriv2_R, evaluate_logdensity_deriv2_ninfb, and evaluate_logdensity_deriv2_ainf evaluates the second derivative of the logarithm of the (penalized) log-concave score matching density estimate at newx when the underlying domain is a bounded interval, the entire real line, an interval of the form (-\infty, b) for some b < \infty, and an interval of the form (a, \infty) for some a > -\infty, respectively. The function evaluate_logdensity_deriv2 encompasses all four cases.

The function plot_logdensity_deriv2 plots the second derivative of the logarithm of the (penalized) log-concave score matching density estimate within the plot_domain.

Value

A data frame with the first column being the sorted newx and the second column being the corresponding second derivative values of the logarithm of the (penalized) log-concave score matching density estimate.

A ggplot2 plot of the second derivative of the logarithm of the (penalized) log-concave score matching density estimate over the specified plot domain.

Examples

set.seed(1119)
N <- 100
data <- rnorm(N)
domain <- c(-5, 5)
result <- lcd_scorematching(data, domain, penalty_param = 1e-1)
# evaluation
evaluate_logdensity_deriv2(scorematching_logconcave = result,
newx = seq(result$domain[1], result$domain[2], 0.01))

# plot
plot_logdensity_deriv2(scorematching_logconcave = result,
plot_domain = result$domain, plot_points_cnt = 500)


zhoucx1119/LogConcaveDESM documentation built on Aug. 28, 2024, 3:25 p.m.