getBest: Identify the Best Fit GVF Model

View source: R/gvf.R

getBestR Documentation

Identify the Best Fit GVF Model

Description

Given a set of competing fitted GVF models, this function selects the best model according to a given criterion.

Usage

getBest(object,
        criterion = c("R2", "adj.R2", "AIC", "BIC"), ...)

Arguments

object

Typically, an object containing many fitted GVF models (i.e. of class gvf.fits or gvf.fits.gr).

criterion

The quality criterion to be used for model selection. Default is R^2.

...

Further arguments passed to or from other methods.

Details

Given a set of competing fitted GVF models, this function selects the best model according to a given criterion.

Four goodness-of-fit criteria are available: R^2, adjusted R^2, AIC, and BIC (see getR2).

If object is a set of GVF models fitted to grouped data (i.e. of class gvf.fits.gr), the function will return the fitted GVF model with best average score in the given criterion over the groups.

Value

A single GVF fitted model.

Methodological Warning

Each one of the available criteria has its own specificities and limitations (e.g. it is senseless to use AIC to compare two GVF models with different response variables). It is up to the user to select the measure which is appropriate to his goals.

Author(s)

Diego Zardetto

See Also

GVF.db to manage ReGenesees archive of registered GVF models, gvf.input and svystat to prepare the input for GVF model fitting, fit.gvf to fit GVF models, plot.gvf.fit to get diagnostic plots for fitted GVF models, drop.gvf.points to drop alleged outliers from a fitted GVF model and simultaneously refit it, and predictCV to predict CV values via fitted GVF models.

Examples

# Load example data:
data(AF.gvf)

# Inspect available estimates and errors of counts:
str(ee.AF)

# List available registered GVF models:
GVF.db


## (A) A *a set* of GVF models fitted to the same data ##
# Fit example data to all registered GVF models:
mm <- fit.gvf(ee.AF)
summary(mm)

# Get the best model according to adjusted R^2:
mm.best <- getBest(mm, criterion = "adj.R2")
mm.best

# NOTE: The *first* model has been selected. A thorough model comparison
#       by means of diagnostic plots would have led to the same result:
plot(mm, 1:3)


## (B) a *set of* GVF models fitted to *grouped* data ##
# We have at our disposal the following survey design object on household data:
exdes

# Use function svystat to prepare *grouped* estimates and errors of counts
# to be fitted separately (here groups are regions):
ee.g <- svystat(exdes, y=~ind, by=~age5c:marstat:sex, combo=3, group=~regcod)
str(ee.g)

# Fit all registered GVF model number separately inside groups:
mm.g <- fit.gvf(ee.g)
summary(mm.g)

# Get the best model according to R^2:
mm.g.best <- getBest(mm.g)
mm.g.best

# NOTE: Again, the *first* model has been selected. A thorough model comparison
#       by means of diagnostic plots would have led to the same result:
plot(mm.g, 1:3)

DiegoZardetto/ReGenesees documentation built on Dec. 16, 2024, 2:03 p.m.