Tich Mangono
1 min readSep 6, 2019

--

Hi Alice! Thanks for the question. If I understand your question, you are wondering how you can have a dataframe which would allow you to run an autoregressive model with multiple lagged variables as predictors i.e. x_t-1, x_t-2, …, x_t-n where n<t. If so, you would have to generate n different dataframes for each lagged variable then join them together. So, do this d1= df_onegrp.set_index([“date”]).shift(1)), d2= df_onegrp.set_index([“date”]).shift(2)),…, dn= df_onegrp.set_index([“date”]).shift(n)). Then use pandas join, merge or concatenate to put them together. Hope this helps.

--

--

Tich Mangono
Tich Mangono

Written by Tich Mangono

Passionate about public health, python, machine learning, and data science. I also share my ideas on https://tichmangono.github.io/

No responses yet