ani_density_penalty: Building an animation to view the effects of the penalty...

View source: R/ani_density_penalty.R

ani_density_penaltyR Documentation

Building an animation to view the effects of the penalty parameter on density estimates

Description

Creates an animation to visualize how different penalty parameters can affect the density estimates. The resulting animation shows the density estimates with increasing values of the penalty parameters.

Usage

ani_density_penalty(
  data,
  domain,
  penalty_params_seq,
  plot_domain,
  plot_points_cnt = 100
)

Arguments

data

A numeric vector whose log-concave density function is to be estimated; missing values are automatically removed.

domain

A numeric vector of length 2 specifying the left and right endpoints of the bounded domain; its components cannot be NA, NULL, or NaN.

penalty_params_seq

Penalty parameter for computing the density estimate; must be non-negative.

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 list of plots with multiple layers for creating the animation. To view the resulting animation, please use gganimate::animate(anim, renderer = gganimate::gifski_renderer()).

Examples

library(transformr)
data <- rnorm(200)
domain <- c(-5, 5)
penalty_params_seq <- c(0, exp(seq(-10, 1, length.out = 20)))
anim <- ani_density_penalty(
data = data,
domain = domain,
penalty_params_seq = penalty_params_seq,
plot_domain = domain,
plot_points_cnt = 500)

gganimate::animate(anim, renderer = gganimate::gifski_renderer())



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