plotDensity: Plot the density function per group by raw score

plotDensityR Documentation

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
)

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.

Value

A ggplot object representing the density functions.

Note

Please check for inconsistent curves, especially those showing implausible shapes such as violations of biuniqueness in the cnorm models.

See Also

plotNormCurves, plotPercentiles

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

Examples

## Not run: 
# 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)

## End(Not run)


cNORM documentation built on Sept. 11, 2024, 8:16 p.m.