grand_mean_center: Grand-mean centering.

Description Usage Arguments Value See Also Examples

View source: R/bruceR_stats_04_regress.R

Description

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

Usage

1
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. Default is FALSE.

add_suffix

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

Value

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

See Also

group_mean_center

Examples

1
2
3
4
5
6
7
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, 2021, 1:06 a.m.