# importing the orginal X-13 example file
import.spc(system.file("tests", "Testairline.spc", package="seasonal"))
### reading .spc with multiple user regression and transformation series
# running a complex seas call and save output in a temporary directory
tdir <- tempdir()
seas(x = AirPassengers, xreg = cbind(a = genhol(cny, start = 1, end = 4,
center = "calendar"), b = genhol(cny, start = -3, end = 0,
center = "calendar")), xtrans = cbind(sqrt(AirPassengers), AirPassengers^3),
transform.function = "log", transform.type = "temporary",
regression.aictest = "td", regression.usertype = "holiday", dir = tdir,
out = TRUE)
# importing the .spc file from the temporary location
ll <- import.spc(file.path(tdir, "iofile.spc"))
# ll is list containing four calls:
# - 'll$x', 'll$xreg' and 'll$xtrans': calls to import.ts(), which read the
# series from the X-13 data files
# - 'll$seas': a call to seas() which performs the seasonal adjustment in R
str(ll)
# to replicate the original X-13 operation, run all four calls in a series.
# You can either copy/paste and run the print() output:
ll
# or use eval() to evaluate the call(s). To evaluate the first call and
# import the x variable:
eval(ll$x)
# to run all four calls in 'll', use lapply() and eval():
ee <- lapply(ll, eval, envir = globalenv())
ee$seas # the 'seas' object, produced by the final call to seas()
Run the code above in your browser using DataLab