
Identify Stratification Variables
strata.RdThis is a special function used in the context of the Cox survival model. It identifies stratification variables when they appear on the right hand side of a formula.
Arguments
- ...
any number of variables. All must be the same length.
- na.group
a logical variable, if
TRUE, then missing values are treated as a distinct level of each variable.- shortlabel
if
TRUEomit variable names from resulting factor labels. The default action is to omit the names if all of the arguments are factors, and none of them was named.- sep
the character used to separate groups, in the created label
Value
a new factor, whose levels are all possible combinations of the factors supplied as arguments.
Details
When used outside of a coxph formula the result of the function
is essentially identical to the interaction function,
though the labels from strata are often more verbose.
Examples
a <- factor(rep(1:3,4), labels=c("low", "medium", "high"))
b <- factor(rep(1:4,3))
levels(strata(b))
#> [1] "1" "2" "3" "4"
levels(strata(a,b,shortlabel=TRUE))
#> [1] "low, 1" "low, 2" "low, 3" "low, 4" "medium, 1" "medium, 2"
#> [7] "medium, 3" "medium, 4" "high, 1" "high, 2" "high, 3" "high, 4"
coxph(Surv(futime, fustat) ~ age + strata(rx), data=ovarian)
#> Call:
#> coxph(formula = Surv(futime, fustat) ~ age + strata(rx), data = ovarian)
#>
#> coef exp(coef) se(coef) z p
#> age 0.13735 1.14723 0.04741 2.897 0.00376
#>
#> Likelihood ratio test=12.69 on 1 df, p=0.0003678
#> n= 26, number of events= 12