Skip to contents

Computes predictions from a fitted islasso model object. Multiple output types supported, including response scale, linear predictor, and coefficient values.

Usage

# S3 method for class 'islasso'
predict(
  object,
  newdata = NULL,
  type = c("link", "response", "coefficients", "class", "terms"),
  se.fit = FALSE,
  ci = NULL,
  type.ci = c("wald", "score"),
  level = 0.95,
  terms = NULL,
  na.action = na.pass,
  ...
)

Arguments

object

A fitted model of class "islasso".

newdata

Optional data frame containing predictors for prediction. If omitted, the fitted model matrix is used.

type

Character. Specifies the prediction scale:

  • "link" (default): linear predictor scale;

  • "response": original response scale;

  • "coefficients": estimated coefficients;

  • "class": predicted class (only for binomial() family);

  • "terms": contribution of each term to the linear predictor.

se.fit

Logical. Whether to compute standard errors/confidence intervals.

ci

Optional. Precomputed matrix of confidence intervals (2 columns).

type.ci

Type of interval. Only "wald" is implemented.

level

Confidence level for intervals. Default is 0.95.

terms

If type = "terms", optionally specify which terms to extract.

na.action

Function to handle missing values in newdata. Default: na.pass.

...

Additional arguments passed to downstream methods.

Value

A numeric vector, matrix, or list depending on type.

Author

Gianluca Sottile gianluca.sottile@unipa.it

Examples

set.seed(1)
n <- 100; p <- 100
beta <- c(runif(20, -3, 3), rep(0, p - 20))
sim <- simulXy(n = n, p = p, beta = beta, seed = 1, family = gaussian())
fit <- islasso(y ~ ., data = sim$data, family = gaussian(), lambda = 2)
predict(fit, type = "response")
#>            1            2            3            4            5            6 
#>   5.21145237  -1.43186355  -1.87707634   3.38862598  -1.92102645   2.98415369 
#>            7            8            9           10           11           12 
#>  -9.43985904   4.15355250  -2.66779789  -4.14845909   3.46641282  -4.10876731 
#>           13           14           15           16           17           18 
#>   0.90610289  -2.76134098   1.89852882  -0.60890376  -6.55871515   0.06352742 
#>           19           20           21           22           23           24 
#>  -2.62533271   0.42070839  -4.82272696  -4.67076935  10.48877879  14.86453464 
#>           25           26           27           28           29           30 
#>  -4.48649098  -6.37381434   4.09537272  13.60055424   2.07156492   7.50878799 
#>           31           32           33           34           35           36 
#>  -6.73281383  -0.91646275   9.10929220  11.18502534  -4.52986378  -7.37417357 
#>           37           38           39           40           41           42 
#>  23.33603867   4.78241357  -1.57391485   5.40950944  -0.46416742  -8.41419768 
#>           43           44           45           46           47           48 
#>   6.61032726  -2.31682147  -7.40341429 -10.68456568  -0.01351213 -12.36236266 
#>           49           50           51           52           53           54 
#>  -0.89347286   9.38899357   3.35335057  -0.98732376  -5.27471442  -5.73730247 
#>           55           56           57           58           59           60 
#>   8.16581897  -5.45944955 -12.85556246  10.86746694 -11.87252793  11.34253371 
#>           61           62           63           64           65           66 
#>  -3.67302524   4.08943614  -8.00715886  -7.92820503   6.25491158  13.88284885 
#>           67           68           69           70           71           72 
#>  -6.17176098  14.24448381  -6.76303137   3.31426261 -15.90302166   8.00218489 
#>           73           74           75           76           77           78 
#>  -2.24816294  -4.95830887   5.03041165  -0.25738149   6.89625712   4.03817956 
#>           79           80           81           82           83           84 
#> -12.83266376  -0.93735110  -9.93779514  -0.36243304  -0.11087383  10.86588406 
#>           85           86           87           88           89           90 
#> -10.84340285  -3.02213088 -12.36447903  13.77524184  -2.55117297  -4.87329978 
#>           91           92           93           94           95           96 
#>   2.21847849  -6.34566460  -2.11714321  -3.08677838  -0.06908000   9.07232136 
#>           97           98           99          100 
#>  -9.20100578   6.35833233  13.40067379  -0.31352736