reflect.data: Data reflection for kernel smoothing

Description Usage Arguments Value Examples

View source: R/reflect.data.R

Description

This function reflects data below minimum and above maximum for use in reducing endpoint bias in kernel smoothing.

Usage

1

Arguments

X

Matrix of inputs

y

Vector of outputs

Value

Returns a list with the following elements

X.reflected

Reflected values of X

y.reflected

Reflected values of y

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
data(univariate)

# Extract data
X <- as.matrix(univariate$x)
y <- univariate$y

# Reflect data
reflected.data <- reflect.data(X, y)

X.reflected <- reflected.data$X
y.reflected <- reflected.data$y

# Plot
library(ggplot2)

plot.df <- data.frame(X = X.reflected,
                      y = y.reflected,
                      data = rep(c("reflected", "actual", "reflected"), each = nrow(X)))

ggplot(plot.df, aes(X, y)) +
  geom_point(aes(color = data))

tkmckenzie/snfa documentation built on June 11, 2020, 4:34 a.m.