# \donttest{
# Fast DISCOM example with synthetic multimodal data
n <- 70
p <- 18
# Generate synthetic data with 3 blocks
set.seed(321)
x_train <- matrix(rnorm(n * p), n, p)
x_tuning <- matrix(rnorm(35 * p), 35, p)
x_test <- matrix(rnorm(20 * p), 20, p)
# True coefficients with block structure
beta_true <- c(rep(1.0, 3), rep(0, 3), rep(-1.2, 3), rep(0, 3), rep(0.8, 3), rep(0, 3))
# Response variables
y_train <- x_train %*% beta_true + rnorm(n, sd = 0.4)
y_tuning <- x_tuning %*% beta_true + rnorm(35, sd = 0.4)
y_test <- x_test %*% beta_true + rnorm(20, sd = 0.4)
# Block sizes (3 blocks of 6 variables each)
pp <- c(6, 6, 6)
# Run fast DISCOM (efficient for large datasets)
result <- fast_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 = 20, pp = pp, n.l = 25)
# View results
print(paste("Test error:", round(result$test.error, 4)))
print(paste("R-squared:", round(result$R2, 3)))
print(paste("Runtime:", round(result$time, 2), "seconds"))
# }
Run the code above in your browser using DataLab