Just a general question. I am getting negative values in predicted values while doing time series modeling. How can I solve this issue?
d
Dane Lyttinen
09/09/2024, 6:46 AM
Well if there are negative values in your time series then this is expected, if you want to avoid this, one easy thing could be to just ensure there are no negative values in the dataset by adding the minimum value to all the data in your dataset. Then after predictions, you perform the inverse if this operation to negate all values with the absolute value of the minimum
a
Ananya Lohani
09/09/2024, 6:59 AM
Can you please provide a code snippet for it?
d
Dane Lyttinen
09/09/2024, 7:00 AM
Can just paste that into ChatGPT and it will give you what you want lol
a
Ananya Lohani
09/09/2024, 7:02 AM
Can't rely totally on ChatGPT😅....If you have used it somewhere, then kindly share the code snippet.
r
rahul bahadur
09/09/2024, 1:16 PM
If you are predicting something like units sold, then the negative values come from products that sell less and have 0s. One thing I find useful is log transforming the output (Y) variables.
Another approach is, when you are using statsForecasts, you can use Poisson or negativeBinomial family. These distributions are meant for handling such cases.