seasonal (version 1.7.1)

import.spc: Import X-13 .spc Files

Description

Utility function to import .spc files from X-13. It generates a list of calls to seas (and import.ts) that can be run in R. Evaluating these calls should perform the same X-13 procedure as the original .spc file. The print method displays the calls in a way that they can be copy-pasted into an R script.

Usage

import.spc(file, text = NULL)

# S3 method for import.spc print(x, ...)

Arguments

file

character, path to the X-13 .spc file

text

character, alternatively, the content of a .spc file as a character string.

x

object of class import.spc

...

further arguments, not used

Value

returns an object of class import.spc, which is a list with the following (optional) objects of class call:

x

the call to retrieve the data for the input series

xtrans

the call to retrieve the data for the xtrans series (if required by the call)

xreg

the call to retrieve the data for the xreg series (if required by the call)

seas

the call to seas

See Also

import.ts, for importing X-13 data files.

seas for the main function of seasonal.

Examples

Run this code
# NOT RUN {
# importing the orginal X-13 example file
import.spc(text =
'
  series{
    title="International Airline Passengers Data from Box and Jenkins"
    start=1949.01
    data=(
    112 118 132 129 121 135 148 148 136 119 104 118
    115 126 141 135 125 149 170 170 158 133 114 140
    145 150 178 163 172 178 199 199 184 162 146 166
    171 180 193 181 183 218 230 242 209 191 172 194
    196 196 236 235 229 243 264 272 237 211 180 201
    204 188 235 227 234 264 302 293 259 229 203 229
    242 233 267 269 270 315 364 347 312 274 237 278
    284 277 317 313 318 374 413 405 355 306 271 306
    315 301 356 348 355 422 465 467 404 347 305 336
    340 318 362 348 363 435 491 505 404 359 310 337
    360 342 406 396 420 472 548 559 463 407 362 405
    417 391 419 461 472 535 622 606 508 461 390 432)
    span=(1952.01, )
  }
  spectrum{
    savelog=peaks 
  }
  transform{
    function=auto
    savelog=autotransform  
  }
  regression{
    aictest=(td easter)
    savelog=aictest  
  }
  automdl{  
    savelog=automodel  
  }
  outlier{ }
  x11{}
'
)

# }
# NOT RUN {
### 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 DataCamp Workspace