Generate variables of seasonal dummies and seasonal cycles.

seasonal.dummies(x)
seasonal.cycles(x)

Arguments

x

a univariate seasonal time series.

Value

A multivariate time series containing the dummies or cycles by columns.

Examples

# In terms of model fitting
# both sets of variables are equivalent
x <- diff(log(AirPassengers))
sd <- seasonal.dummies(x)
fit1 <- lm(x ~ sd[,-1])
summary(fit1)
#> 
#> Call:
#> lm(formula = x ~ sd[, -1])
#> 
#> Residuals:
#>       Min        1Q    Median        3Q       Max 
#> -0.097926 -0.021078 -0.001084  0.027432  0.116727 
#> 
#> Coefficients:
#>              Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)   0.02515    0.01165   2.160  0.03261 *  
#> sd[, -1]SD2  -0.03714    0.01612  -2.303  0.02283 *  
#> sd[, -1]SD3   0.11514    0.01612   7.141 5.73e-11 ***
#> sd[, -1]SD4  -0.04635    0.01612  -2.875  0.00472 ** 
#> sd[, -1]SD5  -0.01746    0.01612  -1.083  0.28091    
#> sd[, -1]SD6   0.10706    0.01612   6.640 7.60e-10 ***
#> sd[, -1]SD7   0.08886    0.01612   5.511 1.82e-07 ***
#> sd[, -1]SD8  -0.02438    0.01612  -1.512  0.13293    
#> sd[, -1]SD9  -0.15972    0.01612  -9.906  < 2e-16 ***
#> sd[, -1]SD10 -0.15324    0.01612  -9.504  < 2e-16 ***
#> sd[, -1]SD11 -0.15880    0.01612  -9.849  < 2e-16 ***
#> sd[, -1]SD12  0.09878    0.01612   6.126 9.81e-09 ***
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 0.03863 on 131 degrees of freedom
#> Multiple R-squared:  0.8788,	Adjusted R-squared:  0.8686 
#> F-statistic: 86.33 on 11 and 131 DF,  p-value: < 2.2e-16
#> 
sc <- seasonal.cycles(x)
fit2 <- lm(x ~ sc)
summary(fit1)
#> 
#> Call:
#> lm(formula = x ~ sd[, -1])
#> 
#> Residuals:
#>       Min        1Q    Median        3Q       Max 
#> -0.097926 -0.021078 -0.001084  0.027432  0.116727 
#> 
#> Coefficients:
#>              Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)   0.02515    0.01165   2.160  0.03261 *  
#> sd[, -1]SD2  -0.03714    0.01612  -2.303  0.02283 *  
#> sd[, -1]SD3   0.11514    0.01612   7.141 5.73e-11 ***
#> sd[, -1]SD4  -0.04635    0.01612  -2.875  0.00472 ** 
#> sd[, -1]SD5  -0.01746    0.01612  -1.083  0.28091    
#> sd[, -1]SD6   0.10706    0.01612   6.640 7.60e-10 ***
#> sd[, -1]SD7   0.08886    0.01612   5.511 1.82e-07 ***
#> sd[, -1]SD8  -0.02438    0.01612  -1.512  0.13293    
#> sd[, -1]SD9  -0.15972    0.01612  -9.906  < 2e-16 ***
#> sd[, -1]SD10 -0.15324    0.01612  -9.504  < 2e-16 ***
#> sd[, -1]SD11 -0.15880    0.01612  -9.849  < 2e-16 ***
#> sd[, -1]SD12  0.09878    0.01612   6.126 9.81e-09 ***
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 0.03863 on 131 degrees of freedom
#> Multiple R-squared:  0.8788,	Adjusted R-squared:  0.8686 
#> F-statistic: 86.33 on 11 and 131 DF,  p-value: < 2.2e-16
#> 
all.equal(fitted(fit1), fitted(fit2))
#> [1] TRUE