# \donttest{
# Simple example with synthetic data
n <- 100
p <- 20
# Generate synthetic data with 2 blocks
set.seed(123)
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
beta_true <- c(rep(2, 5), rep(0, 15))
# Response variables
y_train <- x_train %*% beta_true + rnorm(n)
y_tuning <- x_tuning %*% beta_true + rnorm(50)
y_test <- x_test %*% beta_true + rnorm(30)
# Block sizes (2 blocks of 10 variables each)
pp <- c(10, 10)
# Run AdapDiscom
result <- adapdiscom(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, nalpha = 10, pp = pp)
# View results
print(paste("Test R-squared:", round(result$R2, 3)))
print(paste("Selected variables:", result$select))
# }
Run the code above in your browser using DataLab