Try all one-term additions to and deletions from a model
addtermOld.RdTry fitting all models that differ from the current model by adding or deleting a single term from those supplied while maintaining marginality.
Usage
# S3 method for class 'clm2'
addterm(object, scope, scale = 0, test = c("none", "Chisq"),
k = 2, sorted = FALSE, trace = FALSE,
which = c("location", "scale"), ...)
# S3 method for class 'clm2'
dropterm(object, scope, scale = 0, test = c("none", "Chisq"),
k = 2, sorted = FALSE, trace = FALSE,
which = c("location", "scale"), ...)Arguments
- object
A
clm2object.- scope
for
addterm: a formula specifying a maximal model which should include the current one. All additional terms in the maximal model with all marginal terms in the original model are tried. Fordropterm: a formula giving terms which might be dropped. By default, the model formula. Only terms that can be dropped and maintain marginality are actually tried.- scale
used in the definition of the AIC statistic for selecting the models. Specifying
scaleasserts that the dispersion is known.- test
should the results include a test statistic relative to the original model? The Chisq test is a likelihood-ratio test.
- k
the multiple of the number of degrees of freedom used for the penalty. Only
k=2gives the genuine AIC:k = log(n)is sometimes referred to as BIC or SBC.- sorted
should the results be sorted on the value of AIC?
- trace
if
TRUEadditional information may be given on the fits as they are tried.- which
should additions or deletions occur in location or scale models?
- ...
arguments passed to or from other methods.
Value
A table of class "anova" containing columns for the change
in degrees of freedom, AIC and the likelihood ratio statistic. If
test = "Chisq" a column also contains the
p-value from the Chisq test.
Details
The definition of AIC is only up to an additive constant because the likelihood function is only defined up to an additive constant.
Examples
options(contrasts = c("contr.treatment", "contr.poly"))
if(require(MASS)) { ## dropterm, addterm, housing
mB1 <- clm2(SURENESS ~ PROD + GENDER + SOUPTYPE,
scale = ~ COLD, data = soup, link = "probit",
Hess = FALSE)
dropterm(mB1, test = "Chi") # or
dropterm(mB1, which = "location", test = "Chi")
dropterm(mB1, which = "scale", test = "Chi")
addterm(mB1, scope = ~.^2, test = "Chi", which = "location")
addterm(mB1, scope = ~ . + GENDER + SOUPTYPE,
test = "Chi", which = "scale")
addterm(mB1, scope = ~ . + AGEGROUP + SOUPFREQ,
test = "Chi", which = "location")
## Fit model from polr example:
fm1 <- clm2(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
addterm(fm1, ~ Infl + Type + Cont, test= "Chisq", which = "scale")
dropterm(fm1, test = "Chisq")
}
#> Loading required package: MASS
#> Single term deletions
#>
#> Model:
#> location : Sat ~ Infl + Type + Cont
#> Df AIC LRT Pr(Chi)
#> <none> 3495.1
#> Infl 2 3599.4 108.239 < 2.2e-16 ***
#> Type 3 3545.1 55.910 4.391e-12 ***
#> Cont 1 3507.5 14.306 0.0001554 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1