blob: 32c0766688c25c68d357ae7b37f7124239a54ca3 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Fits a generalized linear model</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="R.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/languages/r.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head><body>
<table width="100%" summary="page for glm {SparkR}"><tr><td>glm {SparkR}</td><td align="right">R Documentation</td></tr></table>
<h2>Fits a generalized linear model</h2>
<h3>Description</h3>
<p>Fits a generalized linear model, similarly to R's glm(). Also see the glmnet package.
</p>
<h3>Usage</h3>
<pre>
glm(formula, family = gaussian, data, weights, subset, na.action,
start = NULL, etastart, mustart, offset, control = list(...),
model = TRUE, method = "glm.fit", x = FALSE, y = TRUE,
contrasts = NULL, ...)
## S4 method for signature 'formula,ANY,DataFrame'
glm(formula, family = c("gaussian",
"binomial"), data, lambda = 0, alpha = 0, standardize = TRUE,
solver = "auto")
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>formula</code></td>
<td>
<p>A symbolic description of the model to be fitted. Currently only a few formula
operators are supported, including '~', '.', ':', '+', and '-'.</p>
</td></tr>
<tr valign="top"><td><code>family</code></td>
<td>
<p>Error distribution. &quot;gaussian&quot; -&gt; linear regression, &quot;binomial&quot; -&gt; logistic reg.</p>
</td></tr>
<tr valign="top"><td><code>data</code></td>
<td>
<p>DataFrame for training</p>
</td></tr>
<tr valign="top"><td><code>lambda</code></td>
<td>
<p>Regularization parameter</p>
</td></tr>
<tr valign="top"><td><code>alpha</code></td>
<td>
<p>Elastic-net mixing parameter (see glmnet's documentation for details)</p>
</td></tr>
<tr valign="top"><td><code>standardize</code></td>
<td>
<p>Whether to standardize features before training</p>
</td></tr>
<tr valign="top"><td><code>solver</code></td>
<td>
<p>The solver algorithm used for optimization, this can be &quot;l-bfgs&quot;, &quot;normal&quot; and
&quot;auto&quot;. &quot;l-bfgs&quot; denotes Limited-memory BFGS which is a limited-memory
quasi-Newton optimization method. &quot;normal&quot; denotes using Normal Equation as an
analytical solution to the linear regression problem. The default value is &quot;auto&quot;
which means that the solver algorithm is selected automatically.</p>
</td></tr>
</table>
<h3>Value</h3>
<p>a fitted MLlib model
</p>
<h3>Examples</h3>
<pre><code class="r">## Not run:
##D sc &lt;- sparkR.init()
##D sqlContext &lt;- sparkRSQL.init(sc)
##D data(iris)
##D df &lt;- createDataFrame(sqlContext, iris)
##D model &lt;- glm(Sepal_Length ~ Sepal_Width, df, family=&quot;gaussian&quot;)
##D summary(model)
## End(Not run)
</code></pre>
<hr><div align="center">[Package <em>SparkR</em> version 1.6.3 <a href="00Index.html">Index</a>]</div>
</body></html>