bestModel: Determine Regression Model

View source: R/modelling.R

bestModelR Documentation

Determine Regression Model

Description

Computes Taylor polynomial regression models by evaluating a series of models with increasing number of predictors. It aims to find a consistent model that effectively captures the variance in the data. It draws on the regsubsets function from the leaps package, builds up to 10 models per number of predictors, screens them for model consistency (monotonicity of the mapping between norm score and raw score over the complete age range) and selects the consistent model with the highest R^2. This automatic model selection should usually be accompanied by visual inspection of the percentile plots and assessment of fit statistics. Set R^2 or the number of terms manually to retrieve a more parsimonious model, if desired.

Usage

bestModel(
  data,
  raw = NULL,
  R2 = NULL,
  k = NULL,
  t = NULL,
  predictors = NULL,
  terms = 0,
  weights = NULL,
  force.in = NULL,
  plot = TRUE,
  extensive = TRUE,
  averaging = FALSE,
  subsampling = FALSE
)

Arguments

data

Preprocessed dataset with 'raw' scores, powers, interactions, and usually an explanatory variable (like age).

raw

Name of the raw score variable (default: 'raw').

R2

Adjusted R^2 stopping criterion for model building.

k

Power constant influencing model complexity (default: taken from the data preparation, max: 6).

t

Age power parameter. If unset, taken from the data preparation (default 3).

predictors

List of predictors or regression formula for model selection. Overrides 'k' and can include additional variables.

terms

Desired number of terms in the model.

weights

Optional case weights. If set to FALSE, default weights (if any) are ignored.

force.in

Variables forcibly included in the regression.

plot

If TRUE (default), displays a percentile plot of the model and information about the regression object. FALSE turns off plotting and report.

extensive

If TRUE (default), screen models for consistency and - if possible - exclude inconsistent ones.

averaging

If TRUE (default FALSE), apply BIC-weighted model averaging across the consistency-screened candidate models instead of selecting a single model. Requires extensive = TRUE and age-based norming.

subsampling

Deprecated and ignored. Use averaging instead.

Details

The functions rankBySlidingWindow, rankByGroup, bestModel, computePowers and prepareData are usually not called directly, but accessed through other functions like cnorm.

Additional functions like plotSubset(model) and cnorm.cv can aid in model evaluation.

If averaging = TRUE, the final coefficients are not taken from a single selected model, but computed as a BIC-weighted average across all consistency-screened candidate models (weights w_j \propto exp(-\Delta BIC_j / 2)). Since a convex combination of functions that are all monotone in the same direction is itself monotone, the averaged model is guaranteed to remain consistent, while reducing model selection variance. This replaces the deprecated subsampling approach.

Value

The model. Further exploration can be done using plotSubset(model) and plotPercentiles(data, model).

See Also

plotSubset, plotPercentiles, plotPercentileSeries, checkConsistency

Other model: checkConsistency(), cnorm.cv(), derive(), modelSummary(), print.cnorm(), printSubset(), rangeCheck(), regressionFunction(), summary.cnorm(), weightedAverageModel()

Examples

## Not run: 
# It is not recommended to directly use this function. Rather use 'cnorm' instead.
normData <- prepareData(elfe)
model <- bestModel(normData)
plotSubset(model)
plotPercentiles(buildCnormObject(normData, model))

# Specifying variables explicitly
preselectedModel <- bestModel(normData, predictors = c("L1", "L3", "L1A3", "A2", "A3"))
print(regressionFunction(preselectedModel))

## End(Not run)

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