Skip to contents

Converts a numeric field or fitted smoother/regression object into a probability mass vector over the evaluation support. This is the explicit adapter between ordinary smoothers such as fit.lps, fit.ps.lps, and fit.metric.graph.lowpass and density or occupation-density workflows.

Usage

normalize.density(x, ...)

# S3 method for class 'numeric'
normalize.density(
  x,
  X = NULL,
  density.control = list(),
  method.id = "normalized_numeric",
  keep.source.fit = FALSE,
  adj.list = NULL,
  empirical.rho = NULL,
  return.details = TRUE,
  ...
)

# Default S3 method
normalize.density(
  x,
  X = NULL,
  density.control = list(),
  method.id = NULL,
  keep.source.fit = TRUE,
  adj.list = NULL,
  empirical.rho = NULL,
  return.details = TRUE,
  ...
)

# S3 method for class 'lps'
normalize.density(
  x,
  X = NULL,
  density.control = list(),
  method.id = NULL,
  keep.source.fit = TRUE,
  adj.list = NULL,
  empirical.rho = NULL,
  return.details = TRUE,
  ...
)

# S3 method for class 'ps_lps'
normalize.density(
  x,
  X = NULL,
  density.control = list(),
  method.id = NULL,
  keep.source.fit = TRUE,
  adj.list = NULL,
  empirical.rho = NULL,
  return.details = TRUE,
  ...
)

# S3 method for class 'metric.graph.lowpass.fit'
normalize.density(
  x,
  X = NULL,
  density.control = list(),
  method.id = NULL,
  keep.source.fit = TRUE,
  adj.list = NULL,
  empirical.rho = NULL,
  return.details = TRUE,
  ...
)

# S3 method for class 'metric.graph.lowpass.refit'
normalize.density(
  x,
  X = NULL,
  density.control = list(),
  method.id = NULL,
  keep.source.fit = TRUE,
  adj.list = NULL,
  empirical.rho = NULL,
  return.details = TRUE,
  ...
)

Arguments

x

Numeric vector or fitted object with a fitted.values field.

...

Additional arguments passed to methods.

X

Optional support/evaluation matrix. If omitted, methods use the fitted object's stored X.eval or X field when available; for a bare numeric vector, a one-dimensional index support is used.

density.control

List controlling clipping, normalization, and accounting checks. See fit.density.

method.id

Character method identifier recorded in the returned object.

keep.source.fit

Logical; if TRUE, retain the source fit in diagnostics for object methods.

adj.list

Optional adjacency list used to compute graph-local smoothness diagnostics for the normalized density.

empirical.rho

Optional empirical probability mass vector used for accounting diagnostics.

return.details

Logical; if TRUE, keep diagnostic details in the result.

Value

A list of class "density_fit".

Examples

normalize.density(c(0.5, -0.1, 0.6, 0), X = matrix(1:4, ncol = 1))
#> Probability mass 
#>   Training rows: NA ; evaluation rows: 4 ; responses: 1 
#>   Observed responses: NA ; nonfinite fitted entries: 0 
#>   Output: ok 
#>   Convergence: unavailable (no stored stopping certificate) 
#>   Total mass: 1 ; positive support: 2 
#>   Accounting: mass=1.000e+00, min.rho=0.000e+00, max.rho=5.455e-01,
#>     raw.mass=1.000e+00, neg.mass=1.000e-01, clip.mass=1.000e-01,
#>     normalization.constant=1.100e+00, mass.tol=1.000e-08, neg.tol=1.000e-12 
#>   Prediction scope: mass on the stored support