Reputation: 902
I am using the R package bfast
to detect any change point in a time series, and come across the following error. Is there any suggestion? Thanks a lot.
library(bfast)
Mydata = Nile
bf1 <- bfast01(data = Mydata)
Error in if (is.nan(p0) || p0 < a2 || p0 > (1 - a2)) { : missing value where TRUE/FALSE needed
Upvotes: 0
Views: 413
Reputation: 50718
It seems that bfast01
tries to guess the model from the other function arguments. I'm not too familiar with bfast
but this seems to lead to the error on the Nile
data.
If we explicitly specify the model,
fit <- bfast01(Nile, formula = response ~ trend);
there won't be an error, and bfast01
picks up a change point at index 28.
fit$breakpoints;
#[1] 28
This result is consistent with results from a similar change point analysis using changepoint
:
changepoint::cpt.mean(Nile, class = FALSE);
# cpt conf.value
# 28 1
Note that for the bfast
change point analysis, a model involving only a trend
component seems sufficient, as the seasonal/autoregressive effects occur on a smaller scale. You'll need to check the validity of the model based on your real data.
Upvotes: 3