Return the model predictions of a DiscSurv
object
Arguments
- fit
a
DiscSurv
object.- data
an
dataframe
orlist
object that contains the variables for prediction.- Event.char
name of the event indicator in
data
as a character string.- Z.char
names of covariates in
data
as vector of character strings.- Time.char
name of the observation time in
data
as a character string.- lambda
values of the regularization parameter lambda at which predictions are requested. For values of lambda not in the sequence of fitted models, linear interpolation is used.
- which
indices of the penalty parameter lambda at which predictions are required. By default, all indices are returned. If lambda is specified, this will override which.
- type
type of prediction:
response
: fitted values (i.e.,exp(eta)/(1 + exp(eta))
)vars
: the indices for the non-zero coefficientsnvars
: the number of non-zero coefficients
- which.lambda
determine which lambda values are included in the output of the prediction. By default, its value is set to "all," resulting in a matrix of predicted values for each lambda presented as a list. However, if specific numeric values are provided, only the predicted matrix corresponding to those specified values will be included in the output.
- ...
Examples
data(DiscTime)
data <- DiscTime$data
Event.char <- DiscTime$Event.char
Z.char <- DiscTime$Z.char
Time.char <- DiscTime$Time.char
fit <- DiscSurv(data, Event.char, Z.char, Time.char)
predict(fit, data, Event.char, Z.char, Time.char, lambda = fit$lambda, type = "response", which.lambda = fit$lambda[1])[1:5,]
#> Individual [Time: 0.53] [Time: 1.03] [Time: 3.92] [Time: 6.74] [Time: 12.5]
#> 1 1 0.121372 0.1081081 NA NA NA
#> 2 2 0.121372 0.1081081 0.07692308 0.08661417 0.04932735
#> 3 3 0.121372 NA NA NA NA
#> 4 4 0.121372 0.1081081 0.07692308 0.08661417 NA
#> 5 5 0.121372 0.1081081 0.07692308 0.08661417 0.04932735
predict(fit, data, Event.char, Z.char, Time.char, lambda = 0.01, type = "vars")
#> Z1 Z2 Z3 Z4 Z5
#> 1 2 3 4 5