<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: The cross-validation (CV) score</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body>

<table width="100%" summary="page for CV.S"><tr><td>CV.S</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>The cross-validation (CV) score</h2>

<h3>Description</h3>

<p>Compute the leave-one-out cross-validation score.
</p>


<h3>Usage</h3>

<pre>
CV.S(y, S, W = NULL, trim = 0, draw = FALSE, metric = metric.lp, ...)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>y</code></td>
<td>
<p>Matrix of set cases with dimension (<code>n</code> x <code>m</code>), where
<code>n</code> is the number of curves and <code>m</code> are the points observed in
each curve.</p>
</td></tr>
<tr valign="top"><td><code>S</code></td>
<td>
<p>Smoothing matrix, see <code>S.NW</code>, <code>S.LLR</code> or
<i>S.KNN</i>.</p>
</td></tr>
<tr valign="top"><td><code>W</code></td>
<td>
<p>Matrix of weights.</p>
</td></tr>
<tr valign="top"><td><code>trim</code></td>
<td>
<p>The alpha of the trimming.</p>
</td></tr>
<tr valign="top"><td><code>draw</code></td>
<td>
<p>=TRUE, draw the curves, the sample median and trimmed mean.</p>
</td></tr>
<tr valign="top"><td><code>metric</code></td>
<td>
<p>Metric function, by default <code>metric.lp</code>.</p>
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
<p>Further arguments passed to or from other methods.</p>
</td></tr>
</table>


<h3>Details</h3>

<p>A.-If <code>trim=0</code>:<br />
</p>
<p style="text-align: center;"><i>CV(h)=1/n\,
&sum;_i ((y_i\, -\, r_{i}(x_i))\, /\, (1\, -\, S_ii))^2\, w(x_i),\,
i=1,...,n</i></p>
 <p><i>Sii</i> is the ith diagonal element of the smoothing
matrix <i>S</i>.
</p>
<p>B.-If <code>trim&gt;0</code>:<br /> </p>
<p style="text-align: center;"><i>CV(h)=1/n\
&sum;_i ((y_i-r_{i}(x_i))/(1-S_ii))^2 w(x_i),\, i=1,...,l</i></p>
 <p><i>Sii</i>
is the ith diagonal element of the smoothing matrix <i>S</i> and l the
index of <code>(1-trim)</code> curves with less error.
</p>


<h3>Value</h3>

<p> Returns CV score calculated for input parameters.  
</p>


<h3>Author(s)</h3>

<p>Manuel Febrero-Bande, Manuel Oviedo de la Fuente
<a href="mailto:manuel.oviedo@udc.es">manuel.oviedo@udc.es</a>
</p>


<h3>References</h3>

<p>Wasserman, L. <em>All of Nonparametric Statistics</em>. Springer
Texts in Statistics, 2006.
</p>


<h3>See Also</h3>

<p>See Also as <code>optim.np</code> <br /> Alternative method:
<code>GCV.S</code>
</p>


<h3>Examples</h3>

<pre>
## Not run: 
data(tecator)
x&lt;-tecator$absorp.fdata
np&lt;-ncol(x)
tt&lt;-1:np
S1 &lt;- S.NW(tt,3,Ker.epa)
S2 &lt;- S.LLR(tt,3,Ker.epa)
S3 &lt;- S.NW(tt,5,Ker.epa)
S4 &lt;- S.LLR(tt,5,Ker.epa)
cv1 &lt;- CV.S(x, S1)
cv2 &lt;- CV.S(x, S2)
cv3 &lt;- CV.S(x, S3)
cv4 &lt;- CV.S(x, S4)
cv5 &lt;- CV.S(x, S4,trim=0.1,draw=TRUE)
cv1;cv2;cv3;cv4;cv5
S6 &lt;- S.KNN(tt,1,Ker.unif,cv=TRUE)
S7 &lt;- S.KNN(tt,5,Ker.unif,cv=TRUE)
cv6 &lt;- CV.S(x, S6)
cv7 &lt;- CV.S(x, S7)
cv6;cv7

## End(Not run)
 
</pre>


</body></html>
