Learn R Programming

snfa (version 0.0.1)

reflect.data: Data reflection for kernel smoothing

Description

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

Usage

reflect.data(X, y)

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

Run this code
# NOT RUN {
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))

# }

Run the code above in your browser using DataLab