cvxcheck

Description

based on a clustering result, verify using cvxmod

Usage

1
cvxcheck(df, lambda = sort(unique(df$lambda)), ...)

Arguments

df

data frame of l1 or l2 solutions

lambda

lambda values on which we will calculate the solutions

...

passed to cvxmod.cluster

Author(s)

Toby Dylan Hocking

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
sim <- gendata(N <- 5,2,2,0.1)
colnames(sim$mat) <- c("height","length")
xyplot(length~height,data.frame(sim$mat,row=1:N),aspect="iso",group=row)
df <- clusterpath.l1.id(sim$mat)
if(cvxmod.available()){
  cvx <- cvxcheck(df)
  library(reshape2)
  cvx.melt <- melt(cvx,measure.vars=1:2)

  ## plot each dimension separately using lattice
  library(latticeExtra)
  (p <- plot(df))
  update(p,main="the path algorithm (lines) agrees with cvxmod (points)")+
    xyplot(value~lambda|variable,cvx.melt,groups=row)

  ## plot the 2 dimensions together using ggplot2
  (p <- plot2d(df))
  ## compare with cvx manually
  p+
    geom_point(aes(size=lambda/max(lambda)),data=cvx,shape=17,colour="red")+
    ggtitle(paste("Optimal solutions from path algorithm (black circles)",
                "agree with cvxmod (red triangles)"))
  ## or use a legend
  p+
    aes(shape=solver,colour=solver)+
    geom_point(aes(size=lambda/max(lambda)),data=cvx)
}