Learn R Programming

hierNet (version 1.10.1)

predict.hierNet.logistic: Prediction function for hierNet.logistic.

Description

A function to perform prediction, using an x matrix and the output of the "hierNet.logistic" function or "hierNet.logistic.path".

Usage

# S3 method for hierNet.logistic
predict(object, newx, newzz = NULL, ...)

Value

yhat

Matrix of predictions (probabilities), one row per observation

Arguments

object

The results of a call to the "hierNet.logistic" or "hierNet.logistic.path" or function. The coefficients that are part of this object will be used for making predictions.

newx

The new x at which predictions should be made. Can be a vector or a matrix (one observation per row).

newzz

Optional matrix of products of columns of newx, computed by compute.interactions.c

...

additional arguments (not currently used)

Author

Jacob Bien and Robert Tibshirani

References

Bien, J., Taylor, J., Tibshirani, R., (2013) "A Lasso for Hierarchical Interactions." Annals of Statistics. 41(3). 1111-1141.

See Also

hierNet.logistic, hierNet.logistic.path

Examples

Run this code

set.seed(12)
x=matrix(rnorm(100*10),ncol=10)
x=scale(x,TRUE,TRUE)
y=x[,1]+2*x[,2]+ x[,1]*x[,2]+3*rnorm(100)
y=1*(y>0)
newx=matrix(rnorm(100*10),ncol=10)
fit=hierNet.logistic(x,y,lam=5)
yhat=predict(fit,newx)

fit=hierNet.logistic.path(x,y)
yhat=predict(fit,newx)

Run the code above in your browser using DataLab