# How to read checkresiduals graphics in R?

I need to check the residuals of two models in R so I can determine how bad or good are said models.

First, I've started simulating an INAR(2) model and wanted to fit a more convenient model, then, compare it with an INAR(1) and decide which one is better. So, for the fit model:

 mo21  <-  tsglm(x,model=list(past_obs=c(1,2)),distr="poisson")


For the INAR(1):

 mo22  <-  tsglm(x,model=list(past_obs=c(1)),distr="poisson")


Now, here is where I don't know exactly how to proceed. I decided to check the summaries to see if $$mo21$$ is a good model, and see if $$mo22$$ was a better model or not:

 summary(mo21)

Call:
tsglm(ts = x, model = list(past_obs = c(1, 2)), distr = "poisson")

Coefficients:
Estimate  Std.Error  CI(lower)  CI(upper)
(Intercept)     1.538     0.1571     1.2298      1.846
beta_1          0.602     0.0399     0.5238      0.680
beta_2          0.094     0.0401     0.0154      0.173
Standard errors and confidence intervals (level =  95 %) obtained
by normal approximation.

Distribution family: poisson
Number of coefficients: 3
Log-likelihood: -2010.146
AIC: 4026.292
BIC: 4041.015
QIC: 4026.228

summary(mo22)

Call:
tsglm(ts = x, model = list(past_obs = c(1)), distr = "poisson")

Coefficients:
Estimate  Std.Error  CI(lower)  CI(upper)
(Intercept)     1.705     0.1436      1.423      1.986
beta_1          0.663     0.0295      0.605      0.721
Standard errors and confidence intervals (level =  95 %) obtained
by normal approximation.

Distribution family: poisson
Number of coefficients: 2
Log-likelihood: -2012.836
AIC: 4029.672
BIC: 4039.487
QIC: 4029.66


And I found them very similar, so I've decided to check the residuals:

  > checkresiduals(mo21)
> checkresiduals(mo22)


Which gave me the following graphics.

But here is my problem, I don't know how to read these graphics, all I can see is that they are very similar too but I don't know how should I extract conclusions from them. What is the basic information I can get from those and how to determine which of the two models works better? Should I check the quadratic residuals?

• – Rob Hyndman Jan 12 at 23:39

The following observations on the model results favour choosing model mo21 over model mo22.

1) Residual histograms
The residuals of the mo21 model seem to better follow a normal distribution than the mo22 model (the mo22 residuals have a few bins with higher concentration of cases than the other bins, which distort the normal distribution).

2) ACF plots
The residuals of the mo21 model are less autocorrelated than those of the mo22 model. In fact, the autocorrelation values at lags 1 and 2 for the mo22 model are way larger than those of the mo21 model, showing two respective peaks that go beyond the 95% limits defined by the dash blue lines.
(As a side note, this is even more relevant given the fact that the 95% limits of ACF values are actually slightly smaller at lower lags than they are at larger lags (making the shown horizontal dash blue lines be a relaxation of more precise limits) --unfortunately I haven't found a shareable reference for this at this time.)

3) Parameter estimates and Likelihood ratio
The following two related observations support the above conclusion:

• the estimate and standard error values of the beta_2 parameter suggest that the true beta_2 is not zero (at a 95% level, confirmed by the fact that the confidence interval (CI) does not cover the zero value)
• the likelihood ratio test (which in this can be applied to compare the two models since model mo22 is nested in model mo21) gives the value 0.02 (a rather small p-value suggesting that there is in fact a significant difference between the likelihoods of the two models and that model mo21 should be preferred).
The likelihood ratio statistic is calculated by -2*log(L1/L2), where L1 is the likelihood of the nested model (mo22 in this case), which approximately follows a chi-square distribution with degrees of freedom (df) equal to the difference in the number of parameters between the two models (df=1 in this case).
The p-value of the likelihood ratio test can therefore be calculated in R by the following piece of code: 1 - pchisq( -2 * (-2012.836 - (-2010.146)), df=1)
where we have applied the property that the log of a ratio is equal to the difference of the logs.
Ref: https://en.wikipedia.org/wiki/Likelihood-ratio_test
• Great answer. I would also add ACF/PACF plots of squared residuals as a validation criterion, to see if there is autocorrelation in variance – David Jun 11 at 8:36