Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Un-differencing the data? #1

Closed
shenxiangzhuang opened this issue Jul 12, 2021 · 2 comments
Closed

How to Un-differencing the data? #1

shenxiangzhuang opened this issue Jul 12, 2021 · 2 comments

Comments

@shenxiangzhuang
Copy link

shenxiangzhuang commented Jul 12, 2021

Hello Jinit, I have read your awesome code in this repo and the article in medium which helps me a lot and thank you for your work. But I can not grasp the key idea about the way of Un-differencing the data. Could you please explain the code with more details?

df_c.Value += np.log(df).shift(1).Value
df_c.Value += np.log(df).diff().shift(12).Value
df_c.Predicted_Values += np.log(df).shift(1).Value 
df_c.Predicted_Values += np.log(df).diff().shift(12).Value
df_c.Value = np.exp(df_c.Value)
df_c.Predicted_Values = np.exp(df_c.Predicted_Values)
@jinit24
Copy link
Owner

jinit24 commented Jul 13, 2021

The differencing is done using :

pd.DataFrame(np.log(df.Value).diff().diff(12))

So if the differencing was just shift(1), you'd add only the shift(1).value (This was the value that was removed)
But now that we are differencing twice, you have to add the shift(1), then the shift(1) shifted by 12.

@jinit24 jinit24 closed this as completed Jul 20, 2021
@shenxiangzhuang
Copy link
Author

Sorry for my late reply, and I try to figure out the transformation by these equations as fellows, which I think may help others in a way~
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants