Thanks for your reply. I have a question about LjungBox test. Based on the instruction of SuanShu, the constructor of Ljung-Box test is LjungBox(double x, int lag, int fitdf). However, by the definition of Ljung-Box, it runs a Ljung-Box test on the residuals of x. So, the constructor of Ljung-Box test in Matlab is Box.test(resid(x.arma), lag=20, type=”Ljung-Box”). In SuanShu, the first input is the residual of a time series or a time series itself?