bfast2 / bfast2/strucchangeRcpp
mefp: Error in root.matrix(crossprod(X)): matrix is not positive semidefinite
- Lenguaje dominante
- R
- Estrellas
- 6
- Forks
- 5
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Empieza reproduciendo el ejemplo proporcionado de bfastmonitor con type="ME"; después, sigue el fallo desde mefp a través de .sc_cpp_efp_process_me y root.matrix(crossprod(X)). Compara esta ruta con los otros tipos de mefp y determina qué comportamiento se espera cuando la matriz no es semidefinida positiva. La tarea estará terminada cuando el fallo se detecte y el fallback acordado o el comportamiento visible para el usuario esté cubierto por una prueba de regresión.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- cpp, r
- Área
- data
- Tipo de issue
- Error
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 28/100