📄 coef.mvr.html
字号:
<html><head><title>R: Extract Information From a Fitted PLSR or PCR 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 coef.mvr {pls}"><tr><td>coef.mvr {pls}</td><td align="right">R Documentation</td></tr></table>
<h2>Extract Information From a Fitted PLSR or PCR Model</h2>
<h3>Description</h3>
<p>
Functions to extract information from <code>mvr</code> objects: Regression
coefficients, the model frame, the the model matrix, names of the
variables and components, and the <i>X</i> variance explained by the
components.
</p>
<h3>Usage</h3>
<pre>
## S3 method for class 'mvr':
coef(object, comps = object$ncomp, intercept = FALSE,
cumulative = TRUE, ...)
## S3 method for class 'mvr':
model.matrix(object, ...)
## S3 method for class 'mvr':
model.frame(formula, ...)
prednames(object, intercept = FALSE)
respnames(object)
compnames(object, comps = 1:object$ncomp, explvar = FALSE)
explvar(object)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>object, formula</code></td>
<td>
an <code>mvr</code> object. The fitted model.</td></tr>
<tr valign="top"><td><code>comps</code></td>
<td>
vector of positive integers. The components to include in
the coefficients or to extract the names of.</td></tr>
<tr valign="top"><td><code>intercept</code></td>
<td>
logical. Whether coefficients for the intercept should
be included. Ignored if <code>cumulative = FALSE</code>. Defaults to
<code>FALSE</code>.</td></tr>
<tr valign="top"><td><code>cumulative</code></td>
<td>
logical. Whether cumulative (the default) or
individual coefficients for each component should be returned. See below.</td></tr>
<tr valign="top"><td><code>explvar</code></td>
<td>
logical. Whether the explained <i>X</i> variance should
be appended to the component names.</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
other arguments sent to underlying functions. Currently
only used for <code>model.frame.mvr</code> and <code>model.matrix.mvr</code>.</td></tr>
</table>
<h3>Details</h3>
<p>
Except for <code>coef.mvr</code>, these functions are mostly used inside
other functions.
</p>
<p>
<code>coef.mvr</code> is used to extract the regression coefficients of a
model, i.e. the <i>B</i> in <i>y = XB</i>. An array of dimension
<code>c(nxvar, nyvar, length(comps))</code> is returned.
</p>
<p>
If <code>cumulative = TRUE</code>, <code>coef()[,,comps[i]]</code> are
the coefficients for models with <code>comps[i]</code> components, for
<i>i = 1, ..., length(comps)</i>. Also, if <code>intercept = TRUE</code>,
the first dimension is <i>nxvar + 1</i>, with the intercept
coefficients as the first row.
</p>
<p>
If <code>cumulative = FALSE</code>, however, <code>coef()[,,comps[i]]</code> are
the coefficients for a model with only the component <code>comps[i]</code>,
i.e. the contribution of the component <code>comps[i]</code> on the
regression coefficients.
</p>
<p>
<code>model.frame.mvr</code> returns the model frame; i.e. a data frame with
all variables neccessary to generate the model matrix. See
<code><a href="../../stats/html/model.frame.html">model.frame</a></code> for details.
</p>
<p>
<code>model.matrix.mvr</code> returns the (possibly coded) matrix used as
<i>X</i> in the fitting. See <code><a href="../../stats/html/model.matrix.html">model.matrix</a></code> for
details.
</p>
<p>
<code>prednames</code>, <code>respnames</code> and <code>compnames</code> extract the
names of the <i>X</i> variables, responses and components,
respectively. With <code>intercept = TRUE</code> in <code>prednames</code>,
the name of the intercept variable (i.e. <code>"(Intercept)"</code>) is
returned as well. If <code>explvar = TRUE</code> in <code>compnames</code>, the
explained variance for each component is appended to the component
names. For optimal formatting of the explained variances when not all
components are to be used, one should specify the desired components
with the argument <code>comps</code>.
</p>
<p>
<code>explvar</code> extracts the amount of <i>X</i> variance (in per cent)
explained by for each component in the model.
</p>
<h3>Value</h3>
<p>
<code>coef.mvr</code> returns an array of regression coefficients.
<br>
<code>model.frame.mvr</code> returns a data frame.
<br>
<code>model.matrix.mvr</code> returns the <i>X</i> matrix.
<br>
<code>prednames</code>, <code>respnames</code> and <code>compnames</code> return a
character vector with the corresponding names.
<br>
<code>explvar</code> returns a numeric vector with the explained variances.</p>
<h3>Author(s)</h3>
<p>
Ron Wehrens and Bj鴕n-Helge Mevik
</p>
<h3>See Also</h3>
<p>
<code><a href="mvr.html">mvr</a></code>
</p>
<h3>Examples</h3>
<pre>
data(NIR)
mod <- pcr(y ~ X, data = NIR[NIR$train,], ncomp = 5)
B <- coef(mod, comps = 3, intercept = TRUE)
## A manual predict method:
stopifnot(drop(B[1,,] + NIR$X[!NIR$train,] %*% B[-1,,]) ==
drop(predict(mod, comps = 3, newdata = NIR[!NIR$train,])))
## Note the difference in formatting:
mod2 <- pcr(y ~ X, data = NIR[NIR$train,])
compnames(mod2, explvar = TRUE)[1:3]
compnames(mod2, comps = 1:3, explvar = TRUE)
</pre>
<hr><div align="center">[Package <em>pls</em> version 1.1-0 <a href="00Index.html">Index]</a></div>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -