simple_loess: Simplified Local Polynomial Regression Fitting

Description Usage Arguments Value Examples

View source: R/simple_loess.R

Description

A simplified interface to the loess and predict.loess combo.

Usage

1
2
3
4
5
6
7
8
simple_loess(...)

## Default S3 method:
simple_loess(y, x = seq_along(y), xout = sort(x),
  span = 0.75, periodic = FALSE, ...)

## S3 method for class 'data.frame'
simple_loess(df, xout = sort(df[, 1]), ...)

Arguments

...

further arguments passed to loess

y

the response values to be regressed

x

the regressor, by default an integer sequence along y

xout

values used for prediction, unless it is an integer of length 1. In that case xout specifies the number of equally spaced values on the interval of x to be used. By default the same as x

span

parameter controlling the degree of smoothing

periodic

should the input be treated as periodic?

df

a data.frame with x-values in the first column and y-vlues in the second

Value

A data.frame with columns xout and y.predicted

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Simple equally spaced vector
h <- c(-0.63, 0.2, -0.44, 1.6, 0.33, -0.74, -0.82, 0.29, 0.74, 0.58, -0.3)

plot(h)
lines(simple_loess(h))

# More complicated unequally space x-values
x <- c(4, 3, 2, 5, 6, 7, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19)
y <- c(3, 2, 4, 5, 6, 5, 5, 3, 4, 7, 10, 10, 8, 9, 7, 8)

plot(x, y)
lines(simple_loess(y, x), col="gray40")
points(simple_loess(y=y, x=x, xout=5L), col=2, cex=2)
points(simple_loess(y=y, x=x, xout=17), col=3, cex=2)
points(simple_loess(y=y, x=x, xout=seq(8, 12, 0.3)), col=3, pch=16)
lines(simple_loess(y=y, x=x, xout=50L), col=4, lty=2)

# data.frame input
dtf <- data.frame(x, y)
simple_loess(dtf)

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.