# Strange results of Ljung-Box test (for white noise process)

Ljung Box test tells that the following time series is white noise (p=0.9746845 for the current run). How could this be?

x=rep(10,1000)
x[500]=-10
Box.test(x,type="Ljung-Box")$p.value  • I don't think the test is "H0: White noise", the test statistic is$\hat{Q}(\hat{r})=n(n+2)\sum_{k=1}^m (n-k)^{-1}\hat(r)^2_k$where r is the autocorrelation. there probably is an explanation in there. Sep 6, 2013 at 8:32 • messed up the latex, statistic is$\hat{Q}(\hat{r})=n(n+2)\sum_{k=1}^m(n-k)^{-1}\hat{r}^2_k$Sep 6, 2013 at 8:42 • @fredrikhs H0 should be independently distributed. But the time series is obviously not independent. Sep 6, 2013 at 12:46 • @user17748: How so? Imagine a process that generated a value of 10 with high probability$p$, & -10 with low probability$1-p$; with fixed$p$so that each observation is independent of the others. Wouldn't it look like your time series? Sep 6, 2013 at 14:22 • @Scortchi Your idea is reasonable. Can you please see this case in which I do get a model residuals like this process, which is white noise? stats.stackexchange.com/questions/69418/is-this-process-an-ar1 Sep 7, 2013 at 0:48 ## 2 Answers Like other hypothesis tests, the Ljung–Box test doesn't tell us the null hypothesis is true, or even likely to be true; but calibrates a test statistic measuring departure from the null hypothesis in a direction of interest by telling us how probable it is that it would exceed (or equal) the value observed under hypothetical repetitions of the experiment or study, if the null hypothesis were true. The L–B test statistic uses the sum of squared sample autocorrelations up to a given lag to investigate autocorrelation in the time series, given a null hypothesis of no autocorrelation at any lag. In your case the spike at$x=500$gets averaged out in the sample autocorrelations & hardly affects the test statistic at all (check the auto-correlation plot with acf). This time series isn't white noise because its mean is far from zero (do a$t$-test if you like). (It's also not Gaussian noise, clearly.) The moral of the story is that there's no single test for every way the null hypothesis can be wrong. Use an outlier test when you want to test for outliers, a location test to test for zero mean, & the L–B test to test for non-zero auto-correlations. † Or if you define white noise as having constant mean, there's no reason to say this time series evidently isn't WN. • Thanks. I agree with your answer. I am just wondering whether these exists a quantitative way to show the time series is not white noise？ Sep 6, 2013 at 12:44 • Well, test if the mean is different from zero. Sep 6, 2013 at 14:18 • @Scortchi white noise does not require zero-mean; just constant mean. I see that its usually used as an error specification with$\mu = 0\$ assumption, but that does not mean white noise has to have zero mean. Mar 21, 2016 at 12:03

At once point, I was looking for a good white noise detector to test against a phenomena that wasn't white noise but I thought might approximate it.

I ran across Prof Don Percival lecture notes (sorry, I lost the pointer to which lecture in which class, but it's somewhere in here:)

https://staff.washington.edu/dbp/

In one of his lectures, he gave several different white noise algorithms.

My take home lesson, is there are a number of plausible ways of measuring for white noise, but it appears there is no one good sure fire way of detecting it. IMHO, this is especially true if you throw in the sampling rate or other things that may create artifacts.

I suspect there may be additional math that needs to be developed before we get a robust white noise detector.