Learn R Programming

psycCleaning (version 0.1.1)

z_scored_mlm: Z-scored for multilevel analyses

Description

This function will group mean centered the scores at the level 1 and create an aggregated mean score for each group at L2. After that, the group-mean-centered L1 scores and mean L2 scores will be z-scored with respect to the grand mean. Please see `center_mlm` if you want to use the version without the z-scoring.

Usage

z_scored_mlm(data, cols, group, keep_original = TRUE)

Value

An object of the same type as .data. The output has the following properties: 1. Columns from .data will be preserved 2. Columns with L1 scores that are group-mean centered then grand-mean z-scored. 3. Columns with L2 aggregated means that are z-scored

Arguments

data

A data.frame or a data.frame extension (e.g. a tibble).

cols

Columns that need to be centered. See `dplyr::dplyr_tidy_select` for available options.

group

The grouping/cluster variable.

keep_original

default is `TRUE`. Set to `FALSE` to remove original columns

Examples

Run this code
z_scored_mlm(iris,dplyr::ends_with('Length'),group = 'Species')

Run the code above in your browser using DataLab