# \donttest{
# Simple example with synthetic multimodal data
n <- 100
p <- 24
# Generate synthetic data with 3 blocks
set.seed(456)
x_train <- matrix(rnorm(n * p), n, p)
x_tuning <- matrix(rnorm(50 * p), 50, p)
x_test <- matrix(rnorm(30 * p), 30, p)
# True coefficients with sparse structure
beta_true <- c(rep(1.5, 4), rep(0, 4), rep(-1, 4), rep(0, 12))
# Response variables
y_train <- x_train %*% beta_true + rnorm(n, sd = 0.5)
y_tuning <- x_tuning %*% beta_true + rnorm(50, sd = 0.5)
y_test <- x_test %*% beta_true + rnorm(30, sd = 0.5)
# Block sizes (3 blocks of 8 variables each)
pp <- c(8, 8, 8)
# Run DISCOM
result <- discom(beta = beta_true,
x = x_train, y = y_train,
x.tuning = x_tuning, y.tuning = y_tuning,
x.test = x_test, y.test = y_test,
nlambda = 25, nalpha = 15, pp = pp)
# View results
print(paste("Test error:", round(result$test.error, 4)))
print(paste("R-squared:", round(result$R2, 3)))
print(paste("Variables selected:", result$select))
# }
Run the code above in your browser using DataLab