Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/predict.grpreg.R
Similar to usual predict methods and predict.grprep in grpreg package.
1 2 3 |
object |
A fitted " |
newdata |
Optionally, a matrix or data frame where to predict. If omits, the fitted predictors are used. |
lambda |
Value of the regularization parameter |
type |
The type of prediction: " |
... |
Not used. |
This function gives the predictions at newdata or all predictors if the
argument newdata is not supplied. The default lambda for "grpreg"
object is the one at which we obtain the minimum loss value, i.e., negative log-likelihood
value. Typically, type = "response" is
used for linear or poisson regression, and type = "class" or
type = "probability" is used for logistic regression.
The predicted values depending on the type.
Debin Qiu, Jeongyoun Ahn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | library(MASS)
set.seed(23)
n <- 30 # sample size
p <- 3 # number of predictors in each group
J <- 50 # group size
group <- rep(1:J,each = 3) # group indices
X <- mvrnorm(n,seq(0,5,length.out = p*J),diag(p*J))
beta <- runif(12,-2,5)
mu <- X%*%matrix(c(beta,rep(0,p*J-12)),ncol = 1)
# linear regression with family = "gaussian"
y <- mu + rnorm(n)
## without cross-validation
gss12 <- grpss(X,y,ncut = 10,group,select = TRUE)
predict(gss12) # fitted values
predict(gss12,lambda = 0.2) # fitted values at lambda = 0.2
# logistic regression with family = "binomial"
set.seed(23)
y1 <- rbinom(n,1,1/(1 + exp(-mu)))
gss21 <- grpss(X,y1,group, criterion = "gDC",select = TRUE,
family = "binomial")
predict(gss21)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.