Package 'changepointsVar'

Title: Change-Points Detections for Changes in Variance
Description: Detection of change-points for variance of heteroscedastic Gaussian variables with piecewise constant variance function. Adelfio, G. (2012), Change-point detection for variance piecewise constant models, Communications in Statistics, Simulation and Computation, 41:4, 437-448, <doi:10.1080/03610918.2011.592248>.
Authors: Gianluca Sottile [cre], Giada Adelfio [aut]
Maintainer: Gianluca Sottile <[email protected]>
License: GPL-2
Version: 0.1.1
Built: 2024-11-23 03:31:07 UTC
Source: https://github.com/cran/changepointsVar

Help Index


Change-Points Detections for Changes in Variance

Description

This algorithm allows breakpoint detections for changes in variation assuming that the variance function can be described by a piecewise constant function with segments delimited by unknown change-points. The approach is a generalization of the cumSeg procedure proposed by Muggeo and Adelfio (2011) assuming that testing for stepwise changes in variance of a sequence of Gaussian random variables may be transformed equivalently to the case of testing for changes in mean of the squared residuals (from an estimated linear model that accounts for the mean behavior of the observed signal) assuming a gamma GLM with a log-link function. A variation of lars procedure adapted to the GLM case is considered to discard the spurious change-points on the basis of a generalized version of the BIC. The proposed approach results in a very efficient algorithm even with n large and many change-points to be estimated. Adelfio, G. (2012), Change-point detection for variance piecewise constant models, Communications in Statistics, Simulation and Computation, 41:4, 437-448. Muggeo, V.M.R., Adelfio, G. (2011) Efficient change point detection for genomic sequences of continuous measurements, Bioinformatics 27, 161-166.

Details

Package: jumpointsVar
Type: Package
Version: 0.1.1
Date: 2024-01-22
License: GPL-2

The function jumpointsVar allows to specify the variable in which to look for change-point in variance. The auxiliary function plot.jumpointsVar can be used to plot the brekpoints detected from the main algorithm.

Author(s)

Giada Adelfio

Maintainer: Gianluca Sottile <[email protected]>

References

Adelfio, G. (2012), Change-point detection for variance piecewise constant models, Communications in Statistics, Simulation and Computation, 41:4, 437-448

Muggeo, V.M.R., Adelfio, G. (2011) Efficient change point detection for genomic sequences of continuous measurements, Bioinformatics 27, 161-166.

Examples

##---- see jumpointsVar documentation ----

Auxiliary function for controlling model fitting

Description

Auxiliary function as user interface for model fitting. Typically only used when calling 'jumpointsVar'

Usage

fit.control(toll=0.001, it.max=10, last=TRUE, scale.res=FALSE,
            maxit.glm=30, h=1, stop.if.error=FALSE)

Arguments

toll

positive convergence tolerance.

it.max

integer giving the maximal number of iterations.

last

Currently ignored.

scale.res

logical indicating if the residuals have to be scaled.

maxit.glm

Currently ignored.

h

Currently ignored.

stop.if.error

logical indicating if the algorithm should stop when one or more estimated changepoints do not assume admissible values. Default is FALSE which implies automatic changepoint selection.

Value

A list with the arguments as components to be used by 'jumpointsVar'.

Author(s)

Gianluca Sottile Maintainer: Gianluca Sottile <[email protected]>

See Also

jumpointsVar


Change-point detection for variance piecewise constant models

Description

Detection of change-points for variance of heteroscedastic Gaussian variables with piecewise constant variance function.

Usage

jumpointsVar(y, x, y.res=FALSE, k=min(30, round(length(y)/10)), print.level=0,
             plot.it=FALSE, psi=NULL, round=TRUE, control=fit.control(),
             selection=sel.control())

Arguments

y

the response variable.

x

the 'segmented' variable; if missing simple indices 1,2,... are assumed.

y.res

logical: if FALSE, y is the observed sequence with piecewise constant variance function; if TRUE, y is the vector of the squared residuals from a fitted linear model that accounts for the mean behavior of the observed signal with changes in variation; see Details

k

the starting number of changepoints. It should be quite larger than the supposed number of (true) changepoints. This argument is ignored if starting values of the changepoints are specified via psi.

print.level

the default value is 0 indicating nothing is printed; 1 allows to print some informations during the algorithm; 2 the same as for 1 plus lars information.

plot.it

logical indicating if the curve of the criterion choosen has to be displayed.

psi

numeric vector to indicate the starting values for the changepoints. When psi=NULL (default), k quantiles are assumed

round

logical: if the change-point values should be rounded

control

a list returned by fit.control

selection

a list returned by sel.control

Details

This algorithm allows breakpoint detections for changes in variation assuming that the variance function can be described by a piecewise constant function with segments delimited by unknown change-points.

The approach is a generalization of the cumSeg procedure proposed by Muggeo and Adelfio (2011) assuming that testing for stepwise changes in variance of a sequence of Gaussian random variables may be transformed equivalently to the case of testing for changes in mean of the squared residuals (from an estimated linear model that accounts for the mean behavior of the observed signal) assuming a gamma GLM with a log-link function.

A variation of lars procedure adapted to the GLM case is considered to discard the spurious change-points on the basis of a generalized version of the BIC.

The proposed approach results in a very efficient algorithm even with n large and many change-points to be estimated.

Value

An object of class jumpointsVar. It's a list including several components:

psi

the estimated changepoints

est.means

the estimated means

n.psi

the estimated number of changepoints

psi0

the initial estimated changepoints (before applying the selection criterion)

est.means0

the initial estimated means (before applying the selection criterion)

criterion

the curve of the selected criterion

fitted.values

the fitted values

input

the input parameters

call

the call function

Author(s)

Giada Adelfio

Maintainer: Gianluca Sottile <[email protected]>

References

Adelfio, G. (2012), Change-point detection for variance piecewise constant models, Communications in Statistics, Simulation and Computation, 41:4, 437-448

Muggeo, V.M.R., Adelfio, G. (2011) Efficient change point detection for genomic sequences of continuous measurements, Bioinformatics 27, 161-166.

See Also

plot.jumpointsVar

Examples

set.seed(2)
n = 500
x = 1:n/n
mu = 10+6*sin(3*pi*x)
# if there are two change-points
sigma = c(rep(0.5,.2*n), rep(8,.4*n), rep(3,.4*n))
y = mu + rnorm(n, 0, sigma)
reg = lm(y ~ mu)
h = influence(reg)$hat
r2 = resid(reg)^2/(1-h) + 1
o = jumpointsVar(y=r2, y.res=TRUE, k=30)
o
plot(o)

# if there are no change-points
sigma = 0.5*x
y = mu + rnorm(n, 0, sigma)
reg = lm(y ~ mu)
h = influence(reg)$hat
r2 = resid(reg)^2/(1-h)+1
o = jumpointsVar(y=r2, y.res=TRUE, k=30)
plot(o)

# if the mean behavior of the observed signal is unkown
sigma = c(rep(0.5,.2*n), rep(8,.4*n), rep(3,.4*n))
y = 10 + rnorm(n, 0, sigma)
o = jumpointsVar(y=y, y.res=FALSE, k=30)
plot(o)

Plot method for changes in variance

Description

Plots signal with changes in variance and corresponding changepoints

Usage

## S3 method for class 'jumpointsVar'
plot(x, ...)

Arguments

x

object returned by jumpointsVar

...

additional arguments.

Details

This fuction takes a fitted object returned by jumpointsVar and plots the resulting fit with changepoints.

Value

The function simply plot the fit returned by 'jumpointsVar'

Author(s)

Giada Adelfio

Maintainer: Gianluca Sottile <[email protected]>

References

Adelfio, G. (2012), Change-point detection for variance piecewise constant models,Communications in Statistics, Simulation and Computation, 41:4, 437-448

Muggeo, V.M.R., Adelfio, G. (2011) Efficient change point detection for genomic sequences of continuous measurements, Bioinformatics 27, 161-166.

See Also

jumpointsVar

Examples

##---- see jumpointsVar documentation ----

Auxiliary function for controlling model selection

Description

Auxiliary function as user interface for model selection. Typically only used when calling 'jumpointsVar'

Usage

sel.control(type=c("bic", "rss"), S=1, Cn="2*log(log(n))",
            alg=c("lasso", "stepwise"), edf.psi=TRUE)

Arguments

type

the criterion to be used to perform model selection.

S

if type="rss" the optimal model is selected when the residual sum of squares decreases by the threshold S.

Cn

if type="bic" a character string (as a function of 'n') to specify to generalized BIC. If Cn=1 the standard BIC is used.

alg

which procedure should be used to perform model selection? The value of alg is passed to the argument 'type' of lars.

edf.psi

logical indicating if the number of changepoints should be computed in the model df.

Details

This function specifies how to perform model seletion, namely how many change points should be selected.

Value

A list with the arguments as components to be used by 'jumpointsVar' and in turn by 'lars'.

Author(s)

Gianluca Sottile Maintainer: Gianluca Sottile <[email protected]>

See Also

jumpointsVar, lars