plot_mle_scorematching: Plotting the Log-concave Maximum Likelihood and Score...

View source: R/plot_mle_scorematching.R

plot_mle_scorematchingR Documentation

Plotting the Log-concave Maximum Likelihood and Score Matching Density Estimates

Description

Plots the log-concave maximum likelihood and (penalized) score matching density estimates together.

Usage

plot_mle_scorematching(
  scorematching_logconcave,
  plot_domain,
  smoothed = FALSE,
  plot_log = FALSE,
  plot_points_cnt = 100,
  minus_const = 0,
  plot_hist = FALSE,
  hist_binwidth = NULL,
  hist_alpha = 0.2
)

Arguments

scorematching_logconcave

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

plot_domain

A numeric vector to indicate the domain of the plot.

smoothed

A logical value to indicate whether to compute the smoothed log-concave maximum likelihood density estimate. Default is FALSE.

plot_log

A logical value to indicate whether to plot the density estimate in the log scale. Default is FALSE.

plot_points_cnt

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

minus_const

A numeric to be subtracted in the exponent to ensure the finite-ness of the integration result. Default is 0.

plot_hist

A logical value to indicate whether to the histogram. Default is FALSE.

hist_binwidth

A numeric to indicate the bin width parameter in plotting the histogram; only works when plot_hist == TRUE. Default is NULL, under which condition the Freedman-Diaconis rule is used.

hist_alpha

A numeric to indicate the opacity in plotting the histogram; must range from 0 to 1, inclusively; only works when plot_hist == TRUE. Default is 0.2.

Value

A ggplot2 plot of the log-concave maximum likelihood and (penalized) score matching density estimates over the specified plot_domain.

See Also

logcondens

Examples

set.seed(1119)
N <- 100
data <- rnorm(N)
domain <- c(-5, 5)
result <- lcd_scorematching(data, domain, penalty_param = 1e-1)

plot_mle_scorematching(result, result$domain, plot_points_cnt = 500,
plot_hist = TRUE)


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