📄 addterm.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Try All One-Term Additions to a Model</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>
<table width="100%" summary="page for addterm {MASS}"><tr><td>addterm {MASS}</td><td align="right">R Documentation</td></tr></table>
<h2>Try All One-Term Additions to a Model</h2>
<h3>Description</h3>
<p>
Try fitting all models that differ from the current model by adding a
single term from those supplied, maintaining marginality.
</p>
<p>
This function is generic; there exist methods for classes <code>lm</code> and
<code>glm</code> and the default method will work for many other classes.
</p>
<h3>Usage</h3>
<pre>
addterm(object, ...)
## Default S3 method:
addterm(object, scope, scale = 0, test = c("none", "Chisq"),
k = 2, sorted = FALSE, trace = FALSE, ...)
## S3 method for class 'lm':
addterm(object, scope, scale = 0, test = c("none", "Chisq", "F"),
k = 2, sorted = FALSE, ...)
## S3 method for class 'glm':
addterm(object, scope, scale = 0, test = c("none", "Chisq", "F"),
k = 2, sorted = FALSE, trace = FALSE, ...)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>object</code></td>
<td>
An object fitted by some model-fitting function.
</td></tr>
<tr valign="top"><td><code>scope</code></td>
<td>
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.
</td></tr>
<tr valign="top"><td><code>scale</code></td>
<td>
used in the definition of the AIC statistic for selecting the models,
currently only for <code>lm</code>, <code>aov</code> and <code>glm</code> models. Specifying <code>scale</code>
asserts that the residual standard error or dispersion is known.
</td></tr>
<tr valign="top"><td><code>test</code></td>
<td>
should the results include a test statistic relative to the original
model? The F test is only appropriate for <code>lm</code> and <code>aov</code> models,
and perhaps for some over-dispersed <code>glm</code> models. The
Chisq test can be an exact test (<code>lm</code> models with known scale) or a
likelihood-ratio test depending on the method.
</td></tr>
<tr valign="top"><td><code>k</code></td>
<td>
the multiple of the number of degrees of freedom used for the penalty.
Only <code>k=2</code> gives the genuine AIC: <code>k = log(n)</code> is sometimes referred
to as BIC or SBC.
</td></tr>
<tr valign="top"><td><code>sorted</code></td>
<td>
should the results be sorted on the value of AIC?
</td></tr>
<tr valign="top"><td><code>trace</code></td>
<td>
if <code>TRUE</code> additional information may be given on the fits as they are tried.
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
arguments passed to or from other methods.
</td></tr>
</table>
<h3>Details</h3>
<p>
The definition of AIC is only up to an additive constant: when
appropriate (<code>lm</code> models with specified scale) the constant is taken
to be that used in Mallows' Cp statistic and the results are labelled
accordingly.
</p>
<h3>Value</h3>
<p>
A table of class <code>"anova"</code> containing at least columns for the change
in degrees of freedom and AIC (or Cp) for the models. Some methods
will give further information, for example sums of squares, deviances,
log-likelihoods and test statistics.</p>
<h3>References</h3>
<p>
Venables, W. N. and Ripley, B. D. (2002)
<EM>Modern Applied Statistics with S.</EM> Fourth edition. Springer.
</p>
<h3>See Also</h3>
<p>
<code><a href="dropterm.html">dropterm</a></code>, <code><a href="stepAIC.html">stepAIC</a></code>
</p>
<h3>Examples</h3>
<pre>
quine.hi <- aov(log(Days + 2.5) ~ .^4, quine)
quine.lo <- aov(log(Days+2.5) ~ 1, quine)
addterm(quine.lo, quine.hi, test="F")
house.glm0 <- glm(Freq ~ Infl*Type*Cont + Sat, family=poisson,
data=housing)
addterm(house.glm0, ~. + Sat:(Infl+Type+Cont), test="Chisq")
house.glm1 <- update(house.glm0, . ~ . + Sat*(Infl+Type+Cont))
addterm(house.glm1, ~. + Sat:(Infl+Type+Cont)^2, test = "Chisq")
</pre>
<hr><div align="center">[Package <em>MASS</em> version 7.2-44 <a href="00Index.html">Index]</a></div>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -