I have a time series dataset. The dataset has a number of variables (Date, revenue, variable1, variable2, variable3). All data is continuous and numeric. The data has over 1000 observations, with each observation being one day as the Dategoing from 2016-2020. I want to produce a regression model such that


The 3 independent variables above are such that their effects on revenue cannot be seen immediantly, but can take up to 7 days. For this reason, I am producing a moving sum over 7 days for all 4 variables, to produce 4 new transformed variables. I was then going to use these transformed variables in the above mentioned regression model. To me this made more sense, as using a single day as a data point would not capture the effects fully of each of the 3 independent variables.

My question is, is this a valid way to go about undertaking linear regression? Am I introducing bias into the results? My purpose is to use the model to explain the effects of changing the independent variable on the revenue.


This is valid though it seems a bit clunky (variables drop out of the 7-day window and no longer matter?). This setup also raises some modeling questions:

  • Should you just be modeling weekly revenue?
  • Do values of the variable from 1 or 2 days ago matter more than values from 7 days ago? Do those matter more than values from 14 days ago?
  • Are these variables correlated?
  • Is revenue changing over different seasons?
  • Is revenue stationary?

While you have daily data, you may be able to greatly reduce your noise by looking at the data weekly. That also avoids any potential day-of-week effects (which are present in many business situations).

If you really want to keep modeling daily data using time-explicit functions, you might want to look into the literature on longitudinal data analysis.

  • $\begingroup$ Thanks for this. If I can answer some of your points. Weekly revenue is possible, but it greatly reduces the number of points I have. So from over 1,000 I have per day over 4 years, it would become around 200. As I am doing machine learning, I would want more points. The variables are various methods of advertising. So seeing an advert for a product 8 days ago would potentially make it less likely to making a purchase than say an advert I saw today. I do see your point however. The independent variables are not correlated, and revenue does go up and down $\endgroup$
    – awz1
    Aug 20 '20 at 15:38
  • $\begingroup$ You don't need machine learning if you have clean data and a solid model (never mind that most "machine learning" is just rebranded stats). Adding 4x the amount of data but making it all noisier is not a win -- hence many analyses summarize the data and then work with the (cleaner) summaries. I would also fix your window issue: maybe have some decay per day since an ad was seen. Also (having consulted some on a similar topic long ago), you might want to use (if you have it) how often the ad was seen. Brand and product awareness tends to rise like a $1-e^x$ function with repeated viewings. $\endgroup$
    – kurtosis
    Aug 20 '20 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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