resid_ID {IDetect} | R Documentation |
Calculate the residuals related to the estimated signal
Description
This function returns the difference between x
and the estimated signal
with change-points at cpt
. The input in the argument type_chg
will
indicate the type of changes in the signal.
Usage
resid_ID(x, cpt, type_chg = c("mean", "slope"), type_res = c("raw",
"standardised"))
Arguments
x |
A numeric vector containing the data. |
cpt |
A positive integer vector with the locations of the change-points.
If missing, the |
type_chg |
A character string, which defines the type of the detected change-points.
If |
type_res |
A choice of |
Value
If type_res = ``raw''
, the function returns the difference between the data
and the estimated signal. If type_res = ``standardised''
, then the function
returns the difference between the data and the estimated signal, divided by
the estimated standard deviation.
Author(s)
Andreas Anastasiou, a.anastasiou@lse.ac.uk
Examples
single.cpt.pcm <- c(rep(4,1000),rep(0,1000))
single.cpt.pcm.noise <- single.cpt.pcm + rnorm(2000)
cpt_detect <- ID(single.cpt.pcm.noise, contrast = "mean")
residuals_cpt_raw <- resid_ID(single.cpt.pcm.noise, cpt = cpt_detect$cpt, type_chg = "mean",
type_res = "raw")
residuals_cpt_stand. <- resid_ID(single.cpt.pcm.noise, cpt = cpt_detect$cpt, type_chg = "mean",
type_res = "standardised")
plot(residuals_cpt_raw)
plot(residuals_cpt_stand.)