loc_median_fit: Estimate local median fit

Description Usage Arguments Details See Also Examples

View source: R/loc_median_fit.R

Description

This function fits y based on x through a (weighted) median using the npoints/2 neighborhood.

Usage

1
2
3
4
5
6
7
8
loc_median_fit(
  x,
  y,
  fraction = 0.1,
  npoints = max(1, round(length(x) * fraction)),
  weighted = TRUE,
  ignore_zeros = FALSE
)

Arguments

x, y

the x and y coordinates of the points.

fraction, npoints

the fraction / number of the points that are considered for each fit. npoints is the argument that is used in the end it is at least one. Default: fraction = 0.1 and npoints = length(x) * fraction.

weighted

a boolean that indicates if a weighted median is calculated.

ignore_zeros

should the zeros be excluded from the fit

Details

This function is low-level and should usually not be called by the user.

See Also

locfit: a package dedicated to local regression.

Examples

1
2
3
4
5
6
  x <- runif(n = 1000, max = 4)
  y <- rpois(n = 1000, lambda = x * 10)

  plot(x, y)
  fit <- loc_median_fit(x, y, fraction = 0.1)
  points(x, fit, col = "red")

glmGamPoi documentation built on Nov. 8, 2020, 7:14 p.m.