SEATS对500多个变量进行季节性调整

时间:2019-06-21 23:36:52

标签: r

我需要对500多个变量应用SEATS季节性调整。但是为了使其简单易懂,例如,我使用了此链接[https://www.r-bloggers.com/seasonal-adjusment-on-the-fly-with-x-13arima-seats-seasonal-and-ggplot2/][1]

library(seasonal) 
library(tidyr) 
library(dplyr) 
library(showtext) 

set path to X13-SEATS and check it's working Sys.setenv(X13_PATH = "c:/winx13/x13as") checkX13() 
        download.file("https://github.com/ellisp/ellisp.github.io/blob/master/data/Electronic card transactions by industry group Monthly.rda?raw=true", mode = "wb", # ie binary destfile = "tmp.rda") 
load("tmp.rda") 
head(ect) 
apparel <- ect %>% filter(group == "Apparel") apparel_ts <- ts(apparel$Value, start = c(2002, 10), frequency = 12)

SEATS季节调整

 mod <- seas(apparel_ts)

我的问题是如何在多个变量上应用如下。我认为应该会这样,但是会出错


apparel <- ect %>%
  filter(group == "Apparel")

apparel1 <- ect %>%
  filter(group == "Services")
apparel2 <- ect %>%
  filter(group == "Durables")

apparel_ts <- ts(apparel$Value, start = c(2002, 10), frequency = 12)
apparel_ts1 <- ts(apparel1$Value, start = c(2002, 10), frequency = 12)
apparel_ts2 <- ts(apparel2$Value, start = c(2002, 10), frequency = 12)    
df1 <- data.frame(cbind(apparel_ts,apparel_ts1,apparel_ts2)) 
df2 <- ts(df1,start = c(2002, 10), frequency = 12) 

To find out SEATS seasonal adjustment on 3 variable I am trying to use this but getting error
ad <- lapply(colnames(df2), function(x) {seas(df2[, x], type = "additive")})

0 个答案:

没有答案