<!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: S-regression estimators</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="https://rpkg.net/assets/examples.css" />
</head><body>

<table width="100%" summary="page for lmrob.S"><tr><td>lmrob.S</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2> S-regression estimators </h2>

<h3>Description</h3>

<p>Computes an S-estimator for linear regression,
using the &ldquo;fast S&rdquo; algorithm.
</p>


<h3>Usage</h3>

<pre>
lmrob.S(x, y, control,
        trace.lev = control$trace.lev,
        only.scale = FALSE, mf)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
<p>design matrix (<i>n * p</i>)</p>
</td></tr>
<tr valign="top"><td><code>y</code></td>
<td>
<p>numeric vector of responses (or residuals for <code>only.scale=TRUE</code>).</p>
</td></tr>
<tr valign="top"><td><code>control</code></td>
<td>
<p> list as returned by <code>lmrob.control</code>; the
following components are used for <code>lmrob.S()</code>:
<code>"trace.lev"</code>, 
<code>"nResample"</code>,
<code>"groups"</code>,
<code>"n.group"</code>,
<code>"fast.s.large.n"</code>,
<code>"seed"</code>,
<code>"bb"</code>,
<code>"psi"</code>, <code>"tuning.chi"</code>,
<code>"best.r.s"</code>,
<code>"k.fast.s"</code>,
<code>"k.max"</code>,
<code>"maxit.scale"</code>,
<code>"refine.tol"</code>, <code>"solve.tol"</code>, <code>"scale.tol"</code>,
<code>"mts"</code>,
<code>"subsampling"</code>.
</p>
</td></tr>
<tr valign="top"><td><code>trace.lev</code></td>
<td>
<p>integer indicating if the progress of the algorithm
should be traced (increasingly); default <code>trace.lev = 0</code> does
no tracing.</p>
</td></tr>
<tr valign="top"><td><code>only.scale</code></td>
<td>
<p><code>logical</code> indicating if only the scale
of <code>y</code> should be computed.  In this case, <code>y</code> will
typically contain <em>residuals</em>.</p>
</td></tr></table>


<table summary="R argblock">
<tr valign="top"><td><code>mf</code></td>
<td>
<p>defunct.</p>
</td></tr>
</table>


<h3>Details</h3>

<p>This function is used by <code>lmrob.fit</code> and typically not
to be used on its own (because an S-estimator has too low
efficiency &lsquo;on its own&rsquo;).
</p>
<p>By default, the subsampling algorithm uses a customized LU
decomposition which ensures a non singular subsample (if this is at
all possible). This makes the Fast-S algorithm also feasible for
categorical and mixed continuous-categorical data.
</p>
<p>One can revert to the old subsampling scheme by setting the parameter
<code>subsampling</code> in <code>control</code> to <code>"simple"</code>.
</p>


<h3>Value</h3>

<p>By default (when <code>only.scale</code> is false), a list with components
</p>
<table summary="R valueblock">
<tr valign="top"><td><code>coefficients</code></td>
<td>
<p>numeric vector (length <i>p</i>) of S-regression coefficient estimates.</p>
</td></tr>
<tr valign="top"><td><code>scale</code></td>
<td>
<p>the S-scale residual estimate</p>
</td></tr></table>



<table summary="R valueblock">
<tr valign="top"><td><code>fitted.values</code></td>
<td>
<p>numeric vector (length <i>n</i>) of the fitted
values.</p>
</td></tr>
<tr valign="top"><td><code>residuals</code></td>
<td>
<p>numeric vector (length <i>n</i>) of the residuals.</p>
</td></tr>
<tr valign="top"><td><code>rweights</code></td>
<td>
<p>numeric vector (length <i>n</i>) of the robustness weights.</p>
</td></tr>
<tr valign="top"><td><code>k.iter</code></td>
<td>
<p>(maximal) number of refinement iterations used.</p>
</td></tr>
<tr valign="top"><td><code>converged</code></td>
<td>
<p>logical indicating if <b>all</b> refinement
iterations had converged.</p>
</td></tr>
<tr valign="top"><td><code>control</code></td>
<td>
<p>the same list as the <code>control</code> argument.</p>
</td></tr>
</table>
<p>If <code>only.scale</code> is true, the computed scale (a number) is returned.
</p>


<h3>Author(s)</h3>

<p> Matias Salibian-Barrera and Manuel Koller; Martin Maechler for
minor new options and more documentation.
</p>


<h3>See Also</h3>

<p><code>lmrob</code>, also for references.
</p>


<h3>Examples</h3>

<pre>
set.seed(33)
x1 &lt;- sort(rnorm(30)); x2 &lt;- sort(rnorm(30)); x3 &lt;- sort(rnorm(30))
X. &lt;- cbind(x1, x2, x3)
y &lt;-  10 + X. %*% (10*(2:4)) + rnorm(30)/10
y[1] &lt;- 500   # a moderate outlier
X.[2,1] &lt;- 20 # an X outlier
X1  &lt;- cbind(1, X.)

(m.lm &lt;- lm(y ~ X.))
set.seed(12)
m.lmS &lt;- lmrob.S(x=X1, y=y,
                 control = lmrob.control(nRes = 20), trace.lev=1)
m.lmS[c("coefficients","scale")]
all.equal(unname(m.lmS$coef), 10 * (1:4), tolerance = 0.005)
stopifnot(all.equal(unname(m.lmS$coef), 10 * (1:4), tolerance = 0.005),
          all.equal(m.lmS$scale, 1/10, tolerance = 0.09))

## only.scale = TRUE:  Compute the S scale, given residuals;
s.lmS &lt;- lmrob.S(X1, y=residuals(m.lmS), only.scale = TRUE,
                 control = lmrob.control(trace.lev = 3))
all.equal(s.lmS, m.lmS$scale) # close: 1.89e-6 [64b Lnx]
</pre>


</body></html>
