untangle.specials.Rd
Given a terms
structure and a desired special name, this returns an
index appropriate for subscripting the terms
structure and another
appropriate for the data frame.
untangle.specials(tt, special, order=1)
a list with two components:
a vector of variable names, as would be found in the data frame, of the specials.
a numeric vector, suitable for subscripting the terms structure, that indexes the terms in the expanded model formula which involve the special.
formula <- Surv(tt,ss) ~ x + z*strata(id)
tms <- terms(formula, specials="strata")
## the specials attribute
attr(tms, "specials")
#> $strata
#> [1] 4
#>
## main effects
untangle.specials(tms, "strata")
#> $vars
#> [1] "strata(id)"
#>
#> $tvar
#> [1] 3
#>
#> $terms
#> [1] 3
#>
## and interactions
untangle.specials(tms, "strata", order=1:2)
#> $vars
#> [1] "strata(id)"
#>
#> $tvar
#> [1] 3
#>
#> $terms
#> [1] 3 4
#>