smuce: Piecewise constant regression with SMUCE

Description Usage Arguments Value Note References See Also Examples

View source: R/main.R

Description

Compute the SMUCE estimator for one-dimensional data with i.i.d. Gaussian noises.

Usage

1
smuce(Y, q, alpha = 0.1, r = round(50/min(alpha, 1-alpha)), sd = stepR::sdrobnorm(Y))

Arguments

Y

a numeric vector containing the noisy data

q

threshold value; a scalar number

alpha

significance level; if q is missing, q is chosen as the (1-alpha)-quantile of the null distribution of the multiscale statistic via Monte Carlo simulation, see (Frick et al., 2014) for an explanation

r

numer of Monte Carlo simulations

sd

standard deviation of noises

Value

A list with components

value

function values on each segment of the estimator

left

indices of leftmost points within each segment of the estimator

n

number of samples

Note

This is an efficient implementation of function smuceR in R package stepR (CRAN) for data with i.i.d. Gaussian noises. The detailed algorithm is described in (Seiling, 2013).

References

Frick, K., Munk, A., and Sieling, H. (2014). Multiscale Change-Point Inference. J. R. Statist. Soc. B, with discussion and rejoinder by the authors, 76:495–580.

Seiling, H. (2013). Statistical Multiscale Segmentation: Inference, Algorithms and Applications. PhD thesis, University of Goettingen, Germany.

See Also

fdrseg, dfdrseg, simulQuantile, sdrobnorm, evalStepFun, computeFdp, v_measure

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# simulate data
set.seed(2)
u0 <- c(rep(1, 50), rep(5, 50))
Y  <- rnorm(100, u0)

# compute the estimate (q is automatically simulated)
uh <- smuce(Y)

# plot result
plot(Y, pch = 20, col = "grey", ylab = "", main = expression(alpha*" = 0.1"))
lines(u0, type = "s", col = "blue")
lines(evalStepFun(uh), type = "s", col = "red")
legend("topleft", c("Truth", "SMUCE"), lty = c(1, 1), col = c("blue", "red"))


# other choice of alpha
uh <- smuce(Y, alpha = 0.05)
# plot result
plot(Y, pch = 20, col = "grey", ylab = "", main = expression(alpha*" = 0.05"))
lines(u0, type = "s", col = "blue")
lines(evalStepFun(uh), type = "s", col = "red")
legend("topleft", c("Truth", "SMUCE"), lty = c(1, 1), col = c("blue", "red"))

## Not run: 
# alternatively simulate quantiles first
alpha <- 0.1
q     <- simulQuantile(1 - alpha, 100, type = "smuce")

# then compute the estimate
uh <- smuce(Y, q)
## End(Not run)

FDRSeg documentation built on May 2, 2019, 9:43 a.m.