addterm: All Possible Single-Term Additions to / Deletions from a...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/addterm.R

Description

Identifies all models which arise via single-term additions to / deletions from a component (or, simultaneously, multiple components) of the supplied mpr model, fits all such models and summarises these models in a table.

Usage

1
2
3
4
5
addterm(object, upper = ~ ., comp = 1:(object$ncomp),
        aic = TRUE, bestmodel = object, ...)

dropterm(object, lower = ~ 1, comp = 1:(object$ncomp),
         aic = TRUE, bestmodel = object, ...)

Arguments

object

an object of class “mpr” which is the result of a call to mpr.

upper

a one-sided formula (used in addterm) specifying a maximal model which must include the current one.

lower

a one-sided formula (used in dropterm) specifying a minimal model which must be within the current one.

comp

a numeric value (or vector) indicating the regression component (or components) where (simultaneous) additions / deletions occur. Note that “1 = λ, “2 = γ and “3 = ρ. For more information on the various components, see mpr and distributions.

aic

logical. If TRUE, AIC is used as the basis for determining the best model among those considered. If FALSE, BIC is used.

bestmodel

an initial best model which, by default, is the supplied current model. This argument is used within the stepmpr function but is unlikely to be used directly by the end user.

...

additional arguments to be passed to internal methods.

Details

The hierarchy is respected when considering terms to be added or dropped, e.g., all main effects contained in a second-order interaction must remain.

When using addterm, the terms in the upper model formula must be a superset of the terms for each regression component indicated by comp. For example, if component 1 is ~ a + b + c and component 2 is ~ a + b (and terms are to be added to both simultaneously, i.e., comp=1:2), then upper = ~ a + b + c + d is acceptable and means that the variable d will be added simultaneously to components 1 and 2 (this can be written more compactly as upper = ~ . + d). On the other hand, ~ a + b + d is not acceptable since its terms do not form a superset of the terms in component 1 (however, this would be acceptable if we were only considering component 2, i.e., if comp=2).

When using dropterm, the terms in the lower model formula must be a subset of the terms for each regression component indicated by comp. Again, if component 1 is ~ a + b + c and component 2 is ~ a + b (and terms are to be dropped from both simultaneously, i.e., comp=1:2), then lower = ~ a is acceptable and means that the variable b will be dropped simultaneously from components 1 and 2 (this can be written more compactly as lower = ~ . - b). On the other hand, ~ c is not acceptable since its terms do not form a subset of the terms in component 2 (however, this would be acceptable if we were only considering component 1, i.e., if comp=1).

To summarise the above two paragraphs, the upper formula must contain each formula corresponding to the components under consideration whereas the lower formula must be contained within each of these formulae.

Value

A list containing the following components:

modeltab

a table containing information about each of the fitted models. This information comes from the “model” element of each of the mpr objects - see mpr for details.

bestmodel

the model with the lowest AIC (or BIC if aic = FALSE) among the fitted models including the initial bestmodel passed to the addterm / dropterm function.

Author(s)

Kevin Burke.

See Also

mpr, stepmpr, update.mpr.

Examples

 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
26
# Veterans' administration lung cancer data
veteran <- survival::veteran
head(veteran)

# null model
mod1 <- mpr(Surv(time, status) ~ list(~ 1, ~ 1), data=veteran)
mod1 # family = "Weibull" by default

# consider adding trt and celltype to component 1 
addterm(mod1, ~ trt + celltype, comp=1)

# consider adding trt and celltype to components 1 and 2 simultaneously
addterm(mod1, ~ trt + celltype, comp=1:2)$modeltab

# further examples
mod2 <- mpr(Surv(time, status) ~ list(~ trt + celltype, ~ trt + karno),
            data=veteran)
dropterm(mod2, ~ 1, comp=1:2)$modeltab
dropterm(mod2, ~ 1, comp=1)$modeltab
dropterm(mod2, ~ 1, comp=2)$modeltab

# does nothing since celltype is only in component 1
dropterm(mod2, ~ . - celltype, comp=1:2)$modeltab 

# removes celltype from component 1
dropterm(mod2, ~ . - celltype, comp=1)$modeltab

mpr documentation built on Jan. 8, 2022, 9:06 a.m.

Related to addterm in mpr...