getR2: Quality Measures on Fitted GVF Models

getR2R Documentation

Quality Measures on Fitted GVF Models

Description

These functions extract goodness-of-fit measures from fitted GVF models.

Usage

getR2(object, adjusted = FALSE, ...)

## S3 method for class 'gvf.fits'
AIC(object, ...)

## S3 method for class 'gvf.fits'
BIC(object, ...)

Arguments

object

An object containing one or more fitted GVF models.

adjusted

Should the adjusted R^2 be computed? The default is FALSE

...

Further arguments passed to or from other methods.

Details

These functions compute three goodness-of-fit measures on fitted GVF models: R^2, AIC, and BIC. Such measures can help compare the relative quality of competing GVF models, hence facilitating model selection (see also function getBest).

Though object can also be a single fitted GVF model, these functions are principally meant to compare different GVF models fitted to the same data (i.e. the same estimates and errors).

To request the adjusted R^2, use function getR2 and specify adjusted = TRUE.

Value

If object is a single GVF model (class gvf.fit), the requested quality measure.

If object is a set of GVF models fitted to the same data (class gvf.fits), a vector whose elements store the requested quality measure for each GVF model.

If object is a single GVF model fitted to "grouped" data (class gvf.fit.gr), a list whose components store the requested quality measure for the corresponding groups.

If object is a set of GVF models fitted to "grouped" data (class gvf.fits.gr), a list whose components store vectors whose elements report the requested quality measure for each GVF model of each group.

Methodological Warning

Each one of the provided quality measures 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 *single* fitted GVF model ##
# Fit example data to registered GVF model number one:
m <- fit.gvf(ee.AF, 1)

# Compute some goodness-of-fit measures:
getR2(m)
AIC(m)


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

# Compute some goodness-of-fit measures:
getR2(mm, adjusted = TRUE)
BIC(mm)


## (C) a *single* GVF model 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 registered GVF model number one separately inside groups:
m.g <- fit.gvf(ee.g, 1)

# Compute some goodness-of-fit measures:
getR2(mm)
AIC(mm)


## (D) a *set of* GVF models fitted to *grouped* data ##
# Fit all registered GVF model number separately inside groups:
mm.g <- fit.gvf(ee.g)

# Compute some goodness-of-fit measures:
getR2(mm.g, adjusted = TRUE)
BIC(mm.g)

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