Learn R Programming

x12 (version 1.0-2)

x12: 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

x12(tso,period=frequency(tso),span=NULL,modelspan=NULL,
		decimals=2,transform="auto",
		arima=NULL,sarima=NULL,
		automdl=FALSE,acceptdefault=FALSE,balanced=TRUE,
		maxorder=c(3,2),maxdiff=c(1,1),
		regvariables=NULL,reguser=NULL,regfile=NULL,usertype=NULL,centeruser=NULL,regfilestart=NULL,#regfileformat=NULL,
		tblnames=NULL,Rtblnames=NULL,addLines=NULL,
		x12path=NULL,x13path=NULL,use="x12",
		seats=FALSE, seatsparameter=NULL,
		sigmalim=c(1.5,2.5),outlier=NULL,critical=NULL,outlier_span=NULL,outlier_method=NULL,
		file="Rout",forecast_years=NULL,backcast_years=NULL,forecast_conf=0.95,estimate=FALSE,
		estOutofsample=TRUE,slidingspans=FALSE,aictest=NULL,
		onlytd=FALSE,sfshort=FALSE,samode=NULL,seasonalma=NULL,trendma=NULL,
		x11appendfcst=TRUE,x11appendbcst=FALSE,x11calendarsigma=NULL,x11excludefcst=TRUE,x11final="user",
		x11regress=FALSE,keep_x12out=FALSE,showWarnings=FALSE)

Arguments

tso
a time series object.
period
frequency of the time series.
span
vector of length 4, limiting the data used for the calculations and analysis to a certain time interval. Start and end date of said time interval can be specified by 4 integers in the format c(start year, start seasonal period, end year, end seasona
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 span.
decimals
number of decimal places of the data.
transform
transform parameter for x12 ("auto", "log", "none").
arima
vector of length 3, defining the arima parameters.
sarima
vector of length 3, defining the sarima parameters.
automdl
TRUE/FALSE for activating auto modeling.
acceptdefault
logical for automdl defining whether the default model should be chosen if the Ljung-Box Q statistic for its model residuals is acceptable.
balanced
logical for automdl defining whether the automatic model procedure will tend towards balanced models. TRUE yields the same preference as the TRAMO program.
maxorder
maximum order for automdl.
maxdiff
maximum diff. order for automdl.
regvariables
character or character vector representing the names of the regression variables.
reguser
character or character vector defining the user parameters in the regression argument.
regfile
path to the file containing the data values of all reguser variables.
usertype
character or character vector assigning a type of model-estimated regression effect on each user parameter in the regression argument ("seasonal", "td", "lpyear", "user", ...). By specifying a chara
centeruser
character specifying the removal of the (sample) mean or the seasonal means from the user parameters in the regression argument ("mean", "seasonal"). Default is no modification of the respective user-defined regressors.
regfilestart
start date for the values of the reguser variables, specified as a vector of two integers in the format c(year, seasonal period).
tblnames
character vector of additional tables to be read into R.
Rtblnames
character vector naming the additional tables.
addLines
list or list of lists in the format list(list("spec1","line","line"),list("spec2","line","line","line"),...) specifying new lines that should be added to the spc file. The first element of each list is a character defining the respecti
x12path
path to the x12 binaries, for example d:\x12a\x12a.exe.
x13path
path to the x13 binaries, for example d:\x13\x13.exe.
use
"x12" or "x13", at the moment only "x12" is tested properly.
seats
TRUE/FALSE for activating SEATS, at the moment SEATS is not properly implemented.
seatsparameter
string defining the seats parameter.
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.
outlier
character or character vector defining the method(s) used for outlier detection ("AO", "LS", "TC", "all").
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 AO,LS and TC) where each list element s
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 ("addone", "addall"). If not specified,"addone" is used by default.
file
path to the output directory and filename, default is the working directory and Rout.*.
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
estimate
if TRUE, the term "estimate" will be added to the spc file.
slidingspans
if TRUE, slidingspans will be enabled.
estOutofsample
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.
aictest
character vector defining the regression variables for which an AIC test is to be performed.
onlytd
if TRUE, x11 will only be used to estimate trend and to adjust according to trading days.
sfshort
logical controlling the seasonal filter to be used if the series is at most 5 years long. If TRUE, the arguments of the seasonalma filter will be used wherever possible. If FALSE, a stable seasonal filter will
samode
character defining the type of seasonal adjustment decomposition calculated ("mult", "add", "pseudoadd", "logadd").
seasonalma
character or character vector of the format c("snxm","snxm", ...) defining which seasonal nxm moving average(s) should be used for which calendar months or quarters to estimate the seasonal factors. If only one ma is specified, the
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.
x11appendfcst
logical defining whether forecasts should be included in certain x11 tables.
x11appendbcst
logical defining whether forecasts should be included in certain x11 tables.
x11calendarsigma
regulates the way the standard errors used for the detection and adjustment of extreme values should be computed ("all", "signif", "select" or no specification).
x11excludefcst
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.
x11final
character or character vector specifying which type(s) of prior adjustment factors should be removed from the final seasonally adjusted series ("AO", "LS", "TC", "user", "none").
x11regress
if TRUE, x11Regression will be performed (using the regression commands above).
keep_x12out
if TRUE, the output files generated by x12 are stored in the folder "gra" in the output directory and are not deleted at the end of a successful run.
showWarnings
logical defining whether warnings and notes generated by x12 should be returned. Errors will be displayed in any case.

Value

  • x12 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:
  • a1original time series
  • d10final seasonal factors
  • d11final seasonally adjusted data
  • d12final trend cycle
  • d13final irregular components
  • d16combined adjustment factors
  • c17final weights for irregular component
  • d9final replacements for SI ratios
  • e2differenced, transformed, seasonally adjusted data
  • d8final unmodified SI ratios
  • b1prior adjusted original series
  • forecastpoint forecasts with prediction intervals
  • backcastpoint backcasts with prediction intervals
  • dga list containing several seasonal adjustment and regARIMA modeling diagnostics, i.e.: x11regress, transform, samode, seasonalma, trendma, arimamdl, automdl, regmdl, nout, nautoout, nalmostout, almostoutlier, crit, outlier, userdefined, autooutlier, peaks.seas, peaks.td, id.seas, id.rsdseas, spcrsd, spcori, spcsa, spcirr, q, q2, nmfail, loglikelihood, aic, aicc, bic, hq, aape, autotransform, ifout, res.acf, res.pacf, res.acf2,...
  • filepath to the output directory and filename
  • tblnamestables read into R
  • Rtblnamesnames of tables read into R

source

http://www.census.gov/srd/www/x12a/

Details

Generates an x12 specification file, runs x12 and reads the output files.

See Also

X12, ts, summary.x12, plot.x12, X12-methods

Examples

Run this code
### Examples
data(AirPassengers)
x12out <- x12(AirPassengers,x12path="d:/x12/x12a.exe",transform="auto",
		arima=c(0,1,1),sarima=c(0,1,1),regvariables="lpyear",
		sigmalim=c(2.0,3.0),outlier="all",critical=list(LS=3.5,TC=3),
		seasonalma="s3x3")
summary(x12out)

Run the code above in your browser using DataLab