2
$\begingroup$

Can we chose time (t) as one of the independent variables in multiple (OLS) regression?

$\endgroup$
3
  • 1
    $\begingroup$ can you share more context about your problem? $\endgroup$
    – gunes
    Commented Mar 11, 2019 at 9:03
  • 1
    $\begingroup$ It is possible in principle, but please consider making a time-series model instead if you expect observations that are closer in time to have an effect on each other $\endgroup$
    – David
    Commented May 28, 2019 at 13:05
  • 1
    $\begingroup$ You can do it. The trick is making sense of what you are doing. You're saying that there is a trend with time quite separate from how the other predictors are varying. $\endgroup$
    – Nick Cox
    Commented May 28, 2019 at 13:18

3 Answers 3

4
$\begingroup$

In my opinion ,,, There is no violation in using time as an independent variable thus Yes "one can include time as an independent/predictor". Auto-regression versus linear regression of x(t)-with-t for modelling time series includes a discussion and a worked example.

The problem comes when one tries to use powers of time like time squared , time cubed etc as predictor variables for purposes of extrapolation (and even interpolation) . See How to extrapolate this simple trend line into the future for the purpose of forecasting in Matlab? @Ben's comments about the dangers of polynomial fitting.

Note that many "EARLIER" textbooks in the BC (BEFORE CORRELATION) era , used examples of fitting time polynomials to data .... seriously flawed in my opinion.

WARNING : BAD APPROACH FOLLOWS !

As an example of what not to do ( always dangerous ! )... Here is quarterly data from an "easy to read popular forecasting text" enter image description here . Yielding the following not-so-useful equation (user-specified) enter image description here with an incredibly deficient residual plot here enter image description here and Actual/Fit/Forecast here enter image description here .

$\endgroup$
2
$\begingroup$

This is a very open question as you're not specifying what type of time measurement you want to add to your model, but the answer is always yes.

If you're thinking about a linear relationship with time (e.g. age vs time) then you can always represent a date as a number of milliseconds or days and add it to your model as a regular continuous variable (your age is explained by the number of milliseconds since a date X, and 8.64e7 milliseconds extra will add 1/365 years to your age).

On the other hand, if you're thinking about a not so linear effect of a date (seasonality, e.g. increase in sales in December due to Christmas), then you'd need to transform the part of the date you're interested in into a categorical variable (in this case, a binary feature that will tell you whether or not you're in December).

$\endgroup$
2
  • $\begingroup$ It was a very general question. I wanted to know if there was any violation of laws in choosing time as an independent variable in an ols regression $\endgroup$
    – Dom Jo
    Commented Mar 11, 2019 at 9:46
  • $\begingroup$ +1 The trick is that time series have serial correlation, cycles, and tend to saturate. If you can take all of that into account, you're good. But using OLS with just time thrown in as a variable instead of a technique that accounts for such things is skating on thin ice. $\endgroup$
    – Wayne
    Commented May 28, 2019 at 13:04
1
$\begingroup$

The answer depends on the underlying process. If the true underlying process is $y_i=\alpha+v t_i+\beta X_i +\varepsilon_i$ then yes, you can regress on time. For instance, you are measuring the temperature of an electric kettle when boiling water. Suppose, your $X$ variables are weight of a kettle, power rating of a kettle, amount of water, the temperature in the room. You're trying different kettles and filling with various amount of water etc. In other words, you're controlling the experiment.

$\endgroup$

Your Answer

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

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