1.

How will you detrend a time series?

Answer»

Linear regression can be used to model the Time Series data with linear indices (Ex: 1, 2,...N). The resulting model’s residuals are a representation of the time series devoid of the TREND.

In case, if some trend is left over to be seen in the residuals (like what it seems to be with ‘Figure1’ with MYDATA below as an EXAMPLE), then you MIGHT wish to add few predictors to the lm() call (like a forecast:: seasonal dummy, forecast::Fourier or may be a lag of the series itself), until the trend is filtered.

Code snippet:

trModel <- lm(myData ~ c(1:length(myData))) plot(resid(trModel), type="l")  # resid(trModel) contains the de-trended series


Discussion

No Comment Found

Related InterviewSolutions