make.product {quest} | R Documentation |
Make Product Terms (e.g., interactions)
Description
make.product
creates product terms (i.e., interactions) from various
components. make.product
uses Center
for the optional of
centering and/or scaling the predictors and/or moderators before making the
product terms.
Usage
make.product(
data,
x.nm,
m.nm,
center.x = FALSE,
center.m = FALSE,
scale.x = FALSE,
scale.m = FALSE,
suffix.x = "",
suffix.m = "",
sep = ":",
combo = TRUE
)
Arguments
data |
data.frame of data. |
x.nm |
character vector of colnames from |
m.nm |
character vector of colnames from |
center.x |
logical vector of length 1 specifying whether the predictor columns should be grand-mean centered before making the product terms. |
center.m |
logical vector of length 1 specifying whether the moderator columns should be grand-mean centered before making the product terms. |
scale.x |
logical vector of length 1 specifying whether the predictor columns should be grand-SD scaled before making the product terms. |
scale.m |
logical vector of length 1 specifying whether the moderator columns should be grand-SD scaled before making the product terms. |
suffix.x |
character vector of length 1 specifying any suffix to add to
the end of the predictor colnames |
suffix.m |
character vector of length 1 specifying any suffix to add to
the end of the moderator colnames |
sep |
character vector of length 1 specifying the string to connect
|
combo |
logical vector of length 1 specifying whether all combinations
of the predictors and moderators should be calculated or only those in
parallel to each other (i.e., |
Value
data.frame with product terms (e.g., interactions) as columns. The
colnames are created by paste(paste0(x.nm, suffix.x), paste0(m.nm,
suffix.m), sep = sep)
.
Examples
make.product(data = attitude, x.nm = c("complaints","privileges"),
m.nm = "learning", center.x = TRUE, center.m = TRUE,
suffix.x = "_c", suffix.m = "_c") # with grand-mean centering
make.product(data = attitude, x.nm = c("complaints","privileges"),
m.nm = c("learning","raises"), combo = TRUE) # all possible combinations
make.product(data = attitude, x.nm = c("complaints","privileges"),
m.nm = c("learning","raises"), combo = FALSE) # only combinations "in parallel"