Learn R Programming

TSclust (version 1.1)

diss.AR.MAH: Model-based Dissimilarity Proposed by Maharaj (1996, 2000)

Description

Computes the dissimilarity between two time series by testing whether both series are or not generated by the same ARMA model.

Usage

diss.AR.MAH(x, y, dependence=FALSE)

Arguments

x
Numeric vector containing the first of the two time series.
y
Numeric vector containing the second of the two time series.
dependence
Boolean for considering dependence between observations of the series at the same point in time.

Value

  • statisticThe statistic of the homogeneity test.
  • p_valueThe p-value of the homogeneity test.

Details

Assuming that the time series x and y belong to the class of invertible and stationary ARMA processes, this dissimilarity measure is based on checking the equality of their underlying ARMA models by following the testing procedures proposed by Maharaj (1996,2000). The ARMA structures are approximated by truncated AR($\infty$) models with a common order $k = \max{(k_x, k_y)}$, where $k_x$ and $k_y$ are determined by the AIC criterion. The AR coefficients are automatically fitted. The dissimilarity can be evaluated by using the value of the test statistic or alternatively the associated p-value. If dependence=FALSE, the dissimilarity measure is constructed by following the procedure introduced by Maharaj (1996), which is designed to compare independent time series. Otherwise, a more general testing procedure is used (Maharaj, 2000), which assumes that both models are correlated at the same time points but uncorrelated across observations (Maharaj, 2000).

References

Maharaj, E.A. (1996) A significance test for classifying {ARMA} models. J. Statist. Comput. Simulation, 54(4), 305--331. Maharaj E.A. (2000) Clusters of time series. J. Classification, 17(2), 297--314.

See Also

diss.AR.PIC, diss.AR.LPC.CEPS

Examples

Run this code
## Create three sample time series
x <- arima.sim(model=list(ar=c(0.4,-0.1)), n =100, n.start=100)
y <- arima.sim(model=list(ar=c(0.9)), n =100, n.start=100)
z <- arima.sim(model=list(ar=c(0.5, 0.2)), n =100, n.start=100)
## Compute the distance and check for coherent results
diss.AR.MAH(x, y)
diss.AR.MAH(x, z)
diss.AR.MAH(y, z)
#create a function that returns only the statitic 
dissimilarity.MAH.STAT <- function(x,y) {
	diss.AR.MAH(x,y, dependence=TRUE)$statistic
}
#create a dist object for its use with clustering functions like pam or hclust
if (require(proxy)) {
   proxy::dist( rbind(x,y,z), dissimilarity.MAH.STAT)
}

Run the code above in your browser using DataLab