|
1 | 1 | #' Adjust data for the effect of other variable(s) |
2 | 2 | #' |
3 | | -#' 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. |
| 3 | +#' This function can be used to adjust the data for the effect of other |
| 4 | +#' variables present in the dataset. It is based on an underlying fitting of |
| 5 | +#' regressions models, allowing for quite some flexibility, such as including |
| 6 | +#' factors as random effects in mixed models (multilevel partialization), |
| 7 | +#' continuous variables as smooth terms in general additive models (non-linear |
| 8 | +#' partialization) and/or fitting these models under a Bayesian framework. The |
| 9 | +#' values returned by this function are the residuals of the regression models. |
| 10 | +#' Note that a regular correlation between two "adjusted" variables is |
| 11 | +#' equivalent to the partial correlation between them. |
4 | 12 | #' |
5 | 13 | #' @param data A dataframe. |
6 | | -#' @param effect Character vector of column names to be adjusted for (regressed out). If `NULL` (the default), all variables will be selected. |
| 14 | +#' @param effect Character vector of column names to be adjusted for (regressed |
| 15 | +#' out). If `NULL` (the default), all variables will be selected. |
7 | 16 | #' @inheritParams standardize |
8 | | -#' @param 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. |
9 | | -#' @param additive If `TRUE`, continuous variables as included as smooth terms in additive models. The goal is to regress-out potential non-linear effects. |
10 | | -#' @param bayesian If `TRUE`, the models are fitted under the Bayesian framework using `rstanarm`. |
| 17 | +#' @param multilevel If `TRUE`, the factors are included as random factors. |
| 18 | +#' Else, if `FALSE` (default), they are included as fixed effects in the |
| 19 | +#' simple regression model. |
| 20 | +#' @param additive If `TRUE`, continuous variables as included as smooth terms |
| 21 | +#' in additive models. The goal is to regress-out potential non-linear |
| 22 | +#' effects. |
| 23 | +#' @param bayesian If `TRUE`, the models are fitted under the Bayesian framework |
| 24 | +#' using `rstanarm`. |
| 25 | +#' |
| 26 | +#' @return A data frame comparable to `data`, with adjusted variables. |
11 | 27 | #' |
12 | 28 | #' @examples |
13 | 29 | #' adjust(iris, effect = "Species", select = "Sepal.Length") |
|
0 commit comments