# Create functional data with different outlier types
set.seed(42)
t <- seq(0, 1, length.out = 50)
X <- matrix(0, 32, 50)
for (i in 1:29) X[i, ] <- sin(2 * pi * t) + rnorm(50, sd = 0.2)
X[30, ] <- sin(2 * pi * t) + 2 # magnitude outlier (high)
X[31, ] <- sin(2 * pi * t) - 2 # magnitude outlier (low)
X[32, ] <- sin(4 * pi * t) # shape outlier
fd <- fdata(X, argvals = t)
# Create outliergram
og <- outliergram(fd)
print(og)
plot(og, color_by_type = TRUE)
Run the code above in your browser using DataLab