
Last chance! 50% off unlimited learning
Sale ends in
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.
adjust(
data,
effect = NULL,
select = NULL,
exclude = NULL,
multilevel = FALSE,
additive = FALSE,
bayesian = FALSE
)
A dataframe.
Character vector of column names to be adjusted for (regressed out). If NULL
(the default), all variables will be selected.
Character vector of column names. If NULL
(the default), all variables will be selected.
Character vector of column names to be excluded from selection.
If TRUE
, the factors are included as random factors. Else, if FALSE
(default), they are included as fixed effects in the simple regression model.
If TRUE
, continuous variables as included as smooth terms in additive models. The goal is to regress-out potential non-linear effects.
If TRUE
, the models are fitted under the Bayesian framework using rstanarm
.
# 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