predict.gren: Predictions and coefficients from gren model.

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Create predictions from new data using a fitted gren model/retrieve coefficients from fitted model. Both are S3 methods.

Usage

1
2
3
4
5
6
## S3 method for class 'gren'
predict(object, newx, unpenalized=NULL, s=NULL, 
             type=c("groupreg", "regular"), ...)

## S3 method for class 'gren'
coef(object, s=NULL, type=c("groupreg", "regular"), ...)

Arguments

object

A fitted gren model.

newx

New data for which to do predictions.

unpenalized

New unpenalized data for which to do predictions.

s

Value of lambda for which to create predictions/coefficients, may be a vector.

type

Either groupreg, which creates predictions/coefficients of group-regularized model, or regular, for predictions/coefficients from regular model.

...

Further arguments to be passed.

Details

This are the predict/coefficient functions of the gren package.

Value

predict returns a numeric matrix with predicted probabilities. coef returns a matrix with coefficients.

Author(s)

Magnus M. Münch <m.munch@vumc.nl>

References

Münch, M.M., Peeters, C.F.W., van der Vaart, A.W., and van de Wiel, M.A. (2018). Adaptive group-regularized logistic elastic net regression. arXiv:1805.00389v1 [stat.ME].

See Also

gren,coef.gren

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Create data
p <- 1000
n <- 100
set.seed(2018)
x <- matrix(rnorm(n*p), ncol=p, nrow=n)
beta <- c(rnorm(p/2, 0, 0.1), rnorm(p/2, 0, 1))
m <- rep(1, n)
y <- rbinom(n, m, as.numeric(1/(1 + exp(-x %*% as.matrix(beta)))))
partitions <- list(groups=rep(c(1, 2), each=p/2))

## estimate model
fit.gren <- gren(x, y, m, partitions=partitions)

## create new data
xnew <- matrix(rnorm(n*p), ncol=p, nrow=n)

## create predictions/coefficients
preds <- predict(fit.gren, xnew, type="groupreg")
coefs <- coef(fit.gren, type="groupreg")

gren documentation built on May 1, 2019, 7:31 p.m.