asef: Find associated effects

Description Usage Arguments Details Value See Also Examples

View source: R/asef.R

Description

This function finds the labels of coefficients associated with interactions or main effects in the results of various model fitting functions.

Usage

1
asef(model, ef, order = c("higher", "lower", "all"), include.base = FALSE)

Arguments

model

a model object.

ef

a character string (a coefficent label).

order

a character string vector giving the order of the terms to be returned. One of "higher" (default), "lower", or "all", can be abbreviated.

include.base

logical. Should the labels in ef be included in the output?

Details

model is an object returned by a model fitting function (e.g., lm, aov).

The character string passed to ef must not include the intercept ("(Intercept)") since it cannot be part of an interaction. All non-intercept labels of any order are allowed.

If order is "higher", all terms of a higher order are returned. If order is "lower", all terms of a lower order are returned. If order is "all" then both terms of lower and higher order are returned. For example, if a model fit has the terms A, B, C, A:B, B:C, A:C, and A:B:C, terms of higher order relative to A are A:B, A:C, and A:B:C. Terms of lower order relative to A:B are A and B.

If include.base is FALSE (the default), the term label in ef is not part of the returned string vector.

Value

asef returns vectors of character strings (coefficent labels).

See Also

terms for extracting model terms.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
require(utils)
 
data(iris)
fit <- lm(Sepal.Length ~ Sepal.Width * Petal.Length * Petal.Width, data = iris)
asef(fit, "Petal.Length:Petal.Width", order = "higher")
asef(fit, "Sepal.Width:Petal.Length:Petal.Width", order = "lower")
asef(fit, "Petal.Length:Petal.Width", order = "all")
 
data(warpbreaks)
fit2 <- lm(breaks ~ wool * tension, data = warpbreaks)
# Since wool is a factor, the coefficient has another name, "woolB"
asef(fit2, "woolB", order = "higher")
asef(fit2, "woolB", order = "higher", include.base = TRUE)

hohenstein/remef documentation built on Jan. 26, 2020, 12:57 a.m.