# resid_ID: Calculate the residuals related to the estimated signal In IDetect: Isolate-Detect Methodology for Multiple Change-Point Detection

## 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

 ```1 2``` ```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 `ID` function is called internally to detect any change-points that might be present in `x`. `type_chg` A character string, which defines the type of the detected change-points. If `type_chg = ``mean''`, then the change-points represent the locations of changes in the mean of a piecewise-constant signal. If `type_chg = ``slope''`, then the change-points represent the locations of changes in the slope of a piecewise-linear and continuous signal. `type_res` A choice of ```raw''` and ```standardised''` residuals.

## 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

 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ```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.) ```

IDetect documentation built on May 2, 2019, 11:04 a.m.