| beast.irreg | R Documentation |
beast.irreg applies the BEAST (Bayesian Estimator of Abrupt change, Seasonal change, and Trend) model to irregular or unordered time series or 1D sequential data. BEAST is a Bayesian model averaging algorithm for decomposing time series or other 1D sequential data into individual components, including abrupt changes, trends, and periodic/seasonal variations. It is useful for changepoint detection (e.g., breakpoints or structural breaks), nonlinear trend analysis, time series decomposition, and time series segmentation. beast123 is a low-level interface to BEAST.
Internally, irregular observations are first aggregated into an evenly spaced (regular) time series at a user-specified time interval, and then decomposed into individual components such as abrupt changes, nonlinear trends, and periodic/seasonal variations.
beast.irreg(
y,
time,
deltat = NULL,
season = c("harmonic", "svd", "dummy", "none"),
period = NULL,
scp.minmax = c(0, 10), sorder.minmax = c(0, 5),
tcp.minmax = c(0, 10), torder.minmax = c(0, 1),
sseg.min = NULL, sseg.leftmargin = NULL, sseg.rightmargin = NULL,
tseg.min = NULL, tseg.leftmargin = NULL, tseg.rightmargin = NULL,
s.complexfct = 0.0,
t.complexfct = 0.0,
method = c("bayes", "bic", "aic", "aicc", "hic",
"bic0.25", "bic0.5", "bic1.5", "bic2"),
detrend = FALSE,
deseasonalize = FALSE,
mcmc.seed = 0,
mcmc.burnin = 200,
mcmc.chains = 3,
mcmc.thin = 5,
mcmc.samples = 8000,
precValue = 1.5,
precPriorType = c("componentwise", "uniform", "constant", "orderwise"),
hasOutlier = FALSE,
ocp.minmax = c(0, 10),
print.param = TRUE,
print.progress = TRUE,
print.warning = TRUE,
quiet = FALSE,
dump.ci = FALSE,
dump.mcmc = FALSE,
gui = FALSE,
...
)
y |
If |
time |
|
deltat |
Numeric or character; the time interval used to aggregate the irregular time series into a regular one. The BEAST model is formulated for regular (evenly spaced) data; therefore
To specify the unit explicitly, supply a character string, for example |
season |
Character (default
|
period |
Numeric or character. The period of the seasonal/periodic component in The period must have units consistent with
If |
scp.minmax |
Integer vector of length 2 ( If If both values are 0, no seasonal changepoints are allowed; a global harmonic (or SVD/dummy) model is used, but the most likely harmonic order is still inferred if |
sorder.minmax |
Integer vector of length 2 ( If |
tcp.minmax |
Integer vector of length 2 ( If If both values are 0, no trend changepoints are allowed; a global polynomial trend is used, but the most likely polynomial order is still inferred if |
torder.minmax |
Integer vector of length 2 ( If |
sseg.min |
Integer (
|
sseg.leftmargin |
Integer (
|
sseg.rightmargin |
Integer (
|
tseg.min |
Integer (
|
tseg.leftmargin |
Integer (
|
tseg.rightmargin |
Integer (
|
s.complexfct |
Numeric (default |
t.complexfct |
Numeric scalar (default |
method |
Character (default
|
detrend |
Logical; if |
deseasonalize |
Logical; if |
mcmc.seed |
Integer ( |
mcmc.chains |
Integer ( |
mcmc.thin |
Integer ( |
mcmc.burnin |
Integer ( |
mcmc.samples |
Integer ( |
precValue |
Numeric ( |
precPriorType |
Character; one of
|
hasOutlier |
Logical; if
Outliers are modeled as changepoints that cannot be captured by trend or seasonal terms. |
ocp.minmax |
Integer vector of length 2 ( |
print.param |
Logical; if |
print.progress |
Logical; if |
print.warning |
Logical; if |
quiet |
Logical; if |
dump.ci |
Logical; if |
dump.mcmc |
Logical; if |
gui |
Logical; if |
... |
Additional implementation-level arguments passed to the underlying |
An object of class "beast", i.e., a list with components similar to those returned by beast and beast123. Below we assume the input y is a single time series of length N:
time |
Numeric vector of length |
data |
A vector, matrix, or 3D array containing a copy of the regularized input data if |
marg_lik |
Numeric; the (average) model marginal likelihood. Larger values correspond to better fits for a given time series (e.g., |
R2 |
Numeric; coefficient of determination ( |
RMSE |
Numeric; root mean squared error of the fitted model. |
sig2 |
Numeric; estimated variance of the model residuals. |
trend |
List containing summaries for the estimated trend component:
|
season |
List containing summaries for the estimated seasonal/periodic component (if present):
|
outlier |
|
The three functions beast(), beast.irreg(), and beast123() implement the same BEAST algorithm but expose different APIs:
beast() operates on regular (evenly spaced) time series.
beast.irreg() accepts irregular/unordered data and internally aggregates it to regular intervals.
beast123() exposes a low-level interface via four lists: metadata, prior, mcmc, and extra.
There is a one-to-one correspondence between arguments of beast() / beast.irreg() and fields in metadata, prior, mcmc, and extra used by beast123(), Examples include:
start | <-> | metadata$startTime |
deltat | <-> | metadata$deltaTime |
deseasonalize | <-> | metadata$deseasonalize |
hasOutlier | <-> | metadata$hasOutlier |
scp.minmax[1:2] | <-> | prior$seasonMinKnotNum, prior$seasonMaxKnotNum |
sorder.minmax[1:2] | <-> | prior$seasonMinOrder, prior$seasonMaxOrder |
sseg.min | <-> | prior$seasonMinSepDist |
tcp.minmax[1:2] | <-> | prior$trendMinKnotNum, prior$trendMaxKnotNum |
torder.minmax[1:2] | <-> | prior$trendMinOrder, prior$trendMaxOrder |
tseg.leftmargin | <-> | prior$trendLeftMargin |
tseg.rightmargin | <-> | prior$trendRightMargin |
s.complexfct | <-> | prior$seasonComplexityFactor |
t.complexfct | <-> | prior$trendComplexityFactor |
mcmc.seed | <-> | mcmc$seed |
dump.ci | <-> | extra$computeCredible. |
Advanced users who need full control over all internal options are encouraged to use beast123() directly.
Zhao, K., Wulder, M. A., Hu, T., Bright, R., Wu, Q., Qin, H., Li, Y., Toman, E., Mallick, B., Zhang, X. and Brown, M. (2019). Detecting change-point, trend, and seasonality in satellite time series data to track abrupt changes and nonlinear dynamics: A Bayesian ensemble algorithm. Remote Sensing of Environment, 232, 111181. (The main BEAST algorithm paper.)
Zhao, K., Valle, D., Popescu, S., Zhang, X. and Mallick, B. (2013). Hyperspectral remote sensing of plant biochemistry using Bayesian model averaging with variable and band selection. Remote Sensing of Environment, 132, 102–119. (The Bayesian MCMC scheme used in BEAST.)
Hu, T., Toman, E. M., Chen, G., Shao, G., Zhou, Y., Li, Y., Zhao, K. and Feng, Y. (2021). Mapping fine-scale human disturbances in a working landscape with Landsat time series on Google Earth Engine. ISPRS Journal of Photogrammetry and Remote Sensing, 176, 250–261. (Example application of BEAST.)
beast,
beast123,
minesweeper,
tetris,
geeLandsat
library(Rbeast)
################################################################################
# Note: The BEAST algorithm is implemented for regular time series.
# \code{beast.irreg} accepts irregular data but internally aggregates it to a
# regular series before applying BEAST. For aggregation, both "time" and
# "deltat" are needed to specify the original timestamps via "time" and the desired
# regular interval via "deltat". If a cyclic component exists, "period" should also
# be provided; otherwise BEAST attempts to guess it via autocorrelation.
################################################################################
# 'ohio' is a data.frame containing an irregular Landsat time series of
# reflectances and NDVI at an Ohio site. It includes multiple alternative
# date formats: year (Y), month (M), day (D), day-of-year (doy), R "Date"
# (rdate), and fractional year (time).
data(ohio)
str(ohio)
plot(ohio$rdate, ohio$ndvi, type = "o") # NDVI is irregular and unordered in time
################################################################################
# Example 1: 'time' as numeric values
# Below, 'time' is given as numeric values, which can be of any arbitray unit. Although
# here 1/12 can be interepreted as 1/12 year, BEAST itself doesn't care about the unit.
# So, the unit of 1/12 is irrelevant for BEAST. 'period' is missing
# and a guess of it is used.
################################################################################
o <- beast.irreg(ohio$ndvi, time = ohio$time, deltat = 1/12)
plot(o)
print(o)
################################################################################
# Example 2: Aggregate to a monthly interval (deltat = 1/12) and provide 'period'
################################################################################
o <- beast.irreg(ohio$ndvi, time = ohio$time, deltat = 1/12, period = 1.0)
# Alternative (deprecated argument 'freq'):
# o <- beast.irreg(ohio$ndvi, time = ohio$time, deltat = 1/12, freq = 12)
## Not run:
################################################################################
# Example 3: Aggregate at a half-monthly interval.
# Here period = 1: freq = period/deltat = 1/(1/24)=24 data points per period
################################################################################
o <- beast.irreg(ohio$ndvi, time = ohio$time, deltat = 1/24, period = 1)
################################################################################
# Example 4: 'time' as R Dates (i.e, ohio$rdate). Unit is YEAR; 1/12 is ~1 month.
################################################################################
o <- beast.irreg(ohio$ndvi, time = ohio$rdate, deltat = 1/12)
################################################################################
# Example 5: 'time' as date strings. The unit is YEAR such that 1/12 is a month
################################################################################
o=beast.irreg(ohio$ndvi, time=ohio$datestr1,deltat=1/12) #"LT4-1984-03-27" (YYYY-MM-DD)
o=beast.irreg(ohio$ndvi, time=ohio$datestr2,deltat=1/12) #"LT4-1984087ndvi" (YYYYDOY)
o=beast.irreg(ohio$ndvi, time=ohio$datestr3,deltat=1/12) #"1984,, 3/ 27" (YYYY M D)
################################################################################
# Example 6: 'time' as date strings with explicit format specifiers
################################################################################
TIME <- list()
TIME$datestr <- ohio$datestr1
TIME$strfmt <- "LT4-YYYY-MM-DD" # e.g., "LT4-1984-03-27"
o <- beast.irreg(ohio$ndvi, time = TIME, deltat = 1/12)
TIME <- list()
TIME$datestr <- ohio$datestr2
TIME$strfmt <- "LT4-YYYYDOYndvi" # e.g., "LT4-1984087ndvi"
o <- beast.irreg(ohio$ndvi, time = TIME, deltat = 1/12)
################################################################################
# Example 7: 'time' as a list of date components
################################################################################
TIME <- list()
TIME$year <- ohio$Y
TIME$month <- ohio$M
TIME$day <- ohio$D
o <- beast.irreg(ohio$ndvi, time = TIME, deltat = 1/12)
TIME <- list()
TIME$year <- ohio$Y
TIME$doy <- ohio$doy
o <- beast.irreg(ohio$ndvi, time = TIME, deltat = 1/12)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.