View source: R/Finalised_coding.R
| resid | R Documentation |
This function returns a 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.
resid(
x,
cpt,
type_chg = c("mean", "slope"),
type_res = c("raw", "standardised")
)
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 "raw" and "standardised" residuals. |
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.
Andreas Anastasiou, anastasiou.andreas@ucy.ac.cy
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(single.cpt.pcm.noise, cpt = cpt_detect$cpt, type_chg = "mean",
type_res = "raw")
residuals_cpt_stand. <- resid(single.cpt.pcm.noise, cpt = cpt_detect$cpt, type_chg = "mean",
type_res = "standardised")
plot(residuals_cpt_raw)
plot(residuals_cpt_stand.)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.