Title: | Regularized Generalized Linear Models with Interaction Effects |
---|---|
Description: | Provides an efficient procedure for fitting the entire solution path for high-dimensional regularized quadratic generalized linear models with interactions effects under the strong or weak heredity constraint. |
Authors: | Yang Feng [aut, cre], Ning Hao [aut], Hao Helen Zhang [aut] |
Maintainer: | Yang Feng <[email protected]> |
License: | GPL-2 |
Version: | 2.0.2 |
Built: | 2025-02-01 06:28:59 UTC |
Source: | https://github.com/cran/RAMP |
Similar to the usual predict methods,
this function returns predictions from a fitted 'RAMP'
object.
## S3 method for class 'RAMP' predict(object, newdata = NULL, type = c("link", "response", "class"), allpath = FALSE, ...)
## S3 method for class 'RAMP' predict(object, newdata = NULL, type = c("link", "response", "class"), allpath = FALSE, ...)
object |
Fitted |
newdata |
Matrix of new values for |
type |
Type of prediction required.
Type |
allpath |
allpath = T will output all the predictions on the solution path. allpath = FALSE will only output the one the criterion selected in the |
... |
Not used. Other arguments to predict. |
The object returned depends on type.
Similar to the usual print methods, this function summarize results
from a fitted 'RAMP'
object.
## S3 method for class 'RAMP' print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'RAMP' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
Fitted |
digits |
The number of significant digits for the coefficient estimates. |
... |
Not used. Other arguments to predict. |
No value is returned.
Regularization Algorithm under Marginality Principle (RAMP) for high dimensional generalized quadratic regression.
RAMP(X, y, family = "gaussian", penalty = "LASSO", gamma = NULL, inter = TRUE, hier = "Strong", eps = 1e-15, tune = "EBIC", penalty.factor = rep(1, ncol(X)), inter.penalty.factor = 1, lam.list, lambda.min.ratio, max.iter = 100, max.num, n.lambda = 100, ebic.gamma = 1, refit = TRUE, trace = FALSE)
RAMP(X, y, family = "gaussian", penalty = "LASSO", gamma = NULL, inter = TRUE, hier = "Strong", eps = 1e-15, tune = "EBIC", penalty.factor = rep(1, ncol(X)), inter.penalty.factor = 1, lam.list, lambda.min.ratio, max.iter = 100, max.num, n.lambda = 100, ebic.gamma = 1, refit = TRUE, trace = FALSE)
X |
input matrix, of dimension nobs x nvars; each row is an observation vector. |
y |
response variable, of dimension nobs x 1. continous for
|
family |
response type. Default is 'gaussian'. The other choice is 'binomial' for logistic regression. |
penalty |
Choose from |
gamma |
concavity parameter. If NULL, the code will use 3.7 for 'SCAD' and 2.7 for 'MCP'. |
inter |
whether to select interaction effects. Default is TRUE. |
hier |
whether to enforce strong or weak heredity. Default is 'Strong'. |
eps |
the precision used to test the convergence. Default is 1e-15. |
tune |
tuning parameter selection method. 'AIC', 'BIC', 'EBIC' and 'GIC' are available options. Default is EBIC. |
penalty.factor |
A multiplicative factor for the penalty applied to each coefficient. If supplied, penalty.factor must be a numeric vector of length equal to the number of columns of X. The purpose of penalty.factor is to apply differential penalization if some coefficients are thought to be more likely than others to be in the model. In particular, penalty.factor can be 0, in which case the coefficient is always in the model without shrinkage. |
inter.penalty.factor |
the penalty factor for interactions effects. Default is 1. larger value discourage interaction effects. |
lam.list |
a user supplied |
lambda.min.ratio |
optional input. smallest value for |
max.iter |
maximum number of iteration in the computation. Default is 100. |
max.num |
optional input. maximum number of nonzero coefficients. |
n.lambda |
the number of |
ebic.gamma |
the gamma parameter value in the EBIC criteria. Default is 1. |
refit |
whether to perform a MLE refit on the selected model. Default is TRUE. |
trace |
whether to trace the fitting process. Default is FALSE. |
An object with S3 class RAMP.
a0 |
intercept vector of length( |
mainInd |
index for the selected main effects. |
interInd |
index for the selected interaction effects |
beta.m |
coefficients for the selected main effects. |
beta.i |
coefficients for the selected interaction effects. |
set.seed(0) n = 500 p = 10 #Can be changed to a much larger number say 50000 x = matrix(rnorm(n*p),n,p) eta = 1 * x[,1] + 2 * x[,3] + 3*x[,6] + 4*x[,1]*x[,3] + 5*x[,1]*x[,6] y = eta + rnorm(n) xtest = matrix(rnorm(n*p),n,p) eta.test = 1 * xtest[,1] + 2 * xtest[,3] + 3*xtest[,6] + 4*xtest[,1]*xtest[,3] + 5*xtest[,1]*xtest[,6] ytest = eta.test + rnorm(n) fit1 = RAMP(x, y) fit1 ###examine the results ypred = predict(fit1, xtest) mean((ypred-ytest)^2) #fit1.scad = RAMP(x, y, penalty = 'SCAD') #fit1.scad ###examine the results #fit1.mcp = RAMP(x, y, penalty = 'MCP') #fit1.mcp ###examine the results ##Now, try a binary response #y = rbinom(n, 1, 1/(1+exp(-eta))) #fit2 = RAMP(x, y, family='binomial') ###for binary response ## Weak heredity eta = 1 * x[,1] + 3*x[,6] + 4*x[,1]*x[,3] + 5*x[,1]*x[,6] y = eta + rnorm(n) eta.test = 1 * xtest[,1] + 3*xtest[,6] + 4*xtest[,1]*xtest[,3] + 5*xtest[,1]*xtest[,6] ytest = eta.test + rnorm(n) fit3 = RAMP(x, y, hier = 'Strong') fit3 ###examine the results ypred3 = predict(fit3, xtest) mean((ypred3-ytest)^2) fit4 = RAMP(x, y, hier = 'Weak') fit4 ypred4 = predict(fit4, xtest) mean((ypred4-ytest)^2)
set.seed(0) n = 500 p = 10 #Can be changed to a much larger number say 50000 x = matrix(rnorm(n*p),n,p) eta = 1 * x[,1] + 2 * x[,3] + 3*x[,6] + 4*x[,1]*x[,3] + 5*x[,1]*x[,6] y = eta + rnorm(n) xtest = matrix(rnorm(n*p),n,p) eta.test = 1 * xtest[,1] + 2 * xtest[,3] + 3*xtest[,6] + 4*xtest[,1]*xtest[,3] + 5*xtest[,1]*xtest[,6] ytest = eta.test + rnorm(n) fit1 = RAMP(x, y) fit1 ###examine the results ypred = predict(fit1, xtest) mean((ypred-ytest)^2) #fit1.scad = RAMP(x, y, penalty = 'SCAD') #fit1.scad ###examine the results #fit1.mcp = RAMP(x, y, penalty = 'MCP') #fit1.mcp ###examine the results ##Now, try a binary response #y = rbinom(n, 1, 1/(1+exp(-eta))) #fit2 = RAMP(x, y, family='binomial') ###for binary response ## Weak heredity eta = 1 * x[,1] + 3*x[,6] + 4*x[,1]*x[,3] + 5*x[,1]*x[,6] y = eta + rnorm(n) eta.test = 1 * xtest[,1] + 3*xtest[,6] + 4*xtest[,1]*xtest[,3] + 5*xtest[,1]*xtest[,6] ytest = eta.test + rnorm(n) fit3 = RAMP(x, y, hier = 'Strong') fit3 ###examine the results ypred3 = predict(fit3, xtest) mean((ypred3-ytest)^2) fit4 = RAMP(x, y, hier = 'Weak') fit4 ypred4 = predict(fit4, xtest) mean((ypred4-ytest)^2)