How do I remove the season from a series? (seasonal adjustment with X-13, R code to take along)
In brief
How do I remove the season from a monthly or quarterly series? X-13 does not run in the browser, so Statable does not calculate the seasonal adjustment itself. It creates the series as a CSV file and an R script to take along, run in R with the package seasonal.
How it works in Statable
- In the time series analysis open the section "Seasonal adjustment with X-13 (in R on your own computer)".
- Choose the method: SEATS (default) or X-11.
- "Save the series as CSV" and "Save the R script".
- Put both files in one folder and run the script in R. It writes a second CSV with the adjusted series.
Not the same as the classical decomposition
The decomposition in the time series analysis (trend, season, remainder) is not a seasonal adjustment with X-13 and is not called that. It stays as it is.
When it is offered
- Only for monthly or quarterly values.
- The series must have no gaps. Statable fills nothing in.
- At least 3 full years are needed: 36 monthly values or 12 quarterly values.
- If any of this does not apply, a sentence with the reason appears instead of the buttons.
All steps in detail
- Choose the method: SEATS (default, the standard of the package seasonal) or X-11.
- "Save the series as CSV" and "Save the R script".
- Put both files in the same folder and run the script in R. For this R needs the package seasonal (with x13binary).
- The script writes a second CSV file with the adjusted series. It can be opened in Statable again.
The CSV file contains the point in time and the value, with a point as decimal sign, in UTF-8. With "View the R script" the script can be read before saving.
Warnings
- Statable does not calculate this. The result is produced in R on your own computer, and Statable has not checked it.
- Calendar: seasonal tests the standard trading-day and Easter effects. Austrian public holidays are not included; the ESS guidelines recommend national calendars. If you need them, add your own regressors via xreg.
- The model choice of X-13 is automatic. summary(m) and the diagnostics need to be read.
Typical examples
- Remove the yearly pattern from a monthly unemployment rate before the development is interpreted.
- Adjust quarterly sales over several years and compare them with the original series.
For specialists
library(seasonal)
d <- read.csv("reihe.csv")
y <- ts(d$wert, start = c(1949, 1), frequency = 12) # 12 bei Monaten, 4 bei Quartalen
m <- seas(y) # bei X-11: seas(y, x11 = "")
summary(m)
plot(m)
bereinigt <- final(m)
As a check, seas(AirPassengers) gives the model (0 1 1)(0 1 1); the first adjusted values are 122.713, 124.766 and 125.073.