Learn R Programming

starnet (version 0.0.7)

predict.starnet: Makes Predictions

Description

Predicts outcome from features with stacked model.

Usage

# S3 method for starnet
predict(object, newx, type = "response", nzero = NULL, ...)

Value

Matrix of predicted values, with samples in the rows, and models in the columns. Included models are alpha (fixed elastic net), ridge (i.e. alpha0), lasso (i.e. alpha1), tune (tuned elastic net), stack (stacked elastic net), and none (intercept-only model).

Arguments

object

starnet object

newx

covariates: numeric matrix with \(n\) rows (samples) and \(p\) columns (variables)

type

character "link" or "response"

nzero

maximum number of non-zero coefficients: positive integer, or NULL

...

further arguments (not applicable)

Examples

Run this code
# \dontshow{
if(!grepl('SunOS',Sys.info()['sysname'])){
set.seed(1)
n <- 50; p <- 100
y <- rnorm(n=n)
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
object <- starnet(y=y,X=X)
y_hat <- predict(object,newx=X[c(1),,drop=FALSE])}# }
# \donttest{
set.seed(1)
n <- 50; p <- 100
y <- rnorm(n=n)
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
object <- starnet(y=y,X=X)
y_hat <- predict(object,newx=X[c(1),,drop=FALSE])# }

Run the code above in your browser using DataLab