# diss.AR.MAH

##### Model-based Dissimilarity Proposed by Maharaj (1996, 2000)

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, permissive=TRUE)`

##### 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.

- permissive
Boolean for continuing with the method even if no valid order is selected by AIC.

##### 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`

is `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).
When `permissive`

argument is `TRUE`

, if the automatic fitting of the AR order fails, the method shows a warning and then forces an AR of order 1. If `permissive`

is `FALSE`

the method produces an error if no AR order is found by AIC.

##### Value

The statistic of the homogeneity test.

The p-value of the homogeneity test.

%% ~Describe the value returned %% If it is a LIST, use %% \item{comp1 }{Description of 'comp1'} %% \item{comp2 }{Description of 'comp2'} %% ...

##### 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.

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/.

##### See Also

##### Examples

```
# NOT RUN {
## 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 dist object for its use with clustering functions like pam or hclust
diss( rbind(x,y,z), "AR.MAH")$statistic
# }
```

*Documentation reproduced from package TSclust, version 1.2.4, License: GPL-2*