Return the model predictions of a strat_cox
object
Arguments
- fit
a
strat_cox
object.- data
an
dataframe
orlist
object that contains the variables for prediction.- Z.char
names of covariates in
data
as vector of character strings.- 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:
link
: linear predictorsresponse
: risk (i.e.,exp(link)
)vars
: the indices for the non-zero coefficientsnvars
: the number of non-zero coefficientsgroups
: the indices for the non-zero groupsngroups
: the number of non-zero coefficients
- ...
Examples
data(ContTime)
data <- ContTime$data
Event.char <- ContTime$Event.char
prov.char <- ContTime$prov.char
Z.char <- ContTime$Z.char
Time.char <- ContTime$Time.char
fit <- Strat.cox(data, Event.char, Z.char, Time.char, prov.char, group = c(1, 2, 2, 3, 3))
predict(fit, data, Z.char, lambda = fit$lambda, type = "response")[1:5, 1:5]
#> 0.0394 0.0368 0.0343 0.032 0.0298
#> [1,] 1 0.9341802 0.8746803 0.8227072 0.7768418
#> [2,] 1 0.9461696 0.8968936 0.8533355 0.8144665
#> [3,] 1 0.8974894 0.8084036 0.7334456 0.6695674
#> [4,] 1 0.9530925 0.9098448 0.8713543 0.8367885
#> [5,] 1 0.8908210 0.7966337 0.7179336 0.6513011