# seasonal 1.3: A Better Way to Seasonal Adjustment Diagnostics

**R – usefulr**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The R package seasonal makes it easy to use X-13ARIMA-SEATS, the seasonal adjustment software by the United States Census Bureau. Thanks to the x13binary package, installing it from CRAN is now as easy as installing any other R package:

`install.packages("seasonal")`

The latest version 1.3 comes with a new `udg`

function and a customizable `summary`

method, which give power users of X-13 a convenient way to check the statistics that are of *their* interest. For a full list of changes, see the package NEWS.

### A generalized way to access diagnostics

Version 1.3 offers a generalized way to access diagnostic statistics. In seasonal, it was always possible to use *all options* of X-13 and access *all output series*. Now it is easy to access *all diagnostics* as well.

The main new function is `udg`

, named after the X-13 output file which it is reading. Consider a simple call to `seas`

(the main function of the seasonal package) that uses the X-11 seasonal adjustment method:

```
m <- seas(AirPassengers, x11 = "")
udg(m)
```

The `udg`

function returns a list containing 357 named diagnostics. They are properly type-converted, so they can be directly used for further analysis within R.

If we ask for a specific statistic, such as the popular X-11 *M statistics*, the result will be simplified to a numeric vector (see `?udg`

for additional options):

```
udg(m, c("f3.m01", "f3.m02", "f3.m03", "f3.m04"))
## f3.m01 f3.m02 f3.m03 f3.m04
## 0.041 0.042 0.000 0.283
```

There are also some new wrappers for commonly used statistics, such as `AIC`

, `BIC`

, `logLik`

or `qs`

, which use the `udg`

function.

### A customizable summary

The new functionality paves the way for a customizable `summary`

method for `seas`

objects. For example, if we want to add the *M statistics* for X-11 adjustments to the summary, we can write:

```
summary(m, stats = c("f3.m01", "f3.m02", "f3.m03", "f3.m04"))
## Call:
## seas(x = AirPassengers, x11 = "")
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## Weekday -0.0029497 0.0005232 -5.638 1.72e-08 ***
## Easter[1] 0.0177674 0.0071580 2.482 0.0131 *
## AO1951.May 0.1001558 0.0204387 4.900 9.57e-07 ***
## MA-Nonseasonal-01 0.1156204 0.0858588 1.347 0.1781
## MA-Seasonal-12 0.4973600 0.0774677 6.420 1.36e-10 ***
## ---
## Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
##
## X11 adj. ARIMA: (0 1 1)(0 1 1) Obs.: 144 Transform: log
## AICc: 947.3, BIC: 963.9 QS (no seasonality in final): 0
## Box-Ljung (no autocorr.): 26.65 Shapiro (normality): 0.9908
## f3.m01: 0.041 f3.m02: 0.042 f3.m03: 0 f3.m04: 0.283
```

Note the new line at the end, which shows the *M statistics*.

If we want to routinely consider these statistics in our `summary`

, we can set the `seas.stats`

option accordingly:

`options(seas.stats = c("f3.m01", "f3.m02", "f3.m03", "f3.m04"))`

This will change the default behavior, and

`summary(m)`

will return the same output as above. To restore the default behavior, set the option back to `NULL`

.

`options(seas.stats = NULL)`

**leave a comment**for the author, please follow the link and comment on their blog:

**R – usefulr**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.