-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some issues importing spec files with verison 1.9.0 of the seasonal package #320
Comments
Thanks, @bcmonsell, I will look into it. |
Dear @bcmonsell, I am trying with a full length title and I am not seeing any error, at least using "in-line" data. Please notice that as long as #322 is not merged it would be better to provide lowercase arguments and specs. Thanks! pkgload::load_all()
#> ℹ Loading seasonal
text <- '
series {
title = "Commercial and industrial machinery and equipment (except automotive and electronic) repair and main"
period = 12
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
)
print = BRIEF
format = "free"
name = "8081130000 - HE"
}'
ll <- import.spc(text = text)
ee <- lapply(ll, eval, envir = globalenv())
ee$x
#> Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
#> 1949 112 118 132 129 121 135 148 148 136 119 104 118
#> 1950 115 126 141 135 125 149 170 170 158 133 114 140
#> 1951 145 150 178 163 172 178 199 199 184 162 146 166
ee$seas |> summary()
#>
#> Call:
#> seas(x = x, regression.aictest = NULL, outlier = NULL, automdl = NULL,
#> series.print = "brief")
#>
#> No Coefficients
#>
#> SEATS adj. ARIMA: (0,0,0) Obs.: 36 Transform: none
#> AICc: 463.9, BIC: 465.3 QS (no seasonality in final):27.52 ***
#> Box-Ljung (no autocorr.): 101.5 *** Shapiro (normality): 0.9628
#> Messages generated by X-13:
#> Warnings:
#> - Series should not be a candidate for seasonal adjustment
#> because the spectrum of the original series (Table A1 or B1)
#> has no visually significant seasonal peaks.
#>
#> Notes:
#> - The program cannot perform hypothesis tests for kurtosis on
#> less than 50 observations. Created on 2024-06-10 with reprex v2.1.0 Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.2 (2023-10-31)
#> os macOS Sonoma 14.3.1
#> system x86_64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Rome
#> date 2024-06-10
#> pandoc 3.1.11 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/x86_64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> ! package * version date (UTC) lib source
#> brio 1.1.5 2024-04-24 [1] CRAN (R 4.3.2)
#> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.0)
#> desc 1.4.3 2023-12-10 [1] CRAN (R 4.3.0)
#> digest 0.6.34 2024-01-11 [1] CRAN (R 4.3.0)
#> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.0)
#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0)
#> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.0)
#> glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.0)
#> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.0)
#> knitr 1.45 2023-10-30 [1] CRAN (R 4.3.0)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.0)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0)
#> pkgbuild 1.4.3 2023-12-10 [1] CRAN (R 4.3.0)
#> pkgload 1.3.3 2023-09-22 [1] CRAN (R 4.3.0)
#> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.0)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.0)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.0)
#> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.3.2)
#> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.3.0)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0)
#> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.3.0)
#> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.0)
#> rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.0)
#> rprojroot 2.0.4 2023-11-05 [1] CRAN (R 4.3.0)
#> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.0)
#> P seasonal * 1.9.0.9002 2024-06-09 [?] load_all()
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0)
#> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.0)
#> testthat * 3.2.1 2023-12-02 [1] CRAN (R 4.3.0)
#> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.0)
#> withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.0)
#> x13binary 1.1.60 2024-01-22 [1] CRAN (R 4.3.2)
#> xfun 0.42 2024-02-08 [1] CRAN (R 4.3.2)
#> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.0)
#>
#> [2] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
#>
#> P ── Loaded and on-disk path mismatch.
#>
#> ────────────────────────────────────────────────────────────────────────────── |
Seems to work fine now after the changes. Thanks a lot, @andreranza. # remotes::install_github("christophsax/seasonal")
library(seasonal)
text <- '
SERIES {
TITLE = "Commercial and industrial machinery and equipment (except automotive and electronic) repair and main"
PERIOD = 12
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
)
PRINT = BRIEF
FORMAT = "free"
NAME = "8081130000 - HE"
}'
import.spc(text = text)
#> ## import input series
#> x <- ts(c(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), start = c(1949, 1), frequency = 12)
#>
#> ## main call to 'seas'
#> seas(x = x, series.print = "brief", automdl = NULL, outlier = NULL,
#> regression.aictest = NULL) Created on 2024-06-14 with reprex v2.1.0 |
I recently had a project where I needed to read in about 4000+ X-13 spec files, and found I had a couple of issues that I thought were worth noting.
My apologies if these have already been reported.
I'm using the seasonal::import.spc function to read spec files into R, which I then evaluate into seas objects.
These issues deal with input from the series spec - here is an example of a series spec from one of the series:
SERIES{
TITLE = "Commercial and industrial machinery and equipment (except automotive and electronic) repair and main"
START = 2014.01
PERIOD = 12
SAVE = (A1 B1)
PRINT = BRIEF
NAME = '8081130000 - HE'
FILE = 'c:\HE8081130000.dat'
}
The first thing is what happens when the FORMAT argument isn't specified and the data file is anything other than datevalue format. The default data format for X-13 is free format, but the function used to read in the data from the local file is seasonal::import.ts, which has a default of 'datevalue'.
The code generated by import.spc includes a call to import.ts without as specified format, so import.ts expects a series in datevalue format but gets one in free format.
There is an easy fix for the user - simply always use the FORMAT argument in your spec files, but it would be nice if import.spc would generate a call in this situation that includes format = "free" to keep this inconsistency from rearing its ugly head.
Assuming we've added the format argument, we would then have the following:
SERIES{
TITLE = "Commercial and industrial machinery and equipment (except automotive and electronic) repair and main"
START = 2014.01
PERIOD = 12
SAVE = (A1 B1)
PRINT = BRIEF
NAME = '8081130000 - HE'
FILE = 'c:\HE8081130000.dat'
FORMAT = FREE
}
There is another problem lurking here - the title of the series spec is over 79 characters. This will cause a fatal error in import.spc.
Again, the user could shorten the title, but it would be nice if seasonal package could check for that.
Let's further stipulate that I shorten the title to the first 79 characters, and get this -
SERIES{
TITLE = "Commercial and industrial machinery and equipment (except automotive and electr"
START = 2014.01
PERIOD = 12
SAVE = (A1 B1)
PRINT = BRIEF
NAME = '8081130000 - HE'
FILE = 'c:\HE8081130000.dat'
}
This will still give you an error in seasonal::seas when you evaluate the code read in by import.spc, and the reason isn't obvious (at least, it wasn't to me - the error message given was not informative).
Even though the right parenthesis within the title argument is contained within a character string, you get an error because there is not a matching left parenthesis in the string.
If you replace the "(" with a "-", seas will run perfectly.
Note that Demetra Lytras of the US Census Bureau has built in options within the X-13-SAM program released by Census for the last two problems cited, and these options will likely be included in the next version of X13-SAM that is released.
Again, my apologies if these issues have already been flagged/dealt with.
The text was updated successfully, but these errors were encountered: