reflect.data {snfa} | R Documentation |
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
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))
[Package snfa version 0.0.1 Index]