bfast icon indicating copy to clipboard operation
bfast copied to clipboard

bfast01: error: inadmissable change points: 'from' is larger than 'to'

Open GreatEmerald opened this issue 7 years ago • 2 comments

This call to Fstat in bfast01() causes an error for some inputs: https://github.com/GreatEmerald/bfast/blob/6e86571601510ea33af4daa16b0e36564995bd54/R/bfast01.R#L156 The error is inadmissable change points: 'from' is larger than 'to'. Setting trim to a low number (~7) makes it not give this error any more.

I'd need some input data for reproducing it easier, but overall I'm not sure why that call to Fstat is there? In the regular bfast, this functionality is handled by bfastts and bfastpp instead.

GreatEmerald avatar Sep 12 '18 11:09 GreatEmerald

I get similar errors. When I make trim a high value, e.g. trim=30, I get the same error: "Error in Fstats(formula, data = data, from = trim) : inadmissable change points: 'from' is larger than 'to'". When I make trim a low value, e.g trim=7, the bfast01 function runs but gives this warning: "Warning messages: 1: In Fstats(formula, data = data, from = trim) : 'from' changed (was too small) 2: In Fstats(formula, data = data, from = trim) : 'to' changed (was too large)"

However, when I set trim=10, it works with no errors. Not sure why the different values of trim yield these different results...

lohanisa avatar Sep 12 '18 23:09 lohanisa

Here is a working example to show the error.

#Sample Data generation
x <- c(0.0000000, 0.6905839, 0.0000000, 0.0000000, 0.0000000, 0.6203174, 0.7495670, 0.8922589, 0.0000000, 0.8118162, 0.7776124, 0.7903695, 0.7772792, 0.7911822, 0.6697724, 0.7787854, 0.7466174, 0.8167376, 0.8350126, 0.6607103, 0.0000000, 0.0000000, 0.8077003, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.8550257, 0.8674726, 0.0000000, 0.8035716, 0.8448063, 0.8292227, 0.8302566, 0.8582140, 0.7552253, 0.7950909, 0.7737473, 0.7849059, 0.6325678, 0.7869667, 0.8124328, 0.8301651, 0.7248341, 0.0000000, 0.7983519)

#time series
x_TS <- ts(data=x,start=2016, end=2018, deltat = 0.5/12)

#bfast01, error with trim values
ex_bfast01 <- bfast01(data = x_TS,
                     formula = response ~ trend + harmon,
                     test = "OLS-MOSUM",
                     level = 0.05,
                     bandwidth = 0.15, 
                     trim = 10)

##when trim=30, error is : "Error in Fstats(formula, data = data, from = trim) : inadmissable change points: 'from' is larger than 'to'". 
#When trim is a low value, e.g trim=7, the bfast01 function runs but gives this warning: "Warning messages:
#1: In Fstats(formula, data = data, from = trim) :
## 'from' changed (was too small)
#2: In Fstats(formula, data = data, from = trim) :
## 'to' changed (was too large)"
#when trim=10, it works with no errors

lohanisa avatar Sep 17 '18 22:09 lohanisa