Description Usage Arguments Author(s) References Examples
Plot change-points using norm by SGL approach
1 | SGLPlotL1Norm(fit, n, p, num = 1, breaks = NULL, norm = 2)
|
fit |
result of SGL approach |
n |
total number of data |
p |
dimension of data |
num |
the num'th lambda used by user |
breaks |
list of breaks where to put a tick on the x-axis |
norm |
norm=2 is l2 norm, norm=1 is l1 norm |
Bingwen Zhang
Bingwen Zhang, Jun Geng and Lifeng Lai, Detecting changes in regression models via sparse group lasso, http://users.wpi.edu/~bzhang/icassp_v1.pdf
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 38 | ##---- 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(fit, n, p, num=1, breaks=NULL,norm=2)
{
# this function plot the l1 norm of theta in the result
# num is the num th lambda we used
# n is the number of data sample
# p is the number of dimension
#norm=2 is l2 norm, norm=1 is l1 norm
#breaks is the break tick the user want to show on the plot,
#if breaks is NULL the default setting is to divide x-axis into 10 equal segment and label the
#tick accordingly
t_sum = matrix(NA, n, 1)
if(norm==1)
{
for (i in 1:n)
{ t_sum[i] = sum(abs(fit$beta[((i-1)*p+1):(i*p), num]))}
}
if(norm==2)
{
for (i in 1:n)
{ t_sum[i] = sqrt(sum((fit$beta[((i-1)*p+1):(i*p), num])^2))}
}
{
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)
}
}
#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)))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.