¿Cuántos rezagos usar en la prueba de Ljung-Box de una serie de tiempo?

20

Después de que un modelo ARMA se ajusta a una serie temporal, es común verificar los residuos a través de la prueba Ljung-Box portmanteau (entre otras pruebas). La prueba de Ljung-Box devuelve un valor p. Tiene un parámetro, h , que es el número de retrasos que se probarán. Algunos textos recomiendan usar h = 20; otros recomiendan usar h = ln (n); la mayoría no dice qué h usar.

En lugar de usar un solo valor para h , supongamos que hago la prueba de Ljung-Box para todo h <50, y luego elijo la h que da el valor p mínimo. ¿Es razonable ese enfoque? ¿Cuáles son las ventajas y desventajas? (Una desventaja obvia es el aumento del tiempo de cómputo, pero eso no es un problema aquí.) ¿Existe literatura sobre esto?

Para elaborar un poco .... Si la prueba da p> 0.05 para toda h , entonces obviamente las series de tiempo (residuales) pasan la prueba. Mi pregunta se refiere a cómo interpretar la prueba si p <0.05 para algunos valores de h y no para otros valores.

usuario2875
fuente
1
@ user2875, he eliminado mi respuesta. El hecho es que para grande la prueba no es confiable. Entonces la respuesta realmente depende de qué , . Además, ¿cuál es el valor exacto de ? Si disminuimos el umbral a , ¿cambia el resultado de la prueba? Personalmente, en caso de hipótesis en conflicto, busco otros indicadores si el modelo es bueno o no. ¿Qué tan bien se ajusta el modelo? ¿Cómo se compara el modelo con modelos alternativos? ¿El modelo alternativo tiene los mismos problemas? ¿Para qué otras violaciones la prueba rechaza el nulo? hhpag<0,05pag0,01
mpiktas
1
@mpiktas, la prueba de Ljung-Box se basa en una estadística cuya distribución es asintóticamente (a medida que h se hace grande) chi-cuadrado. Sin embargo, a medida que h aumenta en relación con n, el poder de la prueba disminuye a 0. De ahí el deseo de elegir h lo suficientemente grande como para que la distribución sea cercana al chi-cuadrado pero lo suficientemente pequeña como para tener un poder útil. (No sé cuál es el riesgo de un falso negativo, cuando h es pequeño.)
user2875
@ user2875, esta es la tercera vez que cambia la pregunta. Primero pregunta sobre la estrategia de elegir con el valor más pequeño, luego cómo interpretar la prueba si para algunos valores de , y ahora cuál es la óptima para elegir. Las tres preguntas tienen respuestas diferentes e incluso pueden tener respuestas diferentes según el contexto del problema particular. p < 0.05 h hhp<0.05hh
mpiktas
@mpiktas, las preguntas son todas iguales, solo diferentes formas de verlo. (Como se señaló, si p> 0.05 para toda h, entonces sabemos cómo interpretar la p más pequeña; si supiéramos la h óptima, no lo sabemos, entonces no estaríamos interesados ​​en elegir la p más pequeña).
user2875

Respuestas:

9

La respuesta definitivamente depende de: ¿Para qué están tratando de usar la prueba ?Q

La razón común es: tener más o menos confianza en la significación estadística conjunta de la hipótesis nula de no autocorrelación hasta el retraso (alternativamente, suponiendo que tiene algo cercano a un ruido blanco débil ) y construir un modelo parsimonioso , teniendo tan poco Número de parámetros como sea posible.h

Por lo general, los datos de series temporales tienen un patrón estacional natural, por lo que la regla práctica sería establecer al doble de este valor. Otro es el horizonte de pronóstico, si usa el modelo para las necesidades de pronóstico. Finalmente, si encuentra algunas desviaciones significativas en los últimos rezagos, trate de pensar en las correcciones (esto podría deberse a algunos efectos estacionales, o los datos no se corrigieron por valores atípicos).h

En lugar de usar un solo valor para h, supongamos que hago la prueba de Ljung-Box para todo h <50, y luego elijo h que da el valor p mínimo.

Es una prueba de significación conjunta , por lo que si la elección de depende de los datos, ¿por qué debería preocuparme por algunas pequeñas desviaciones (ocasionales?) En cualquier retraso menor que h , suponiendo que es mucho menor que n, por supuesto (el poder de la prueba que mencionaste). Buscando encontrar un modelo simple pero relevante, sugiero los criterios de información como se describe a continuación.hhn

Mi pregunta se refiere a cómo interpretar la prueba si para algunos valores de h y no para otros valores.p<0.05h

Por lo tanto, dependerá de cuán lejos del presente ocurra. Desventajas de desviaciones lejanas: más parámetros para estimar, menos grados de libertad, peor poder predictivo del modelo.

Intente estimar el modelo, incluidas las partes MA y \ o AR en el retraso donde se produce la partida Y, además, observe uno de los criterios de información (ya sea AIC o BIC, dependiendo del tamaño de la muestra), esto le brindará más información sobre qué modelo es más parsimonioso. Cualquier ejercicio de predicción fuera de la muestra también es bienvenido aquí.

Dmitrij Celov
fuente
+1, esto es lo que intentaba expresar pero no podía :)
mpiktas
8

Supongamos que especificamos un modelo AR (1) simple, con todas las propiedades habituales,

yt=βyt-1+tut

Denote la covarianza teórica del término de error como

γjmi(tuttut-j)

Si pudiéramos observar el término de error, entonces la muestra de autocorrelación del término de error se define como

ρ~jγ~jγ~0 0

dónde

γ~j1nt=j+1nututj,j=0,1,2 ...

Pero en la práctica, no observamos el término de error. Por lo tanto, la muestra de autocorrelación relacionada con el término de error se estimará utilizando los residuos de la estimación, como

γ^j1nt=j+1nu^tu^tj,j=0,1,2...

La estadística Q de Box-Pierce (la Ljung-Box Q es solo una versión asintóticamente neutra a escala)

QBP=nj=1pρ^j2=j=1p[nρ^j]2d???χ2(p)

Nuestro problema es exactamente si se puede decir que tiene asintóticamente una distribución de chi-cuadrado (bajo el nulo de no autocorellación en el término de error) en este modelo. Para que esto suceda, todos y cada uno de QBP
debe ser asintóticamente estándar normal. Una forma de verificar esto es examinar sinρ^j tiene la misma distribución asintótica comonρ^ (que se construye utilizando los errores verdaderos, y también tiene el comportamiento asintótico deseado bajo nulo).nρ~

Tenemos eso

tu^t=yt-β^yt-1=tut-(β^-β)yt-1

donde β es un estimador consistente. Entoncesβ^

γ^j1nt=j+1n[ut(β^β)yt1][utj(β^β)ytj1]

=γ~j1nt=j+1n(β^β)[utytj1+utjyt1]+1nt=j+1n(β^β)2yt1ytj1

Se supone que la muestra es estacionaria y ergódica, y se supone que existen momentos hasta el orden deseado. Puesto que el estimador de β es consistente, esto es suficiente para las dos sumas para ir a cero. Entonces concluimosβ^

γ^jpγ~j

Esto implica que

ρ^jpρ~jpρj

Pero esto no garantiza automáticamente que converge a nρ^jnρ~j(en distribución) (piense que el teorema de mapeo continuo no se aplica aquí porque la transformación aplicada a las variables aleatorias depende de). Para que esto suceda, necesitamosn

nγ^jdnγ~j

(el denominador -tilde o hat- convergerá con la varianza del término de error en ambos casos, por lo que es neutral para nuestro problema).γ0

Tenemos

nγ^j=nγ~j1nt=j+1nn(β^β)[utytj1+utjyt1]+1nt=j+1nn(β^β)2yt1ytj1

Entonces la pregunta es: ¿estas dos sumas, multiplicadas ahora por , ir a cero en probabilidad para que nos quedemos connasintóticamente?nγ^j=nγ~j

Para la segunda suma tenemos

1nt=j+1nn(β^β)2yt1ytj1=1nt=j+1n[n(β^β)][(β^β)yt1ytj1]

Since [n(β^β)] converges to a random variable, and β^ is consistent, this will go to zero.

For the first sum, here too we have that [n(β^β)] converges to a random variable, and so we have that

1nt=j+1n[utytj1+utjyt1]pE[utytj1]+E[utjyt1]

The first expected value, E[utytj1] is zero by the assumptions of the standard AR(1) model. But the second expected value is not, since the dependent variable depends on past errors.

So nρ^j won't have the same asymptotic distribution as nρ~j. But the asymptotic distribution of the latter is standard Normal, which is the one leading to a chi-squared distribution when squaring the r.v.

Therefore we conclude, that in a pure time series model, the Box-Pierce Q and the Ljung-Box Q statistic cannot be said to have an asymptotic chi-square distribution, so the test loses its asymptotic justification.

This happens because the right-hand side variable (here the lag of the dependent variable) by design is not strictly exogenous to the error term, and we have found that such strict exogeneity is required for the BP/LB Q-statistic to have the postulated asymptotic distribution.

Here the right-hand-side variable is only "predetermined", and the Breusch-Pagan test is then valid. (for the full set of conditions required for an asymptotically valid test, see Hayashi 2000, p. 146-149).

Alecos Papadopoulos
fuente
1
You wrote "But the second expected value is not, since the dependent variable depends on past errors." That's called strict exogeneity. I agree that it's a strong assumption, and you can build AR(p) framework without it, just by using weak exogeneity. This the reason why Breusch-Godfrey test is better in some sense: if the null is not true, then B-L loses power. B-G is based on weak exogeneity. Both tests are not good for some common econometric, applications, see e.g. this Stata's presentation, p. 4/44.
Aksakal
3
@Aksakal Thanks for the reference. The point exactly is that without strict exogeneity, the Box-Pierce/Ljung-Box do not have an asymptotic chi-square distribution, this is what the mathematics above show. Weak exogeneity (which holds in the above model) is not enough for them. This is exactly what the presentation you link to says in p. 3/44.
Alecos Papadopoulos
2
@AlecosPapadopoulos, an amazing post!!! Among the few best ones I have encountered here at Cross Validated. I just wish it would not disappear in this long thread and many users would find and benefit from it in the future.
Richard Hardy
3

Before you zero-in on the "right" h (which appears to be more of an opinion than a hard rule), make sure the "lag" is correctly defined.

http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm

Quoting the section below Issue 4 in the above link:

"....The p-values shown for the Ljung-Box statistic plot are incorrect because the degrees of freedom used to calculate the p-values are lag instead of lag - (p+q). That is, the procedure being used does NOT take into account the fact that the residuals are from a fitted model. And YES, at least one R core developer knows this...."

Edit (01/23/2011): Here's an article by Burns that might help:

http://lib.stat.cmu.edu/S/Spoetry/Working/ljungbox.pdf

bill_080
fuente
@ bil_080, el OP no menciona R, y la página de ayuda para Box.test en R menciona la corrección y tiene un argumento para permitir la corrección, aunque debe proporcionarla manualmente.
mpiktas
@mpiktas, Oops, you're right. I assumed this was an R question. As for the second part of your comment, there are several R packages that use Ljung-Box stats. So, it's a good idea to make sure the user understands what the package's "lag" means.
bill_080
Thanks--I am using R, but the question is a general one. Just to be safe, I was doing the test with the LjungBox function in the portes package, as well as Box.test.
user2875
2

The thread "Testing for autocorrelation: Ljung-Box versus Breusch-Godfrey" shows that the Ljung-Box test is essentially inapplicable in the case of an autoregressive model. It also shows that Breusch-Godfrey test should be used instead. That limits the relevance of your question and the answers (although the answers may include some generally good points).

Richard Hardy
fuente
The trouble with LB test is when autoregressive models have other regressors, i.e. ARMAX not ARM models. OP explicitly states ARMA not ARMAX in the question. Hence, I think that your answer is incorrect.
Aksakal
@Aksakal, I clearly see from Alecos Papadopoulos answer (and comments under it) in the above-mentioned thread that Ljung-Box test is inapplicable in both cases, i.e. pure AR/ARMA and ARX/ARMAX. Therefore, I cannot agree with you.
Richard Hardy
Alecos Papadopoulos's answer is good, but incomplete. It points out to Ljung-Box test's assumption of strict exogeneity but it fails to mention that if you're fine with the assumption, then L-B test is Ok to use. B-G test, which he and I favor over L-B, relies on weak exogeneity. It's better to use tests with weaker assumptions in general, of course. However, even B-G test's assumptions are too strong in many cases.
Aksakal
@Aksakal, The setting of this question is quite definite -- it considers residuals from an ARMA model. The important thing here is, L-B does not work (as shown explicitly in Alecos post in this as well as the above-cited thread) while B-G test does work. Of course, things can happen in other settings (even B-G test's assumptions are too strong in many cases) -- but that is not the concern in this thread. Also, I did not get what the assumption is in your statement if you're fine with the assumption, then L-B test is Ok to use. Is that supposed to invalidate Alecos point?
Richard Hardy
1

Escanciano and Lobato constructed a portmanteau test with automatic, data-driven lag selection based on the Pierce-Box test and its refinements (which include the Ljung-Box test).

The gist of their approach is to combine the AIC and BIC criteria --- common in the identification and estimation of ARMA models --- to select the optimal number of lags to be used. In the introduction of they suggest that, intuitively, ``test conducted using the BIC criterion are able to properly control for type I error and are more powerful when serial correlation is present in the first order''. Instead, tests based on AIC are more powerful against high order serial correlation. Their procedure thus choses a BIC-type lag selection in the case that autocorrelations seem to be small and present only at low order, and an AIC-type lag section otherwise.

The test is implemented in the R package vrtest (see function Auto.Q).

Ryogi
fuente
1

The two most common settings are min(20,T1) and lnT where T is the length of the series, as you correctly noted.

The first one is supposed to be from the authorative book by Box, Jenkins, and Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.. However, here's all they say about the lags on p.314: ingrese la descripción de la imagen aquí

It's not a strong argument or suggestion by any means, yet people keep repeating it from one place to another.

The second setting for a lag is from Tsay, R. S. Analysis of Financial Time Series. 2nd Ed. Hoboken, NJ: John Wiley & Sons, Inc., 2005, here's what he wrote on p.33:

Several values of m are often used. Simulation studies suggest that the choice of m ≈ ln(T ) provides better power performance.

This is a somewhat stronger argument, but there's no description of what kind of study was done. So, I wouldn't take it at a face value. He also warns about seasonality:

This general rule needs modification in analysis of seasonal time series for which autocorrelations with lags at multiples of the seasonality are more important.

Summarizing, if you just need to plug some lag into the test and move on, then you can use either of these setting, and that's fine, because that's what most practitioners do. We're either lazy or, more likely, don't have time for this stuff. Otherwise, you'd have to conduct your own research on the power and properties of the statistics for series that you deal with.

UPDATE.

Here's my answer to Richard Hardy's comment and his answer, which refers to another thread on CV started by him. You can see that the exposition in the accepted (by Richerd Hardy himself) answer in that thread is clearly based on ARMAX model, i.e. the model with exogenous regressors xt:

yt=xtβ+ϕ(L)yt+ut

However, OP did not indicate that he's doing ARMAX, to contrary, he explicitly mentions ARMA:

After an ARMA model is fit to a time series, it is common to check the residuals via the Ljung-Box portmanteau test

One of the first papers that pointed to a potential issue with LB test was Dezhbaksh, Hashem (1990). “The Inappropriate Use of Serial Correlation Tests in Dynamic Linear Models,” Review of Economics and Statistics, 72, 126–132. Here's the excerpt from the paper:

ingrese la descripción de la imagen aquí

As you can see, he doesn't object to using LB test for pure time series models such as ARMA. See also the discussion in the manual to a standard econometrics tool EViews:

If the series represents the residuals from ARIMA estimation, the appropriate degrees of freedom should be adjusted to represent the number of autocorrelations less the number of AR and MA terms previously estimated. Note also that some care should be taken in interpreting the results of a Ljung-Box test applied to the residuals from an ARMAX specification (see Dezhbaksh, 1990, for simulation evidence on the finite sample performance of the test in this setting)

Yes, you have to be careful with ARMAX models and LB test, but you can't make a blanket statement that LB test is always wrong for all autoregressive series.

UPDATE 2

Alecos Papadopoulos's answer shows why Ljung-Box test requires strict exogeneity assumption. He doesn't show it in his post, but Breusch-Gpdfrey test (another alternative test) requires only weak exogeneity, which is better, of course. This what Greene, Econometrics, 7th ed. says on the differences between tests, p.923:

The essential difference between the Godfrey–Breusch and the Box–Pierce tests is the use of partial correlations (controlling for X and the other variables) in the former and simple correlations in the latter. Under the null hypothesis, there is no autocorrelation in εt , and no correlation between xt and εs in any event, so the two tests are asymptotically equivalent. On the other hand, because it does not condition on xt , the Box–Pierce test is less powerful than the LM test when the null hypothesis is false, as intuition might suggest.

Aksakal
fuente
I suppose that you decided to answer the question as it was bumped to the top of the active threads by my recent answer. Curiously, I argue that the test is inappropriate in the setting under consideration, making the whole thread problematic and the answers in it especially so. Do you think it is good practice to post yet another answer that ignores this problem without even mentioning it (just like all the previous answers do)? Or do you think my answer does not make sense (which would justify posting an answer like yours)?
Richard Hardy
Thank you for an update! I am not an expert, but the argumentation by Alecos Papadopoulos in "Testing for autocorrelation: Ljung-Box versus Breusch-Godfrey" and in the comments under his answer suggests that Ljung-Box is indeed inapplicable on residuals from pure ARMA (as well as ARMAX) models. If the wording is confusing, check the maths there, it seems fine. I think this is a very interesting and important question, so I would really like to find agreement between all of us here.
Richard Hardy
0

... h should be as small as possible to preserve whatever power the LB test may have under the circumstances. As h increases the power drops. The LB test is a dreadfully weak test; you must have a lot of samples; n must be ~> 100 to be meaningful. Unfortunately I have never seen a better test. But perhaps one exists. Anyone know of one ?

Paul3nt


fuente
0

There's no correct answer to this that works in all situation for the reasons other have said it will depend on your data.

That said, after trying to figure out to reproduce a result in Stata in R I can tell you that, by default Stata implementation uses: min(n22,40). Either half the number of data points minus 2, or 40, whichever is smaller.

All defaults are wrong, of course, and this will definitely be wrong in some situations. In many situations, this might not be a bad place to start.

Benjamin Mako Hill
fuente
0

Let me suggest you our R package hwwntest. It has implemented Wavelet-based white noise tests that do not require any tuning parameters and have good statistical size and power.

Additionally, I have recently found "Thoughts on the Ljung-Box test" which is excellent discussion on the topic from Rob Hyndman.

Actualización: Considerando la discusión alternativa en este hilo con respecto a ARMAX, otro incentivo para analizar hwwntest es la disponibilidad de una función de potencia teórica para una de las pruebas contra una hipótesis alternativa del modelo ARMA (p, q).

Delyan Savchev
fuente