Local Linear Regression

A bare-bones implementation of local linear regression, using high-level functions. Can handle both numerical and non-numerical (factor) variables. See Loader (1999) , ch2, or Hastie et al (2009) , ch6. The package also contains a scale_df() function which only scales the numeric variables in a dataframe.


loclm

A bare-bones implementation of local linear regression, using high-level functions. Can handle both numerical and non-numerical (factor) variables. Non-numerical regressors are converted to factors.

Installation

You can install the current version of loclm like so:

install.packages("loclm") # once only

Example

## local linear fit for the stack-loss data

library(loclm)

x <- stack.x
y <- stack.loss
fit <- loclm(x, y, span = 0.5)
yhat <- fitted(fit)

See the help file ?loclm for more examples.

Versions

1.1.0 Improvements for speed:

  • new function x2m() to replace calls to scale_df() and model.matrix().

  • new function LOO_loclm() to do leave-one-out more efficiently.

  • option of parallel predict using the 'future.apply' package.

  • faster inline implementation of sweep().

  • other small tidy-ups of the code and vignette.

  • scale_df() is no longer used, but retained for backward compatibility.

1.0.0. Initial version, submitted Aug 2026. Three functions:

  • loclm() : local linear regression

  • predict(), fitted(), residuals(), hatvalues() : S3 regression methods.

  • scale_df() : scale numeric variables in a data.frame.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("loclm")

1.1.0 by Jonathan Rougier, 15 days ago


Browse source code at https://github.com/cran/loclm


Authors: Jonathan Rougier [aut, cre] (ORCID:


Documentation:   PDF Manual  


GPL (>= 3) license


Imports future.apply, stats

Suggests future, knitr, rmarkdown, testthat


See at CRAN