⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coef.mvr.html

📁 偏最小二乘法
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<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, fitted values, residuals, the model frame, 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, ncomp = object$ncomp, comps, intercept = FALSE, ...)
## S3 method for class 'mvr':
fitted(object, ...)
## S3 method for class 'mvr':
residuals(object, ...)
## 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, 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>ncomp, comps</code></td>
<td>
vector of positive integers.  The components to include in
the coefficients or to extract the names of.  See below.</td></tr>
<tr valign="top"><td><code>intercept</code></td>
<td>
logical.  Whether coefficients for the intercept should
be included.  Ignored if <code>comps</code> is specified.  Defaults to
<code>FALSE</code>.</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>
These functions are mostly used inside other functions.  (Functions
<code>coef.mvr</code>, <code>fitted.mvr</code> and <code>residuals.mvr</code> are
usually called through their generic functions <code><a href="../../stats/html/coef.html">coef</a></code>,
<code><a href="../../VGAM/html/notdocumentedyet.html">fitted</a></code> and <code><a href="../../VGAM/html/notdocumentedyet.html">residuals</a></code>, respectively.)
</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(ncomp))</code>  or <code>c(nxvar, nyvar,
    length(comps))</code> is returned.
</p>
<p>
If <code>comps</code> is missing (or is <code>NULL</code>),
<code>coef()[,,ncomp[i]]</code> are the coefficients for models with
<code>ncomp[i]</code> components, for <i>i = 1, ..., length(ncomp)</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>comps</code> is given, 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>fitted.mvr</code> and <code>residuals.mvr</code> return the fitted values
and residuals, respectively.  If the model was fitted with
<code>na.action = na.exclude</code> (or after setting the default
<code>na.action</code> to <code>"na.exclude"</code> with <code><a href="../../base/html/options.html">options</a></code>),
the fitted values (or residuals) corresponding to excluded 
observations are returned as <code>NA</code>; otherwise, they are omitted.
</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.  <code>compnames</code> can also extract component names
from score and loading matrices.  If <code>explvar = TRUE</code> in <code>compnames</code>, the
explained variance for each component (if available) 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.  It can also handle
score and loading matrices returned by <code><a href="scores.html">scores</a></code> and <code><a href="scores.html">loadings</a></code>.
</p>


<h3>Value</h3>

<p>
<code>coef.mvr</code> returns an array of regression coefficients.
<br>
<code>fitted.mvr</code> returns an array with fitted values.
<br>
<code>residuals.mvr</code> returns an array with residuals.
<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,
or <code>NULL</code> if not available.</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>, <code><a href="../../stats/html/coef.html">coef</a></code>, <code><a href="../../VGAM/html/notdocumentedyet.html">fitted</a></code>,
<code><a href="../../VGAM/html/notdocumentedyet.html">residuals</a></code>, <code><a href="../../stats/html/model.frame.html">model.frame</a></code>,
<code><a href="../../stats/html/model.matrix.html">model.matrix</a></code>, <code><a href="../../stats/html/na.fail.html">na.omit</a></code>
</p>


<h3>Examples</h3>

<pre>
data(yarn)
mod &lt;- pcr(density ~ NIR, data = yarn[yarn$train,], ncomp = 5)
B &lt;- coef(mod, ncomp = 3, intercept = TRUE)
## A manual predict method:
stopifnot(drop(B[1,,] + yarn$NIR[!yarn$train,] %*% B[-1,,]) ==
          drop(predict(mod, ncomp = 3, newdata = yarn[!yarn$train,])))

## Note the difference in formatting:
mod2 &lt;- pcr(density ~ NIR, data = yarn[yarn$train,])
compnames(mod2, explvar = TRUE)[1:3]
compnames(mod2, comps = 1:3, explvar = TRUE)
</pre>



<hr><div align="center">[Package <em>pls</em> version 2.0-1 <a href="00Index.html">Index]</a></div>

</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -