Description Usage Arguments Details User-defined focuses Examples
Focused model comparison for Cox models fitted with coxph
from the survival
package. Built-in focuses include the hazard ratio, survival and cumulative hazard.
1 2 3 |
wide |
Fitted model object containing the wide model. |
inds |
Matrix or vector of indicators for which parameters are included in the submodel or submodels to be assessed. A matrix should be supplied if there are multiple submodels. This should have number of rows equal to the number of submodels, and number of columns equal to the total number of parameters in the wide model. It contains 1s in the positions where the parameter is included in the submodel, and 0s in positions where the parameter is excluded. This should always be 1 in the positions defining the narrow model, as specified in |
inds0 |
Vector of indicators specifying the narrow model, in the same format as |
gamma0 |
Vector of special values taken by the parameters gamma which define the narrow model. This defaults to 0, as in covariate selection, where "excluded" coefficients are fixed to 0. This should either be a scalar, assumed to be the same for all parameters fixed in the narrow model, or a vector of length equal to the number of parameters from the wide model which are fixed in the narrow model, that is, the number of entries of |
focus |
Three built-in focus quantities are supported:
Alternatively, a list of three R functions can be supplied, with components named |
X |
Covariate values to evaluate the focus at. See |
t |
times to evaluate the focus at. Only relevant for survival and cumulative hazard focuses, as the hazard ratio is constant through time. |
sub |
If |
tidy |
If |
... |
Other arguments to the focus function can be supplied here. The built-in focus functions If just one focus is needed, then To compute focused model comparison statistics for multiple focuses defined by the same focus function evaluated at multiple covariate values, For a typical regression model, the first parameter will denote an intercept, so the first value of Arguments to the focus function other than |
Stratified Cox models are not currently supported.
Each function should have four arguments:
par
Vector of estimated coefficients, the log hazard ratios in the Cox model.
H0
Cumulative hazard estimate at a set of times, in the form of the output from basehaz
. The function get_H0
can be used on this estimate to obtain the estimate at any other times by interpolation.
X
Matrix of covariates, with ncov
rows and npar
columns, where ncov
is the number of alternative covariate values definining alternative focuses we want to compare models for, and npar
is the number of coefficients in the model.
t
Vector of times defining alternative focus quantities (such as the survival)
For examples, examine the source for the built-in functions
fic:::cox_hr,fic:::cox_hr_deriv,fic:::cox_hr_dH
for the hazard ratio between X
and 0
fic:::cox_cumhaz,fic:::cox_cumhaz_deriv,fic:::cox_cumhaz_dH
for the cumulative hazard
fic:::cox_survival,fic:::cox_survival_deriv,fic:::cox_survival_dH
for the survival.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Example of focused covariate selection in a Cox model
## For more information see the main package vignette.
library(survival)
wide <- coxph(Surv(years, death==1) ~ sex + thick_centred + infilt +
epith + ulcer + depth + age, data=melanoma)
## Define models to be selected from
## Sex included in all models
## Select between models including all combinations of other covariates
inds0 <- expand_inds(c(1,0,0,0,0,0,0), wide)
combs <- all_inds(wide, inds0)
## Covariate values defining focus
newdata <- with(melanoma,
data.frame(sex = c("female","male"),
thick_centred = tapply(thick_centred, sex, mean),
infilt=4, epith=1, ulcer=1, depth=2,
age = tapply(age, sex, mean)))
X <- newdata_to_X(newdata, wide, intercept=FALSE)
## Focus is 5-year survival for these covariate values
ficall <- fic(wide, inds=combs, inds0=inds0, focus="survival", X=X, t=5)
ggplot_fic(ficall)
summary(ficall)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.