getBest | R Documentation |
Given a set of competing fitted GVF models, this function selects the best model according to a given criterion.
getBest(object,
criterion = c("R2", "adj.R2", "AIC", "BIC"), ...)
object |
Typically, an object containing many fitted GVF models (i.e. of class |
criterion |
The quality criterion to be used for model selection. Default is |
... |
Further arguments passed to or from other methods. |
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.
A single GVF fitted model.
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.
Diego Zardetto
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.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.