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,\ldots,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}, \ldots, \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}, \ldots, \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} t, 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} t + \gamma_{j} t^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)

not documentation built on Oct. 1, 2024, 5:09 p.m.