1

I'm trying to reproduce the plot of the experiment in the paper "Group Lasso with Overlap and Graph Lasso - Jacob, Obozinksi and Vert". I was able to produce the data but I don't know where to start with the plot.

enter image description here

Here the description of the plot from the authors: "for each variable (on the vertical axis), we plot its frequency of selection in levels of gray as a function of the regularization parameter λ, both for the lasso penalty and Ω_overlap"

I'm trying a simplified version to begin with, with only 1 simulation, so instead of a scale of gray I should obtain black and white segment

I tried heatmap but I don't know how to impose the x-axis

Here is the code to produce the data

library(MLGL)

p <- 82
n <- 50

X <- rnorm(n*p)
X <- matrix(X, nrow=n, ncol=p)

y <- X[,c(26:42)] %*% c(rep(1,17)) + rnorm(50, 0, 0.5)

var <- c(1:10, 9:18, 17:26, 25:34, 33:42, 41:50, 49:58, 57:66, 65:74, 73:82)
group <- rep(1:10, each = 10)

experimento <- overlapgglasso(X, y, var, group, intercept = F)

lambda <- experimento$lambda[-1]

variabili <- 1:82

selez <- matrix(NA, ncol = 82, nrow = 99)

for (i in 1:99){
  selez[i,] <- variabili %in% experimento$var[[i+1]]
}

I tried heatmap but I don't know how to impose the x-axis.

1 Answer 1

0

I would probably convert to a data frame, then pivot into long format for plotting with ggplot:

library(ggplot2)

as.data.frame(0 + selez) |>
  setNames(variabili) |>
  cbind(lambda = lambda) |>
  tidyr::pivot_longer(-lambda) |>
  dplyr::mutate(name = factor(as.numeric(name))) |>
  ggplot(aes(lambda, name, fill = factor(value))) +
  geom_tile(aes(width = lambda/20), color = 'gray') +
  scale_fill_manual('Selez', values = c('white', 'black'), 
                    labels = c('No', 'Sì')) +
  labs(y = 'variabili') +
  coord_cartesian(expand = FALSE) +
  theme_minimal()

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.