# Weighted Portmanteau Test

### Description

Weighted portmanteau tests for testing the null hypothesis of adequate ARMA fit and/or for detecting nonlinear processes. Written in the style of `Box.test()`

and is capable of performing the traditional Box Pierce (1970), Ljung Box (1978) or Monti (1994) tests.

### Usage

1 2 3 4 5 |

### Arguments

`x` |
a numeric vector or univariate time series, or residuals of a fitted time series |

`lag` |
the statistic will be based on |

`type` |
test to be performed, partial matching is used. "Box-Pierce" by default |

`fitdf` |
number of degrees of freedom to be subtracted if |

`sqrd.res` |
A flag, should the series/residuals be squared to detect for nonlinear effects?, FALSE by default |

`log.sqrd.res` |
A flag, should a log of the squared series/residuals be used to detect for nonlinear effects? FALSE by default |

`abs.res` |
A flag, should the absolute series or residuals be used to detect for nonlinear effects? FALSE by default |

`weighted` |
A flag determining if the weighting scheme should be utilized. TRUE by default. If set to FALSE, the traditional test is performed with no weights |

### Details

These test are traditionally applied to a time series for detecting autocorrelation, or to the residuals of an `ARMA(p,q)`

fit to check the adequacy of that fit or to detect nonlinear (i.e. GARCH) effects in the time/residual series. The weighting scheme utilized here is asymptotically similar to the results found in Pena and Rodriguez (2002) and Mahdi and McLeod (2012) (i.e. the `portes`

package).

### Value

A list with class "`htest`

" containing the following components:

`statistic` |
the value of the test statistic |

`parameter` |
The approximate shape and scale parameters for the weighted statistic or degrees of freedom of the chi-squared distribution if the weighted flag is set to false. |

`p.value` |
The p-value of the test |

`method` |
a character string indicating which type of test was performed. |

`data.name` |
a character string giving the name of the data |

### Note

Like the `Box.test()`

function, missing values are not handled

### Author(s)

Thomas J. Fisher

### References

Box, G. E. P. and Pierce, D. A. (1970), Distribution of residual correlations in autoregressive-integrated moving average time series models. Journal of the American Statistical Association, 65, 1509-1526.

Fisher, T. J. and Gallagher, C. M. (2012), New Weighted Portmanteau Statistics for Time Series Goodness-of-Fit Testing. Journal of the American Statistical Association, accepted.

Ljung, G. M. and Box, G. E. P. (1978), On a measure of lack of fit in time series models. Biometrika 65, 297-303.

Mahdi, E. and McLeod, A. I. (2012), Improved multivariate portmanteau test. Journal of Time Series Analysis 65(2), 297-303.

Monti, A. C. (1994), A proposal for a residual autocorrelation test in linear models. Biometrika 81(4), 776-780.

Pena, D. and Rodriguez, J. (2002) A powerful portmanteau test of lack of fit for time series. Journal of the American Statistical Association 97(458), 601-610.

### Examples

1 2 3 4 | ```
set.seed(1)
x <- rnorm(100);
Weighted.Box.test(x, lag=10, type="Ljung");
Weighted.Box.test(x, lag=10, type="Ljung", sqrd.res=TRUE);
``` |