Description Usage Arguments Details Value Author(s) Examples
View source: R/Finalised_coding.R
This function estimates the signal in a given data sequence x
with changepoints
at cpt
. The type of the signal depends on whether the changepoints represent changes
in a piecewiseconstant or continuous, piecewiselinear signal. For more information see
Details below.
1  est_signal(x, cpt, type = c("mean", "slope"))

x 
A numeric vector containing the given data. 
cpt 
A positive integer vector with the locations of the changepoints.
If missing, the 
type 
A character string, which defines the type of the detected changepoints.
If 
The data points provided in x
are assumed to follow
X_t = f_t + σε_t; t = 1,2,...,T,
where T is the total length of the data sequence, X_t are the observed
data, f_t is a onedimensional, deterministic signal with abrupt structural
changes at certain points, and ε_t is white noise. We denote by
r_1, r_2, ..., r_N the elements in cpt
and by r_0 = 0 and
r_{N+1} = T. Depending on the value that has been passed to type
, the returned
value is calculated as follows.
For type = ``mean''
, in each segment (r_j + 1, r_{j+1}), f_t for
t \in (r_j + 1, r_{j+1}) is approximated by the mean of X_t calculated
over t \in (r_j + 1, r_{j+1}).
For type = ``slope''
, f_t is approximated by the linear spline fit with
knots at r_1, r_2, ..., r_N minimising the l_2 distance between the fit and the data.
A numeric vector with the estimated signal.
Andreas Anastasiou, a.anastasiou@lse.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13 14  single.cpt.pcm < c(rep(4,1000),rep(0,1000))
single.cpt.pcm.noise < single.cpt.pcm + rnorm(2000)
cpt.single.pcm < ID_pcm(single.cpt.pcm.noise)
fit.cpt.single.pcm < est_signal(single.cpt.pcm.noise, cpt.single.pcm$cpt, type = "mean")
three.cpt.pcm < c(rep(4,500),rep(0,500),rep(4,500),rep(1,500))
three.cpt.pcm.noise < three.cpt.pcm + rnorm(2000)
cpt.three.pcm < ID_pcm(three.cpt.pcm.noise)
fit.cpt.three.pcm < est_signal(three.cpt.pcm.noise, cpt.three.pcm$pcm, type = "mean")
single.cpt.plm < c(seq(0,999,1),seq(998.5,499,0.5))
single.cpt.plm.noise < single.cpt.plm + rnorm(2000)
cpt.single.plm < ID_cplm(single.cpt.plm.noise)
fit.cpt.single.plm < est_signal(single.cpt.plm.noise, cpt.single.plm$cpt, type = "slope")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.