christophsax / seasonal

R interface to X-13ARIMA-SEATS
www.seasonal.website
120 stars 27 forks source link

Checks not reliable yet #129

Closed eddelbuettel closed 8 years ago

eddelbuettel commented 8 years ago

It only works after library(x13binary) which defeats the purpose.

R> library(seasonal)    # 1.1.6, ie what is current in the branch
R> checkX13()
X-13 installation test:
Error in checkX13() : could not find function "checkX13binary"
R> x13binary::checkX13binary()
Error in path.package("x13binary") : none of the packages are loaded
R> library(x13binary)
R> x13binary::checkX13binary()

 X-13ARIMA-SEATS Seasonal Adjustment Program
 Version Number 1.1 Build 19
 Execution began  Jan  4, 2016  19.19.43 

  Reading input spec file from /tmp/RtmpOUVcT9/Testairline.spc
  Storing any program output into /tmp/RtmpOUVcT9/Testairline.html
  Storing any program error messages into /tmp/RtmpOUVcT9/Testairline_err.html

 WARNING: Visually significant seasonal and trading day peaks have 
          been found in the estimated spectrum of the regARIMA residuals.

 WARNING: At least one visually significant trading day peak has been
          found in one or more of the estimated spectra.

 Execution complete for /tmp/RtmpOUVcT9/Testairline.spc at  Jan  4, 2016  19.19.43 
X-13 has run successfully
R> 
eddelbuettel commented 8 years ago

Also, this is just wrong:

R> search()             # x13binary loaded
 [1] ".GlobalEnv"        "package:readr"     "package:gunsales"  "package:x13binary" "tools:rstudio"     "package:stats"     "package:graphics" 
 [8] "package:grDevices" "package:utils"     "package:datasets"  "package:methods"   "Autoloads"         "package:base"     
R> checkX13binary()

 X-13ARIMA-SEATS Seasonal Adjustment Program
 Version Number 1.1 Build 19
 Execution began  Jan  4, 2016  19.23.20 

  Reading input spec file from /tmp/RtmpmWFGkJ/Testairline.spc
  Storing any program output into /tmp/RtmpmWFGkJ/Testairline.html
  Storing any program error messages into /tmp/RtmpmWFGkJ/Testairline_err.html

 WARNING: Visually significant seasonal and trading day peaks have 
          been found in the estimated spectrum of the regARIMA residuals.

 WARNING: At least one visually significant trading day peak has been
          found in one or more of the estimated spectra.

 Execution complete for /tmp/RtmpmWFGkJ/Testairline.spc at  Jan  4, 2016  19.23.20 
X-13 has run successfully
R> analysis()
No path to the binary executable of X-13 specified.

For installation details, consider Section 2 of the package vignette:
  http://cran.r-project.org/web/packages/seasonal/vignettes/seas.pdf

 Hide Traceback

 Rerun with Debug
 Error in checkX13(fail = TRUE, fullcheck = FALSE, htmlcheck = FALSE) : 
  Process terminated 
11 stop("Process terminated") 
10 checkX13(fail = TRUE, fullcheck = FALSE, htmlcheck = FALSE) 
9 seas(.) 
8 function_list[[i]](value) 
7 freduce(value, `_function_list`) 
6 `_fseq`(`_lhs`) 
5 eval(expr, envir, enclos) 
4 eval(quote(`_fseq`(`_lhs`)), env, env) 
3 withVisible(eval(quote(`_fseq`(`_lhs`)), env, env)) 
2 total %>% seas %>% final at main.R#66
1 analysis() 
R> 
christophsax commented 8 years ago
christophsax commented 8 years ago

Ah, the second is because seasonal is imported, instead of loaded. This skips the .onAttach() function which sets the path. This currently won't work:

seasonal::seas(AirPassengers)
No path to the binary executable of X-13 specified.

For installation details, consider Section 2 of the package vignette:
  http://cran.r-project.org/web/packages/seasonal/vignettes/seas.pdf

Error in checkX13(fail = TRUE, fullcheck = FALSE, htmlcheck = FALSE) : 
  Process terminated

I guess I need to put this check inside the seas() function.

eddelbuettel commented 8 years ago

I usually use .onLoad() not .onAttach() but then I also don't have such fine-grained dependencies over multiple layers. We get this sorted out.

Also: We could abuse LinkingTo:. It will also ensure package is present, but not load anything. Maybe an alternative?

christophsax commented 8 years ago

I switched to .onAttach() because CRAN tests don't want messages in .onLoad(). But it should work now:

> seasonal::seas(AirPassengers)

Call:
seasonal::seas(x = AirPassengers)

Coefficients:
          Weekday          Easter[1]         AO1951.May  MA-Nonseasonal-01  
         -0.00295            0.01777            0.10016            0.11562  
   MA-Seasonal-12  
          0.49736  
eddelbuettel commented 8 years ago

Yes you can have messages in .onLoad() if you use packageStartupMessage() or what it is called.

https://github.com/Rblp/Rblpapi/blob/master/R/init.R#L27-L29

Let's do this properly.

christophsax commented 8 years ago

I got a NOTE saying I should read ?.onAttach, where it said:

Loading a namespace should where possible be silent, with startup messages given by .onAttach. These messages (and any essential ones from .onLoad) should use packageStartupMessage so they can be silenced where they would be a distraction.

Ok, essential messages seem to be o.k.

christophsax commented 8 years ago

works with onLoad.()!