l1tf: L1 trend filteirng

View source: R/l1tf.R

l1tfR Documentation

L1 trend filteirng

Description

L1 trend filteirng

Usage

l1tf(x, lambda, prop = 0.1, debug = FALSE)

Arguments

x

Numeric vector of inputs. Must be equally spaced in time.

lambda

A number that controls the balance between accuracy and simplicity. Small values favour accuracy; large values favour simplicity.

prop

A number between 0 and 1. Specify lambda as a proportion of the maximum lambda for the input dataset.

debug

If TRUE will print details about each iteration.

Examples

x <- runif(1000)

plot(x)
lines(l1tf(x), col = "red")
lines(l1tf(x, prop = 0.01), col = "blue")

# SP500 example from paper
plot(sp500$date, log(sp500$raw), type="l", col="grey50", ylab="log-price")
lines(sp500$date, l1tf(log(sp500$raw), lambda=100), col="blue")

hadley/l1tf documentation built on April 2, 2024, 3:16 p.m.