n <- 100
p <- 12
nr <- 4
g <- paste0("Group ",ceiling(1:p / nr))
X <- matrix(rnorm(n * p), n, p)
b <- c(-3:3)
y_lin <- X[, 1:length(b)] %*% b + 5 * rnorm(n)
y_log <- rbinom(n, 1, exp(y_lin) / (1 + exp(y_lin)))
lin_fit <- sgp(X, y_lin, g, type = "linear")
plot(lin_fit, legend.pos = "topright", label = TRUE)
plot(lin_fit, label = TRUE, norm = TRUE)
log_fit <- sgp(X, y_log, g, type = "logit")
plot(log_fit, legend.pos = "topright", label = TRUE)
plot(log_fit, label = TRUE, norm = TRUE)
Run the code above in your browser using DataLab