add.scope
Resolve Scopes for Formulas

Description

Resolve scopes for formulas.

Usage

add.scope(terms1, terms2) 
drop.scope(terms1, terms2) 
factor.scope(factor, scope)

Arguments

terms1 the terms object for the base model, or the formula corresponding to it.
terms2 the terms object (or formula) for the upper scope for add.scope, or the lower scope for drop.scope.
factor the "factor" attribute of terms1
scope a list with two components; \$add or \$drop which are the factor attributes corresponding to upper and lower scope terms objects. Either can be missing.
Value
A character vector of term labels is returned by add.scope, which are all the terms in terms2, but not in terms1, that can be separately added to terms1. This last provision ensures that the hierarchical nature of the model is preserved; e.g., third order interactions will only be added if their second order marginals are present. Similarly, drop.scope returns all the term labels that can be dropped from term1, except for those in terms2, and likewise maintaining the hierarchy.
factor.scope is support for the first two, and uses the factor attributes of the terms to efficiently establish the valid labels, returns a list with components "drop" and "add".
Note
These are support for the functions add1.lm, drop1.lm and step.glm.
See Also
add1, drop1, step.
Examples
add.scope( ~ a + b + c + a:b,  ~ (a + b + c)^3) 
# [1] "a:c" "b:c" 
drop.scope( ~ a + b + c + a:b) 
# [1] "c"   "a:b" 

Package stats version 6.0.0-69
Package Index