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 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 and builds up to 20 models for each number of predictors, evaluates these models regarding model consistency and selects consistent model with the highest R^2. This automatic model selection should usually be accompanied with visual inspection of the percentile plots and assessment of fit statistics. Set R^2 or 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
)

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: 4, max: 6).

t

Age power parameter. If unset, defaults to 'k'.

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

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.

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()

Examples


# Example with sample data
## Not run: 
# It is not recommende to 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)

WLenhard/cNORM documentation built on Sept. 7, 2024, 6:28 p.m.