logdensity_deriv1: Computation and Plotting the First Derivative of the...

logdensity_deriv1R Documentation

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

Description

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

Usage

evaluate_logdensity_deriv1(scorematching_logconcave, newx)

evaluate_logdensity_deriv1_bounded(scorematching_logconcave, newx)

evaluate_logdensity_deriv1_R(scorematching_logconcave, newx)

evaluate_logdensity_deriv1_ninfb(scorematching_logconcave, newx)

evaluate_logdensity_deriv1_ainf(scorematching_logconcave, newx)

plot_logdensity_deriv1(
  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 first derivative of the logarithm of the (penalized) log-concave score matching density estimate should be evaluated.

#' @details The functions evaluate_logdensity_deriv1_bounded, evaluate_logdensity_deriv1_R, evaluate_logdensity_deriv1_ninfb, and evaluate_logdensity_deriv1_ainf evaluates the first 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_deriv1 plots the first derivative of the logarithm of the (penalized) log-concave score matching density estimate within the plot_domain.

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.

Value

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

A ggplot2 plot of the first 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-10)
# evaluationn
evaluate_logdensity_deriv1(scorematching_logconcave = result,
newx = seq(result$domain[1], result$domain[2], 0.01))

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


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