bfast2 / bfast2/strucchangeRcpp

mefp: Error in root.matrix(crossprod(X)): matrix is not positive semidefinite

Offen
#22 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug help wanted
Vorherrschende Sprache
R
Sterne
6
Forks
5
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I have run into a (rare) case where the root of a matrix cannot be found because it's indefinite. Here's a reprex using the bfast package:

``` r
library(bfast)
BugTS = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 2, 2, 3, 5, NA, NA, 3, 2, 3, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, NA, 0, 1, NA, 0, 1)
BugTS = ts(BugTS, start=2009, frequency = 23)
bfastmonitor(BugTS, start=2016, type = "ME")
#> Error in root.matrix(crossprod(X)): matrix is not positive semidefinite
```

Created on 2020-04-07 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0)

Using @appelmar's C++ code, the same error is rendered as:
```r
Error in .sc_cpp_efp_process_me(X, y, rescale, h) :
sqrtmat_sympd(): transformation failed
```

This fails when `type` is set to `ME`, but it works with any other `mefp` types.

Is there a way to detect that this would happen, and then fall back to some other fluctuation process type instead?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginnen Sie damit, das bereitgestellte bfastmonitor-Beispiel mit type="ME" zu reproduzieren; verfolgen Sie dann den Fehler von mefp über .sc_cpp_efp_process_me und root.matrix(crossprod(X)) zurück. Vergleichen Sie diesen Pfad mit den anderen mefp-Typen und bestimmen Sie, welches Verhalten erwartet wird, wenn die Matrix nicht positiv semidefinit ist. Erledigt ist die Aufgabe, wenn der Fehler erkannt wird und das vereinbarte Fallback oder das für Benutzer sichtbare Verhalten durch einen Regressionstest abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, r
Bereich
data
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
28/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.