I have a question regarding the result from the bfast function in R. Let’s assume I have a time series where no break is detected.
library(bfast)
library(zoo)
NDVI <- as.ts(zoo(som$NDVI.b,som$Time))
NDVI_w <- window(NDVI, c(2001, 4) , c(2008, 13))
fit <- bfast(NDVI_w, h=1/2, season="dummy", max.iter=1)
plot(fit)
How can I extract the slope value of the trend component from the bfast (fit) object? The option 'plot' with ANOVA=TRUE doesn't work.
plot(fit, ANOVA=TRUE)$slope
One option could be, to compute it based on the provided trend component, but is there any way to get it directly from the 'fit' object?
out <- fit$output[[1]]
plot(out$Tt)
lm(out$Tt ~ time(out$Tt))$coefficients[2]
Any hint is more than appreciated.
You have already figured out (presumably from the help file) that the trend component is given by fit$output[[1]]$Tt
.
You say you want the "slope value of the trend component". So simply take the slope from the first two trend values:
diff(fit$output[[1]]$Tt[1:2])/diff(time(fit$output[[1]]$Tt)[1:2])
.