Skip to content

arma: decide negative_values from the training data only - #182

Closed
gitRasheed wants to merge 1 commit into
rasheed/py-cumhaz-targetfrom
rasheed/py-arma-train-support
Closed

gitRasheed wants to merge 1 commit into
rasheed/py-cumhaz-targetfrom
rasheed/py-arma-train-support

Conversation

@gitRasheed

Copy link
Copy Markdown
Collaborator

R's NNS.ARMA switched negative.values on when any value of the variable was negative, including values after training.set that the forecast never sees. A held-out negative therefore removed the clamp at 0 from the forecast. OVVO-Financial/NNS#135 (merged) decides from variable[1:training.set]. NNS.ARMA.optim does the same for its validation forecasts and decides the out-of-sample forecast from the whole series, which it is fitted on. This slice mirrors it.

Stacked on #181; merge with a merge commit.

Changes

  • nns_arma checks for negatives after cutting the variable to training_set.
  • nns_arma_optim checks values[:training_set] for the validation forecasts and their clamp. With h set, the out-of-sample forecast and its bands use results_negative_values, which is also on when any value of the whole series is negative.
  • Before and after, with after equal to R main: nns_arma([20..1, -1], h=3, training_set=20, seasonal_factor=1, method="lin") [0, -1, -2] -> [0, 0, 0]. For R's optim test series (58, 56, ..., 2, 1, .5, .2, .1, -.1, training_set=29), the validation forecasts used to run negative (errors -0.78 down to -7.15); they are now clamped, and errors (-0.778, -0.5, -0.2, -0.1, 0.1) and bias.shift 0.3296 equal R main's to 1e-12.

Tests

Review

GPT-6.1 Sol reviewed the #135, #127 and #126 mirrors together: SHIP.

Mirrors OVVO-Financial/NNS#135

…n-support)

Mirrors R NNS.ARMA and NNS.ARMA.optim (OVVO-Financial/NNS
arma-train-support). nns_arma switched negative_values on when any value of
the variable was negative, including values after training_set that the
forecast never sees, so a held-out negative removed the clamp at 0 from the
forecast. It now looks at variable[:training_set] only.

nns_arma_optim scores validation forecasts from the training window, so it
also decides from variable[:training_set]. The out-of-sample forecast (h
set) is fitted on the whole series, so it and its bands stay unclamped when
any value is negative.

Before -> after (= R main):
  nns_arma([20..1, -1], h=3, training_set=20, seasonal_factor=1, method="lin")
                                                     [0, -1, -2] -> [0, 0, 0]
  nns_arma_optim on 58, 56, ..., 2, 1, .5, .2, .1, -.1 (training_set=29)
    validation forecasts were negative (errors -0.78, -2.14, ..., -7.15);
    now clamped (errors -0.78, -0.5, -0.2, -0.1, 0.1, bias.shift 0.33)

No cache entry moves.
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Incorporated through NNS R 14.0 integration #192, merged as bd19c3303222af46da79d8c97f258248eb5674d2. Verified exact head 38f6b803f383069a63f5ba0a88d4f01dd7b2d046 is an ancestor of main; original commits and authorship are preserved. The integration includes the subsequent R14 compatibility corrections and passed the complete GitHub Python 3.11-3.14 matrix. This supersedes the separate landing, not the work or review history.

@github-actions github-actions Bot closed this Nov 7, 2026
@github-actions
github-actions Bot deleted the rasheed/py-arma-train-support branch November 7, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant