Description Usage Arguments Value Author(s) Examples
Cluster a matrix using the identity weights on each dimension. The L1 problem is separable, so we can process each dimension separately on each core if the multicore package is available.
1 | clusterpath.l1.id(x, LAPPLY = if (require(multicore)) mclapply else lapply)
|
x |
Matrix of data. |
LAPPLY |
Function to use to combine the results of each dimension. Defaults to mclapply for parallel processing if the multicore package is available, otherwise the standard lapply. |
data frame of optimal solutions at the breakpoints. need unique() when there are multiple lines that join at the exact same time (only pathological cases).
Toby Dylan Hocking
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | x <- c(-3,-2,0,3,5)
df <- clusterpath.l1.id(x)
head(df)
mean(x)
plot(df)
## check agreement with cvx
if(cvxmod.available()){
cres <- cvxcheck(df,seq(0,max(df$lambda),l=8),verbose=TRUE)
orig <- data.frame(alpha=x,row=1:length(x),lambda=0)
p <- ggplot(df,aes(lambda,alpha))+
geom_line(aes(group=row))+
geom_point(aes(y=alpha.1),data=cres,pch=21)+
scale_y_continuous(breaks=x,minor=min(x):max(x))
print(p)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.