0
$\begingroup$

I am trying to figure out how to make a time series of time series. I might not even be asking the right question.

I created individualized lm models based on one year of transactions for each customer using purrr, broom, dplyr and I did to do this for numerous different one-year windows of time. The goal is to measure the differences in the models over time.

I am sure there is a way to do it without just copying my code 12 times. I was hoping someone could point me in the right direction.

$\endgroup$
  • $\begingroup$ Does taking the first difference of the data help? $\endgroup$ – Ferdi Dec 7 '16 at 13:22
  • $\begingroup$ I would like each customer to have 12 different LM models, each model will encompass 12 months worth of data (weekly data as the time series). The goal is to forecast churn or decrease in buying behavior. My hypothesis is that changes in the slop and intercept of the different models could potentially provide me some predictive value. I have a lot of other features that I was then going to put into xgboost. $\endgroup$ – Daniel Robert Armstrong Dec 7 '16 at 15:24
  • $\begingroup$ @Ferdi I don't really know. I was thinking a fast way of doing this would be to create 12 copies of the data frame and modifying the date and customer ID. Customer A would become A1, A2, A3... the date 12/1/2016 would become 1/1/2017, 2/1/2017.... This way filter could be used. I could then combine the data frames and create the lm models I could them combine them back by the original customer ID. $\endgroup$ – Daniel Robert Armstrong Dec 8 '16 at 2:15
  • $\begingroup$ If you want to avoid writing the code 12 times you can run a for-loop $\endgroup$ – Ferdi Dec 8 '16 at 7:14
1
$\begingroup$

The term for what you are doing is a lagged time series. In your case it sounds like you have a time series per customer and you want to compare different lagged 12 month windows for each customer.

Have a look at R's lag function. There is also a lot of background on lagged groups of time series in this answer.

| cite | improve this answer | |
$\endgroup$

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.