I am currently working on a bivariate time series that I would like to model using a VAR model. I am trying to assess using an STL decomposition if the seasonal trend is significant and should be integrated in my VAR model (if other tests, like specifications of ADF test on models having a seasonal component, exist, I would be glad to learn about them !). I have thus tried the following code but I can't plot the ACF as it says there are missing values, whereas the 2 following lines of code indicate there aren't any missing values in my series gaz... How could I fix this problem ? Any advice about how I should tackle this model, like how I could show there is seasonality, would be welcome !
# Additive decomposition
gaz_add_decomp <- decompose(gaz, type = "additive")
plot(gaz_add_decomp)
acf(gaz_add_decomp$random, main="ACF of Residuals from Additive Decomposition")
Error in na.fail.default(as.ts(x)) : valeurs manquantes dans l'objet
missing_values <- data.frame(Index = which(is.na(gaz)))
print(missing_values)
[1] Index
<0 lignes> (ou 'row.names' de longueur nulle)
# Multiplicative decomposition
gaz_mult_decomp <- decompose(gaz, type = "multiplicative")
plot(gaz_mult_decomp)
acf(gaz_mult_decomp$random, main="ACF of Residuals from Multiplicative Decomposition")
# STL decomposition
library(tidyverse)
library(tidyquant)
# Decompose the first series (gaz)
gaz %>%
tk_ts(start = c(2003, 11), frequency = 12) %>%
decompose(type = "multiplicative") %>%
autoplot() + theme_tq() +
labs(title = "Decomposition of gaz")
# Decompose the second series (nuc)
nuc %>%
tk_ts(start = c(2003, 11), frequency = 12)
decompose(type = "multiplicative") %>%
autoplot() + theme_tq() +
labs(title = "Decomposition of nuc")
Here is the structure of my dataset for reproducibility :
> dput(head(gaz))
structure(c(47422, 48928, 44215, 38737, 43426, 45864), tsp = c(2003.83333333333,
2004.25, 12), class = "ts")
> dput(head(nuc))
structure(c(39489, 43603, 43703, 37910, 37890, 35611), tsp = c(2003.83333333333,
2004.25, 12), class = "ts")
Thanks in advance for your answers !