predict.not: Estimate signal for a 'not' object.

View source: R/predict.R

predict.notR Documentation

Estimate signal for a 'not' object.

Description

Estimates signal in object$x with change-points at cpt. The type of the signal depends on on the value of contrast that has been passed to not (see details below).

Usage

## S3 method for class 'not'
predict(object, cpt, ...)

Arguments

object

An object of class 'not', returned by not.

cpt

An integer vector with locations of the change-points. If missing, the features is called internally to extract the change-points from object.

...

Further parameters that can be passed to predict.not and features.

Details

The data points provided in object$x are assumed to follow

Y_t= f_t + sigma_t varepsilon_t,

for t=1,...,n, where n is the number of observations in object$x, the signal f_t and the standard deviation sigma_{t} are non-stochastic with change-points at locations given in cpt and varepsilon_t is a white-noise. Denote by tau_1, ..., tau_q the elements in cpt and set tau_0=0 and tau_q+1=T. Depending on the value of contrast that has been passed to not to construct object, the returned value is calculated as follows.

  • For contrast="pcwsConstantMean" and contrast="pcwsConstantMeanHT", in each segment (tau_j +1, tau_(j+1)), f_t for t in (tau_j +1, tau_(j+1)) is approximated by the mean of Y_t calculated over t in (tau_j +1, tau_(j+1)).

  • For contrast="pcwsLinContMean", f_{t} is approximated by the linear spline fit with knots at tau_1, ..., tau_q minimising the l2 distance between the fit and the data.

  • For contrast="pcwsLinMean" in each segment (tau_j +1, tau_(j+1)), the signal f_t for t in (tau_j +1, tau_(j+1)) is approximated by the line alpha_j + beta_j j, where the regression coefficients are found using the least squares method.

  • For contrast="pcwsQuad", the signal f_t for t in (tau_j +1, tau_(j+1)) is approximated by the curve alpha_j + beta_j j + gamma_j^2, where the regression coefficients are found using the least squares method.

  • For contrast="pcwsConstMeanVar", in each segment (tau_j +1, tau_(j+1)), f_t and sigma_t for t in (tau_j +1, tau_(j+1)) are approximated by, respectively, the mean and the standard deviation of Y_t, both calculated over t in (tau_j +1, tau_(j+1)).

Value

A vector wit the estimated signal or a two-column matrix with the estimated estimated signal and standard deviation if contrast="pcwsConstMeanVar" was used to construct object.

See Also

not

Examples

# **** Piecewisce-constant mean with Gaussian noise.
x <- c(rep(0, 100), rep(1,100)) + rnorm(100)
# *** identify potential locations of the change-points
w <- not(x, contrast = "pcwsConstMean")
# *** when 'cpt' is omitted, 'features' function is used internally 
# to choose change-points locations
signal.est <- predict(w)
# *** estimate the signal specifying the location of the change-point
signal.est.known.cpt <- predict(w, cpt=100)
# *** pass arguments of the 'features' function through 'predict'.
signal.est.aic <- predict(w, penalty.type="aic")

# **** Piecewisce-constant mean and variance with Gaussian noise.
x <- c(rep(0, 100), rep(1,100)) + c(rep(2, 100), rep(1,100)) * rnorm(100)
# *** identify potential locations of the change-points
w <- not(x, contrast = "pcwsConstMeanVar")
# *** here signal is two-dimensional
signal.est <- predict(w)

rbaranowski/not documentation built on March 22, 2022, 1:18 p.m.