0
$\begingroup$

I want to analyse a time series that in genereal seems to follow a linear trend but at the same time seems to be influenced from some kind of multiplicative effects. A simple example would be a time series generated by the following code:

set.seed(1)
x <- ts(1:30)
x[c(7, 14, 21, 28)] <- 0.5 * x[c(7, 14, 21, 28)]
x <- x + rnorm(30, mean = 0, sd = 0.05 * 1:30)
plot(x, type = "l")

My question is how to best estimate this time series within a regression framework? Obviously a simple linear model would underestimate the multiplicative effect in recent days while a simple log-linear model would estimate a exponential growth instead of a linear one. Is there a simple way to combine both effects within a single regression approach or do I have to do some kind of stepwise estimation?

I would appretiate any thoughts / comments!

$\endgroup$

1 Answer 1

1
$\begingroup$

Your error term is a bit strange because it is multiplicative to time and not to seasonality and trend. I would reconsider if this should be expected in your real data. However, what you have seems close enough to a multiplicative time series to get at least decent estimates:

$Y_t = T_t \cdot S_t \cdot e_t$

Such a time series can be decomposed easily if you define an appropriate frequency for the time series. With stats::decompose:

set.seed(1)
x <- ts(1:30, frequency = 7) #note the frequency
x[c(7, 14, 21, 28)] <- 0.5 * x[c(7, 14, 21, 28)]
x <- x + rnorm(30, mean = 0, sd = 0.05 * 1:30)

y <- decompose(x, type = "multiplicative")
plot(y)

resulting plot

fit_trend <- lm(y$trend ~ seq_along(y$trend))
summary(fit_trend)$coef[-1,]
#    Estimate   Std. Error      t value     Pr(>|t|) 
#9.182801e-01 1.060280e-02 8.660734e+01 2.253371e-29 

You could also check out the forecast package which offers more flexible and automated decomposition of time series.

$\endgroup$
2
  • $\begingroup$ The error was only incorporated for sampling purposes and does not mean anything special. I think decomposition would not work for me because the "drops" are due to public holidays which are not regular but can be given as an external regressor. $\endgroup$ May 22, 2018 at 13:39
  • $\begingroup$ There are decomposition methods that consider moving holidays. $\endgroup$
    – Roland
    May 22, 2018 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.