0
$\begingroup$

I am confused about using nnetar.

All my training time series data are positive numbers, but the forecast results obtained from nnetar returns negative numbers. The following is my code

myts <- ts(data, freq = 5)
fit <- nnetar(myts)
fcast <- forecast(fit, h = 100)

However, if I forecast only short period of time e.g., h = 10 or 20. The returned values are positive.

Did I do anything wrong ?

Thank you.

$\endgroup$

1 Answer 1

3
$\begingroup$

If you think it's unreasonable to get negative forecasts in this case, you could set lambda = 0 to achieve strictly positive forecasts.

fit <- nnetar(myts, lambda = 0)
fcast <- forecast(fit, h = 100)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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