DPPlotL1Norm: Plot l1-norm of coefficients of each interval computed by DP...

Description Usage Arguments Author(s) References Examples

Description

Plot l1-norm of coefficients of each interval computed by DP approach

Usage

1
DPPlotL1Norm(predictedAlpha, sol, n, p, breaks = NULL)

Arguments

predictedAlpha

predicted coefficients solved by DP approach

sol

list of change-points computed by DP approach

n

total number of data

p

dimension of data

breaks

list of breaks where to put a tick on the x-axis

Author(s)

Bingwen Zhang

References

Bingwen Zhang, Jun Geng and Lifeng Lai, Detecting changes in regression models via sparse group lasso, http://users.wpi.edu/~bzhang/icassp_v1.pdf

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
32
33
34
35
36
37
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (predictedAlpha, sol, n, p, breaks = NULL) 
{
    predictedTheta <- matrix(0, length(sol) - 1, p)
    for (i in 1:(length(sol) - 1)) {
        if (i == 1) {
            predictedTheta[i, ] <- predictedAlpha[i, ]
        }
        else {
            predictedTheta[i, ] <- predictedAlpha[i, ] - predictedAlpha[i - 
                1, ]
        }
    }
    t_sum = mat.or.vec(n, 1)
    for (i in 1:(length(sol) - 1)) {
        t_sum[sol[i]] <- sum(abs(predictedTheta[i, ]))
    }
    plotData <- data.frame(pos = 1:length(t_sum), normL1 = t_sum)
    plotTsum <- ggplot(plotData, aes(pos, normL1))
    {
        if (is.null(breaks)) {
            plotTsum + geom_point() + theme_bw(base_size = 16) + 
                xlab("Number of Observations") + ylab(expression(paste(group("|", 
                group("|", theta[i], "|"), "|"))[1])) + scale_x_continuous(breaks = seq(1, 
                n, floor(n/10)))
        }
        else {
            plotTsum + geom_point() + theme_bw(base_size = 16) + 
                xlab("Number of Observations") + ylab(expression(paste(group("|", 
                group("|", theta[i], "|"), "|"))[1])) + scale_x_continuous(breaks = breaks)
        }
    }
  }

boris109able/ChangePointCalc documentation built on May 13, 2019, 12:34 a.m.