bfast2 / bfast2/strucchangeRcpp

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

Aperta
#22 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug help wanted
Lingua principale
R
Stelle
6
Fork
5
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia riproducendo l’esempio fornito di bfastmonitor con type="ME", quindi segui il fallimento da mefp attraverso .sc_cpp_efp_process_me e root.matrix(crossprod(X)). Confronta questo percorso con gli altri tipi di mefp e determina quale comportamento ci si aspetta quando la matrice non è semidefinita positiva. Il lavoro è completo quando il fallimento viene rilevato e il fallback concordato o il comportamento visibile all’utente è coperto da un test di regressione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, r
Ambito
data
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
28/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.