bfast01 | R Documentation |
A function to select a suitable model for the data by choosing either a model with 0 or with 1 breakpoint.
bfast01(
data,
formula = NULL,
test = "OLS-MOSUM",
level = 0.05,
aggregate = all,
trim = NULL,
bandwidth = 0.15,
functional = "max",
order = 3,
lag = NULL,
slag = NULL,
na.action = na.omit,
reg = c("lm", "rlm"),
stl = "none",
sbins = 1
)
data |
A time series of class |
formula |
formula for the regression model. The default is
intelligently guessed based on the arguments order/lag/slag i.e.
|
test |
character specifying the type of test(s) performed. Can be one
or more of BIC, supLM, supF, OLS-MOSUM, ..., or any other test supported by
|
level |
numeric. Significance for the
|
aggregate |
function that aggregates a logical vector to a single
value. This is used for aggregating the individual test decisions from
|
trim |
numeric. The mimimal segment size passed to the |
bandwidth |
numeric scalar from interval (0,1), functional. The
|
functional |
arguments passed on to
|
order |
numeric. Order of the harmonic term, defaulting to |
lag |
numeric. Order of the autoregressive term, by default omitted. |
slag |
numeric. Order of the seasonal autoregressive term, by default omitted. |
na.action |
arguments passed on to |
reg |
whether to use OLS regression |
stl |
argument passed on to |
sbins |
argument passed on to |
bfast01
tries to select a suitable model for the data by choosing
either a model with 0 or with 1 breakpoint. It proceeds in the following
steps:
The data is preprocessed with bfastpp using the arguments
order
/lag
/slag
/na.action
/stl
/sbins
.
A linear model with the given formula is fitted. By default a suitable formula is guessed based on the preprocessing parameters.
The model with 1 breakpoint is estimated as well where the breakpoint is chosen to minimize the segmented residual sum of squares.
A sequence of tests for the null hypothesis of zero breaks is performed. Each test results in a decision for FALSE (no breaks) or TRUE (structural break(s)). The test decisions are then aggregated to a single decision (by default using all() but any() or some other function could also be used).
Available methods for the object returned include standard methods for linear models (coef, fitted, residuals, predict, AIC, BIC, logLik, deviance, nobs, model.matrix, model.frame), standard methods for breakpoints (breakpoints, breakdates), coercion to a zoo series with the decomposed components (as.zoo), and a plot method which plots such a zoo series along with the confidence interval (if the 1-break model is visualized). All methods take a 'breaks' argument which can either be 0 or 1. By default the value chosen based on the 'test' decisions is used.
Note that the different tests supported have power for different types of alternatives. Some tests (such as supLM/supF or BIC) assess changes in all coefficients of the model while residual-based tests (e.g., OLS-CUSUM or OLS-MOSUM) assess changes in the conditional mean. See Zeileis (2005) for a unifying view.
bfast01
returns a list of class "bfast01"
with the
following elements:
call |
the original function call. |
data |
the
data preprocessed by |
formula |
the model formulae. |
breaks |
the number of breaks chosen based on the |
test |
the individual test decisions. |
breakpoints |
the optimal breakpoint for the model with 1 break. |
model |
A list of two 'lm' objects with no and one breaks, respectively. |
Achim Zeileis, Jan Verbesselt
rogierbfast01bfast
\insertRefachimstrucchangebfast
bfastmonitor
,
breakpoints
library(zoo)
## define a regular time series
ndvi <- as.ts(zoo(som$NDVI.a, som$Time))
## fit variations
bf1 <- bfast01(ndvi)
bf2 <- bfast01(ndvi, test = c("BIC", "OLS-MOSUM", "supLM"), aggregate = any)
bf3 <- bfast01(ndvi, test = c("OLS-MOSUM", "supLM"), aggregate = any, bandwidth = 0.11)
## inspect test decisions
bf1$test
bf1$breaks
bf2$test
bf2$breaks
bf3$test
bf3$breaks
## look at coefficients
coef(bf1)
coef(bf1, breaks = 0)
coef(bf1, breaks = 1)
## zoo series with all components
plot(as.zoo(ndvi))
plot(as.zoo(bf1, breaks = 1))
plot(as.zoo(bf2))
plot(as.zoo(bf3))
## leveraged by plot method
plot(bf1, regular = TRUE)
plot(bf2)
plot(bf2, plot.type = "multiple",
which = c("response", "trend", "season"), screens = c(1, 1, 2))
plot(bf3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.