x12work {x12} | R Documentation |
Run x12 on an R TS-object
Description
A wrapper function for the x12 binaries. It creates a specification file for an R time series and runs x12, afterwards the output is read into R.
Usage
x12work(tso,period=frequency(tso),file="Rout",
series.span=NULL,series.modelspan=NULL,
transform.function="auto",transform.power=NULL,transform.adjust=NULL,
regression.variables=NULL,regression.user=NULL,regression.file=NULL,
regression.usertype=NULL,regression.centeruser=NULL,regression.start=NULL,
regression.aictest=NULL,
outlier.types=NULL,outlier.critical=NULL,outlier.span=NULL,outlier.method=NULL,
identify=FALSE,identify.diff=NULL,identify.sdiff=NULL,identify.maxlag=NULL,
arima.model=NULL,arima.smodel=NULL,arima.ar=NULL,arima.ma=NULL,
automdl=FALSE,automdl.acceptdefault=FALSE,automdl.balanced=TRUE,
automdl.maxorder=c(3,2),automdl.maxdiff=c(1,1),
forecast_years=NULL,backcast_years=NULL,forecast_conf=.95,
forecast_save="ftr",
estimate=FALSE,estimate.outofsample=TRUE,
check=TRUE,check.maxlag=NULL,
slidingspans=FALSE,
slidingspans.fixmdl=NULL,slidingspans.fixreg=NULL,
slidingspans.length=NULL,slidingspans.numspans=NULL,
slidingspans.outlier=NULL,
slidingspans.additivesa=NULL,slidingspans.start=NULL,
history=FALSE,
history.estimates=NULL,history.fixmdl=FALSE,
history.fixreg=NULL,history.outlier=NULL,
history.sadjlags=NULL,history.trendlags=NULL,
history.start=NULL,history.target=NULL,
x11.sigmalim=c(1.5,2.5),x11.type=NULL,x11.sfshort=FALSE,x11.samode=NULL,
x11.seasonalma=NULL,x11.trendma=NULL,
x11.appendfcst=TRUE,x11.appendbcst=FALSE,x11.calendarsigma=NULL,
x11.excludefcst=TRUE,x11.final="user",
x11regression=FALSE,
tblnames=NULL,Rtblnames=NULL,
x12path=NULL,use="x12",keep_x12out=TRUE,showWarnings=TRUE)
Arguments
tso |
a time series object. |
period |
frequency of the time series. |
file |
path to the output directory and filename, default is the working directory and |
series.span |
vector of length 4, limiting the data used for the calculations and analysis to a certain time interval. |
series.modelspan |
vector of length 4, defining the start and end date of the time interval of the data
that should be used to determine all regARIMA model coefficients. Specified in the same way as |
transform.function |
transform parameter for x12 ( |
transform.power |
numeric value specifying the power of the Box Cox power transformation. |
transform.adjust |
determines the type of adjustment to be performed,
i.e. |
regression.variables |
character or character vector representing the names of the regression variables. |
regression.user |
character or character vector defining the user parameters in the regression argument. |
regression.file |
path to the file containing the data values of all |
regression.usertype |
character or character vector assigning a type of model-estimated regression effect
on each user parameter in the regression argument ( |
regression.centeruser |
character specifying the removal of the (sample) mean or the seasonal means from
the user parameters in the regression argument ( |
regression.start |
start date for the values of the |
regression.aictest |
character vector defining the regression variables for which an AIC test is to be performed. |
outlier.types |
to enable the "outlier" specification in the spc file, this parameter has to be defined by a character or character vector determining the method(s) used for outlier detection ( |
outlier.critical |
number specifying the critical value used for outlier detection
(same value used for all types of outliers)
or named list (possible names of list elements being |
outlier.span |
vector of length 2, defining the span for outlier detection. |
outlier.method |
character determining how detected outliers should be added to the model ( |
identify |
Object of class |
identify.diff |
number or vector representing the orders of nonseasonal differences specified, default is 0. |
identify.sdiff |
number or vector representing the orders of seasonal differences specified, default is 0. |
identify.maxlag |
number of lags specified for the ACFs and PACFs, default is 36 for monthly series and 12 for quarterly series. |
arima.model |
vector of length 3, defining the arima parameters. |
arima.smodel |
vector of length 3, defining the sarima parameters. |
arima.ar |
numeric or character vector specifying the initial values for nonseasonal and seasonal autoregressive parameters in the order that they appear in the |
arima.ma |
numeric or character vector specifying the initial values for all moving average parameters in the order that they appear in the |
automdl |
|
automdl.acceptdefault |
logical for |
automdl.balanced |
logical for |
automdl.maxorder |
vector of length 2, maximum order for |
automdl.maxdiff |
vector of length 2, maximum diff. order for |
forecast_years |
number of years to forecast, default is 1 year. |
backcast_years |
number of years to backcast, default is no backcasts. |
forecast_conf |
probability for the confidence interval of forecasts |
forecast_save |
character either "ftr"(in transformed scaling) or "fct"(in original scaling) |
estimate |
if |
estimate.outofsample |
logical defining whether "out of sample" or "within sample" forecast errors should be used in calculating the average magnitude of forecast errors over the last three years. |
check |
|
check.maxlag |
the number of lags requested for the residual sample ACF and PACF, default is 24 for monthly series and 8 for quarterly series. |
slidingspans |
if |
slidingspans.fixmdl |
( |
slidingspans.fixreg |
character or character vector specifying the trading day, holiday, outlier or other user-defined regression effects to be fixed ( |
slidingspans.length |
numeric value specifying the length of each span in months or quarters (>3 years, <17 years). |
slidingspans.numspans |
numeric value specifying the number of sliding spans used to generate output for comparisons (must be between 2 and 4, inclusive). |
slidingspans.outlier |
( |
slidingspans.additivesa |
( |
slidingspans.start |
specified as a vector of two integers in the format |
history |
if |
history.estimates |
character or character vector determining which estimates from the regARIMA modeling and/or the x11 seasonal adjustment will be analyzed in the history analysis ( |
history.fixmdl |
logical determining whether the regARIMA model will be re-estimated during the history analysis. |
history.fixreg |
character or character vector specifying the trading day, holiday, outlier or other user-defined regression effects to be fixed ( |
history.outlier |
( |
history.sadjlags |
integer or vector specifying up to 5 revision lags (each >0) that will be analyzed in the revisions analysis of lagged seasonal adjustments. |
history.trendlags |
integer or vector specifying up to 5 revision lags (each >0) that will be used in the revision history of the lagged trend components. |
history.start |
specified as a vector of two integers in the format |
history.target |
character determining whether the revisions of the seasonal adjustments and trends calculated at the lags specified in |
x11.sigmalim |
vector of length 2, defining the limits for sigma in the x11 methodology, used to downweight extreme irregular values in the internal seasonal adjustment iterations. |
x11.type |
character, i.e. |
x11.sfshort |
logical controlling the seasonal filter to be used if the series is at most 5 years long.
If |
x11.samode |
character defining the type of seasonal adjustment decomposition calculated
( |
x11.seasonalma |
character or character vector of the format |
x11.trendma |
integer defining the type of Henderson moving average used for estimating the final trend cycle. If not specified, the program will invoke an automatic choice. |
x11.appendfcst |
logical defining whether forecasts should be included in certain x11 tables. |
x11.appendbcst |
logical defining whether forecasts should be included in certain x11 tables. |
x11.calendarsigma |
regulates the way the standard errors used for the detection and adjustment of
extreme values should be computed ( |
x11.excludefcst |
logical defining if forecasts and backcasts from the regARIMA model should not be used in the generation of extreme values in the seasonal adjustment routines. |
x11.final |
character or character vector specifying which type(s) of prior adjustment factors should be
removed from the final seasonally adjusted series ( |
x11regression |
if |
tblnames |
character vector of additional tables to be read into R. |
Rtblnames |
character vector naming the additional tables. |
x12path |
path to the x12 binaries, for example |
use |
|
keep_x12out |
if |
showWarnings |
logical defining whether warnings and notes generated by x12 should be returned. Errors will be displayed in any case. |
Details
Generates an x12 specification file, runs x12 and reads the output files.
Value
x12work
returns an object of class "x12"
.
The function summary
is used to print a summary of the diagnostics results.
An object of class "x12"
is a list containing at least the following components:
a1 |
original time series |
d10 |
final seasonal factors |
d11 |
final seasonally adjusted data |
d12 |
final trend cycle |
d13 |
final irregular components |
d16 |
combined adjustment factors |
c17 |
final weights for irregular component |
d9 |
final replacements for SI ratios |
e2 |
differenced, transformed, seasonally adjusted data |
d8 |
final unmodified SI ratios |
b1 |
prior adjusted original series |
forecast |
point forecasts with prediction intervals |
backcast |
point backcasts with prediction intervals |
dg |
a list containing several seasonal adjustment and regARIMA modeling diagnostics, i.e.: |
file |
path to the output directory and filename |
tblnames |
tables read into R |
Rtblnames |
names of tables read into R |
Note
Only working with available x12 binaries.
Author(s)
Alexander Kowarik, Angelika Meraner
Source
https://www.census.gov/data/software/x13as.html
References
Alexander Kowarik, Angelika Meraner, Matthias Templ, Daniel Schopfhauser (2014). Seasonal Adjustment with the R Packages x12 and x12GUI. Journal of Statistical Software, 62(2), 1-21. URL http://www.jstatsoft.org/v62/i02/.
See Also
x12
,
ts
,
summary.x12work
,
plot.x12work
,
x12-methods
Examples
### Examples
data(AirPassengers)
## Not run:
x12out <- x12work(AirPassengers,x12path=".../x12a.exe",transform.function="auto",
arima.model=c(0,1,1),arima.smodel=c(0,1,1),regression.variables="lpyear",
x11.sigmalim=c(2.0,3.0),outlier.types="all",outlier.critical=list(LS=3.5,TC=3),
x11.seasonalma="s3x3")
summary(x12out)
## End(Not run)