Cannot use seas() function from seasonal package in R

224 Views Asked by At

I am trying to make seasonal adjustment for a data in R with seasonal package.

While using it with my own data I get

Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file '/var/folders/lz/y98s6mjd0wj20yg753975_gm0000gn/T//RtmpmbiMm1/x132069375fe11b/iofile.est': No such file or directory

error

Example of my data, which is a monthly, electricity usage data.

structure(list(TP_ELEKTUKETIM_TKT1 = c(829993.67, 828500.35, 
794785.03, 780987.81, 794123.54, 801793.81, 920212.91, 887967.7, 
837716.33, 765780.2, 791234.38, 836844.05, 862093.97, 855170.09, 
793270.11, 671752.87, 670617.73, 789836.94, 920637.78, 923602.56, 
907935.74, 805712, 837915.2, 865274.32, 861818.14, 860445.29, 
886330.82, 853433.59, 804124.56, 885961.42)), row.names = c(NA, 
-30L), class = c("tbl_df", "tbl", "data.frame"))

But while using unemp dataset from the package or a reproduced seasonal data I do not get this error and I can get the result.

> set.seed(111)
> toy <- abs(sin(seq(1, 60, by = 1) * 2 * pi / 12) + rnorm(60))
> toyts <- ts(toy,frequency = 12,start = 2010,end = 2015)
> seas(toyts)

Call:
seas(x = toyts)

Coefficients:
         Constant  AR-Nonseasonal-01  
          -0.2602             0.1147  

or

> seas(seasonal::unemp)

Call:
seas(x = seasonal::unemp)

Coefficients:
AR-Nonseasonal-01  MA-Nonseasonal-01     MA-Seasonal-12  
           0.9436             0.8254             0.8507  

I tried to update all packages, re-downloaded seasonal and x13binary packages but I don't understand why it works with sample datasets but not with my own. I also tried to unlist and turned my data into double datatype and still did not work. Thanks for replies.

1

There are 1 best solutions below

0
On

It turns out that I did not clearly specify the ts() so that seas() could not work properly. I needed to revise my ts() and data so that it didn't have any re-used or missing time series data.