# diss.SPEC.GLK: Dissimilarity based on the Generalized Likelihood Ratio Test In TSclust: Time Series Clustering Utilities

## Description

The dissimilarity between two time series is computed by using an adaptation of the generalized likelihood ratio test to check the equality of two log-spectra.

## Usage

 `1` ```diss.SPEC.GLK(x, y, plot=FALSE) ```

## Arguments

 `x` Numeric vector containing the first of the two time series. `y` Numeric vector containing the second of the two time series. `plot` If `TRUE`, the smoothed spectral densities of the two series are plotted.

## Details

The dissimilarity between two series `x` and `y` is measured in terms of the vaue of a test statistic to check the equality of their log-spectra, m_X(λ) and m_Y(λ) respectivelty. The test statistic is constructed by using the generalized likelihood ratio test criterion (Fan and Zhang, 2004). Specifically, the test statistic takes the form:

d(x,y) = ∑[Z_k - hatμ(λ_k) - 2 \log( 1 + exp(Z_k - hatμ(λ_k))] - ∑[ Z_k -2 \log(1+ exp(Z_k))] | k=1 to T,

where I_x(λ_k) and I_y(λ_k) are the periodograms of `x` and `y`, Z_k = \log(I_x(λ_k)) - \log( I_y(λ_k)), and hatμ(λ_k) is the local maximum log-likelihood estimator of μ(λ_k)= m_x(λ_k) - m_y(λ_k) computed by local linear fitting.

## Value

The computed distance.

## Author(s)

Pablo Montero Manso, José Antonio Vilar.

## References

Fan, J. and Zhang, W. (2004) Generalised likelihood ratio tests for spectral density. Biometrika, 195–209.

Pértega, S. and Vilar, J.A. (2010) Comparing several parametric and nonparametric approaches to time series clustering: A simulation study. J. Classification, 27(3), 333–362.

Montero, P and Vilar, J.A. (2014) TSclust: An R Package for Time Series Clustering. Journal of Statistical Software, 62(1), 1-43. http://www.jstatsoft.org/v62/i01/.

`diss.SPEC.ISD`, `diss.SPEC.LLR`
 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```## Create two sample time series x <- cumsum(rnorm(50)) y <- cumsum(rnorm(50)) z <- sin(seq(0, pi, length.out=50)) ## Compute the distance and check for coherent results diss.SPEC.GLK(x, y, plot=TRUE) #create a dist object for its use with clustering functions like pam or hclust ## Not run: diss( rbind(x,y,z), "SPEC.GLK" ) ## End(Not run) ```