densprf: Density Estimation Function

View source: R/densprf.R

densprfR Documentation

Density Estimation Function

Description

This function estimates the density using a Poisson GLM with natural splines.

Usage

densprf(
  x,
  n.interval = NULL,
  df = 5,
  knots.mode = TRUE,
  type.nclass = c("wand", "scott", "FD"),
  addx = FALSE
)

Arguments

x

Input data vector.

n.interval

Number of intervals (optional).

df

Degrees of freedom for the splines.

knots.mode

Boolean to determine if quantiles should be used for knots.

type.nclass

Method for determining number of classes.

addx

Add x values (optional).

Details

densprf is a modification of the denspr function from the siggenes package.

For more details, see the documentation in the siggenes package.

Value

The function densprf(x) returns a function that, for a given input z, computes the estimated density evaluated at the position values of z as a result.

Examples

# Set seed for reproducibility
set.seed(123)

# Generate random data
z <- rnorm(1000)

# Apply densprf function
f <- densprf(z)

# Define sequences for evaluation
x1 <- seq(-4, 4, 0.5)
x2 <- seq(-5, 5, 0.1)

# Evaluate the density function at specified points
f1 <- f(x1)
f2 <- f(x2)

NPFD documentation built on Nov. 4, 2024, 5:07 p.m.