correlate_ml: Compute single- or multilevel correlations

View source: R/correlate_ml.R

correlate_mlR Documentation

Compute single- or multilevel correlations

Description

This function computes correlations between a series of specified variables. If no cluster identifier is specified, the function provides simple single-level correlations at the individual level of observations. If a cluster identifier is specified, the function provides multilevel correlations between the respective group means at the specified hierarchical level.

Usage

correlate_ml(data, .cols, .id_cluster)

Arguments

data

A data frame.

.cols

<data-masked> The names or column numbers of the numeric variables to compute correlations for.

.id_cluster

<data-masked> Optional. The name or column number of the cluster identifier to compute multilevel correlations.

Value

A tibble containing a correlation matrix of variables specified in .cols.

Examples

# compute single-level correlations between students' mathematics and reading achievement
correlate_ml(data = studach, .cols = read:math)

# compute multilevel correlations between students' mathematics and reading achievement
# at the school level
correlate_ml(data = studach, .cols = c(gender, read, math), .id_cluster = id_sch)

sophiestallasch/multides documentation built on Oct. 20, 2024, 5:14 a.m.