grand_mean_center: Grand-mean centering.

View source: R/bruceR-stats_4_regress.R

grand_mean_centerR Documentation

Grand-mean centering.

Description

Compute grand-mean centered variables. Usually used for GLM interaction-term predictors and HLM level-2 predictors.

Usage

grand_mean_center(data, vars = names(data), std = FALSE, add.suffix = "")

Arguments

data

Data object.

vars

Variable(s) to be centered.

std

Standardized or not. Defaults to FALSE.

add.suffix

The suffix of the centered variable(s). Defaults to "". You may set it to "_c", "_center", etc.

Value

A new data object containing the centered variable(s).

See Also

group_mean_center

Examples

d = data.table(a=1:5, b=6:10)

d.c = grand_mean_center(d, "a")
d.c

d.c = grand_mean_center(d, c("a", "b"), add.suffix="_center")
d.c


bruceR documentation built on June 22, 2024, 12:26 p.m.