Learn R Programming

cNORM (version 3.3.1)

plotDensity: Plot the density function per group by raw score

Description

This function plots density curves based on the regression model against the raw scores. It supports both traditional continuous norming models and beta-binomial models. The function allows for customization of the plot range and groups to be displayed.

Usage

plotDensity(
  model,
  minRaw = NULL,
  maxRaw = NULL,
  minNorm = NULL,
  maxNorm = NULL,
  group = NULL
)

Value

A ggplot object representing the density functions.

Arguments

model

The model from the bestModel function, a cnorm object, or a cnormBetaBinomial or cnormBetaBinomial2 object.

minRaw

Lower bound of the raw score. If NULL, it's automatically determined based on the model type.

maxRaw

Upper bound of the raw score. If NULL, it's automatically determined based on the model type.

minNorm

Lower bound of the norm score. If NULL, it's automatically determined based on the model type.

maxNorm

Upper bound of the norm score. If NULL, it's automatically determined based on the model type.

group

Numeric vector specifying the age groups to plot. If NULL, groups are automatically selected.

Details

The function generates density curves for specified age groups, allowing for easy comparison of score distributions across different ages.

For beta-binomial models, the density is based on the probability mass function, while for traditional models, it uses a normal distribution based on the norm scores.

See Also

plotNormCurves, plotPercentiles

Other plot: plot.cnorm(), plot.cnormBetaBinomial(), plot.cnormBetaBinomial2(), plotDerivative(), plotNorm(), plotNormCurves(), plotPercentileSeries(), plotPercentiles(), plotRaw(), plotSubset()

Examples

Run this code
if (FALSE) {
# For traditional continuous norming model
result <- cnorm(raw = elfe$raw, group = elfe$group)
plotDensity(result, group = c(2, 4, 6))

# For beta-binomial model
bb_model <- cnorm.betabinomial(age = ppvt$age, score = ppvt$raw, n = 228)
plotDensity(bb_model)
}

Run the code above in your browser using DataLab