Learn R Programming

effectsize (version 0.4.0)

adjust: Adjust data for the effect of other variable(s)

Description

This function can be used to adjust the data for the effect of other variables present in the dataset. It is based on an underlying fitting of regressions models, allowing for quite some flexibility, such as including factors as random effects in mixed models (multilevel partialization), continuous variables as smooth terms in general additive models (non-linear partialization) and/or fitting these models under a Bayesian framework. The values returned by this function are the residuals of the regression models. Note that a regular correlation between two "adjusted" variables is equivalent to the partial correlation between them.

Usage

adjust(
  data,
  effect = NULL,
  select = NULL,
  exclude = NULL,
  multilevel = FALSE,
  additive = FALSE,
  bayesian = FALSE
)

Arguments

data

A dataframe.

effect

Character vector of column names to be adjusted for (regressed out). If NULL (the default), all variables will be selected.

select

Character vector of column names. If NULL (the default), all variables will be selected.

exclude

Character vector of column names to be excluded from selection.

multilevel

If TRUE, the factors are included as random factors. Else, if FALSE (default), they are included as fixed effects in the simple regression model.

additive

If TRUE, continuous variables as included as smooth terms in additive models. The goal is to regress-out potential non-linear effects.

bayesian

If TRUE, the models are fitted under the Bayesian framework using rstanarm.

Examples

Run this code
# NOT RUN {
adjust(iris, effect = "Species", select = "Sepal.Length")
# }
# NOT RUN {
adjust(iris, effect = "Species", select = "Sepal.Length", multilevel = TRUE)
adjust(iris, effect = "Species", select = "Sepal.Length", bayesian = TRUE)
adjust(iris, effect = "Petal.Width", select = "Sepal.Length", additive = TRUE)
adjust(iris, effect = "Petal.Width", select = "Sepal.Length",
       additive = TRUE, bayesian = TRUE)
adjust(iris, effect = c("Petal.Width", "Species"), select = "Sepal.Length",
       multilevel = TRUE, additive = TRUE)
adjust(iris)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab