Densities {NormData}R Documentation

Plot densities

Description

Plot densities for an outcome for different subgroups.

Usage

Densities(Dataset, Test.Score, IV, Color=TRUE, 
Size.Legend=1, xlab="Test score", main, ...)

Arguments

Dataset

The name of the dataset.

Test.Score

The name of the outcome variable (e.g., a raw test score).

IV

The name of the stratification variable, that defines for which subgroups density plots should be provided. If IV is not specified, a single density is shown (no subgroups).

Color

Logical. Should densities for different subgroups be depicted in color? Default Color=TRUE.

Size.Legend

The size of the legend in the plot. Default Size.Legend=1.

xlab

The label on the X-axis. Default xlab="Test score".

main

The title of the plot.

...

Other arguments to be passed to the plot(function), e.g. xlim=c(0, 100).

Value

No return value, called for side effects.

Author(s)

Wim Van der Elst

References

Van der Elst, W. (2024). Regression-based normative data for psychological assessment: A hands-on approach using R. Springer Nature.

Examples

# Plot Gender-specific densities of the raw science exam 
# scores in the GCSE dataset
data(GCSE)
Densities(Dataset = GCSE, Test.Score = Science.Exam, IV=Gender)

# Plot LE-specific densities of the residuals of a model
# where the Openness scale score is regressed on LE
data(Personality)
Fit <- Stage.1(Dataset = Personality, Model = Openness~LE)
summary(Fit)
Data.With.Residuals <- data.frame(Personality, 
  Fit$HomoNorm$Residuals)
Densities(Dataset = Data.With.Residuals, 
  Test.Score = Fit.HomoNorm.Residuals, IV = LE)


[Package NormData version 1.1 Index]