Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

impute.loess

Impute loess


Description

Imputes missing data or smooths using Loess regression

Usage

impute.loess(y, s = 0.2, smooth = FALSE)

Arguments

y

A vector to impute

s

Smoothing parameter ()

smooth

(FALSE/TRUE) Smooth data, else only replace NA's

Details

Performs a local polynomial regression to smooth data or to impute NA values. The minimal number of non-NA observations to reliably impute/smooth values is 6. There is not a reliably way to impute NA's on the tails of the distributions so if the missing data is in the first or last position of the vector it will remain NA. Please note that smooth needs to be TRUE to return a smoothed vector, else only NA's will be imputed.

Value

a vector the same length as x with NA values filled or the data smoothed (or both)..

Author(s)

Jeffrey S. Evans <jeffrey_evans<at>tnc.org>

Examples

data(cor.data)
d <- cor.data[[1]][,2]
  plot(d, type="l")
  lines(impute.loess(d, s=0.3, smooth=TRUE), lwd=2, col="red")
 
# add some NA's
d <- d[1:100]
  d[sample(30:70, 5)] <- NA 
  d
  
impute.loess(d, s=0.2)

spatialEco

Spatial Analysis and Modelling Utilities

v1.3-6
GPL-3
Authors
Jeffrey S. Evans [aut, cre], Melanie A. Murphy [ctb], Karthik Ram [ctb]
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.