compare: Compare Two Norm Models Visually

compareR Documentation

Compare Two Norm Models Visually

Description

This function creates a visualization comparing two norm models by displaying their percentile curves. The first model is shown with solid lines, the second with dashed lines. If age and score vectors are provided, manifest percentiles are displayed as dots. The function works with regular cnorm models, beta-binomial models, and shash models, allowing comparison between different model types.

Usage

compare(
  model1,
  model2,
  percentiles = c(0.025, 0.1, 0.25, 0.5, 0.75, 0.9, 0.975),
  age = NULL,
  score = NULL,
  weights = NULL,
  title = NULL,
  subtitle = NULL,
  discrete = TRUE
)

Arguments

model1

First model object (distribution free, beta-binomial, or shash)

model2

Second model object (distribution free, beta-binomial, or shash)

percentiles

Vector with percentile scores, ranging from 0 to 1 (exclusive)

age

Optional vector with manifest age or group values

score

Optional vector with manifest raw score values

weights

Optional vector with manifest weights

title

Custom title for plot (optional)

subtitle

Custom subtitle for plot (optional)

discrete

Logical indicating whether beta-binomial models are displayed with their exact discrete quantiles as step functions (TRUE, default) or with a smooth continuous approximation via the underlying beta distribution (FALSE). Ignored for other model types.

Details

For beta-binomial models, the exact quantiles of the discrete beta-binomial distribution are displayed by default as step functions (discrete = TRUE). Setting discrete = FALSE draws smooth lines based on the quantiles of the underlying beta (mixing) distribution instead. Note that this continuous approximation omits the binomial stage of the variance and therefore displays less spread than the fitted model actually implies, particularly in the outer percentiles. The parameter has no effect on Taylor polynomial or shash models.

Value

A ggplot object showing the comparison of both models

See Also

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

Examples

## Not run: 
# Compare different types of models
model1 <- cnorm(group = elfe$group, raw = elfe$raw)
model2 <- cnorm.betabinomial(elfe$group, elfe$raw)
model3 <- cnorm.shash(elfe$group, elfe$raw)

# Compare traditional cnorm with shash
compare(model1, model3, age = elfe$group, score = elfe$raw)

# Compare beta-binomial with shash
compare(model2, model3, age = elfe$group, score = elfe$raw)

## End(Not run)


cNORM documentation built on July 13, 2026, 5:08 p.m.