# localProjection: Time series denoising via a local projection filtering... In fractal: A Fractal Time Series Modeling and Analysis Package

## Description

Given a time series, X[t], this function performs one iteration of the local projection filtering algorithm as described in Kantz and Schreiber . This noise reduction algorithm is summarized in the following steps:

1.

A time lag embedding of dimension dimension is formed using X[t], where dimension is typically at least twice the dimension at which the underlying dynamics of X[t] become deterministic. At each point in the embedding a neighborhood is determined by a given radius and a given minimum number of required neighbors.

2.

Center-of-mass vectors are computed for each embedding point neighborhood and corresponding covariance matrices are computed with respect to the center-of-maxx vectors.

3.

The eigenvectors corresponding to the noise.dimension smallest eigenvalues are assumed to form a (local) basis for the noise subspace and the projection of the embedding vector onto these "noise" eigenvectors is subtracted from the original embedding vector.

4.

The components of the corrected embedding vectors are averaged to compute the overall correction for each point in the original time series.

## Usage

 ```1 2``` ```localProjection(x, dimension=3, tlag=timeLag(x), n.neighbor=dimension + 1, max.distance=2*stdev(x), metric=Inf, noise.dimension=1, corr.curve=TRUE) ```

## Arguments

 `x` a vector containing a uniformly-sampled real-valued time series. `corr.curve` boolean argument. If true, the center-of-mass vectors will be corrected for curvature effects. Default: `TRUE`. `dimension` the dimension of the time lag embedding created from the given time series. This value should be at least twice the dimension in which the underlying dynamics of the time series become deterministic. Default: `3`. `max.distance` the neighbor search for each embedding point finds all neighbors within max.distance. Default: `2*stdev(x)`. `metric` the metric used when searching for neighbors. Supported values are 1 (1-norm), 2 (2-norm), and Inf (infinity norm). Default: `Inf`. `n.neighbor` the minimum number of neighbors acceptable to define a neighborhood for each embedding point. If the neighbor search using input max.distance does not produce at least this number of neighbors a new search is performed which finds exactly n.neighbor neighbors. Default: `dimension + 1`. `noise.dimension` the assumed dimension of the (local) noise subspace. This should be equal to the embedding dimension, dimension, minus the dimension where the underlying dynamics of the time series become deterministic. Default: `1`. `tlag` the time lag used when creating the time lag embedding. Default: `1`.

## Value

the resulting denoised time series, a vector the same length as the original time series.

## References

Holger Kantz and Thomas Schreiber (1997), Nonlinear Time Series Analysis, Cambridge University Press.

`embedSeries`, `medianFilter`, `timeLag`, `FNN`.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```## Not run: x <- beamchaos@data x <- x - mean(x) sigma <- stdev(x) xnoise <- x + rnorm(length(x)) * sigma / 3 xclean <- localProjection(xnoise, dimension=7, noise.dimension=5, max.distance=3*sigma, n.neighbor=100) y <- data.frame(xclean, xnoise, x) stackPlot(x=positions(beamchaos)[], y=y, ylab=c("denoised","noisy","original"), ylim=range(y)) ## End(Not run) ```