blob: fede454dd18298525807e93c5d441e3ce31020ed [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MADlib: multilogistic.sql_in File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<script src="../mathjax/MathJax.js">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">MADlib
&#160;<span id="projectnumber">0.6</span> <span style="font-size:10pt; font-style:italic"><a href="../latest/./multilogistic_8sql__in.html"> A newer version is available</a></span>
</div>
<div id="projectbrief">User Documentation</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="dynsections.js"></script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&#160;List</span></a></li>
<li><a href="globals.html"><span>File&#160;Members</span></a></li>
</ul>
</div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
initNavTree('multilogistic_8sql__in.html','');
</script>
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">multilogistic.sql_in File Reference</div> </div>
</div>
<div class="contents">
<p>SQL functions for multinomial logistic regression.
<a href="#details">More...</a></p>
<p><a href="multilogistic_8sql__in_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">mlogregr_result&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="multilogistic_8sql__in.html#a8037cc95b1349de7f8910768be3262c8">mlogregr</a> (varchar source, varchar depvar, integer numcategories, varchar indepvar, integer maxnumiterations=20, varchar optimizer=&quot;irls&quot;, float8 precision=0.0001)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute logistic-regression coefficients and diagnostic statistics. <a href="#a8037cc95b1349de7f8910768be3262c8"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><dl class="date"><dt><b>Date:</b></dt><dd>July 2012</dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd>For a brief introduction to multinomial <a class="el" href="logistic_8sql__in.html#a4ded9be5c8b111dbb3109efaad83d69e" title="Evaluate the usual logistic function in an under-/overflow-safe way.">logistic</a> regression, see the module description <a class="el" href="group__grp__mlogreg.html">Multinomial Logistic Regression</a>. </dd></dl>
<p>Definition in file <a class="el" href="multilogistic_8sql__in_source.html">multilogistic.sql_in</a>.</p>
</div><hr/><h2>Function Documentation</h2>
<a class="anchor" id="a8037cc95b1349de7f8910768be3262c8"></a><!-- doxytag: member="multilogistic.sql_in::mlogregr" ref="a8037cc95b1349de7f8910768be3262c8" args="(varchar source, varchar depvar, integer numcategories, varchar indepvar, integer maxnumiterations=20, varchar optimizer=&quot;irls&quot;, float8 precision=0.0001)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">mlogregr_result mlogregr </td>
<td>(</td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>source</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>depvar</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>numcategories</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>indepvar</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer&#160;</td>
<td class="paramname"><em>maxnumiterations</em> = <code>20</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">varchar&#160;</td>
<td class="paramname"><em>optimizer</em> = <code>&quot;irls&quot;</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">float8&#160;</td>
<td class="paramname"><em>precision</em> = <code>0.0001</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>To include an intercept in the model, set one coordinate in the <code>independentVariables</code> array to 1.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramname">source</td><td>Name of the source relation containing the training data </td></tr>
<tr><td class="paramname">depvar</td><td>Name of the dependent column (of type INTEGER &lt; numcategories - 1) </td></tr>
<tr><td class="paramname">numcategories</td><td>Number of categories for the dependant variables ( of type INTEGER) </td></tr>
<tr><td class="paramname">indepvar</td><td>Name of the independent column (of type DOUBLE PRECISION[]) </td></tr>
<tr><td class="paramname">maxnumiterations</td><td>The maximum number of iterations </td></tr>
<tr><td class="paramname">optimizer</td><td>The optimizer to use ( <code>'irls'</code>/<code>'newton'</code> for iteratively reweighted least squares) </td></tr>
<tr><td class="paramname">precision</td><td>The difference between log-likelihood values in successive iterations that should indicate convergence. Note that a non-positive value here disables the convergence criterion, and execution will only stop after \ maxNumIterations iterations.</td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A composite value:<ul>
<li><code>coef FLOAT8[]</code> - Array of coefficients, \( \boldsymbol c \)</li>
<li><code>log_likelihood FLOAT8</code> - Log-likelihood \( l(\boldsymbol c) \)</li>
<li><code>std_err FLOAT8[]</code> - Array of standard errors, \( \mathit{se}(c_1), \dots, \mathit{se}(c_k) \)</li>
<li><code>z_stats FLOAT8[]</code> - Array of Wald z-statistics, \( \boldsymbol z \)</li>
<li><code>p_values FLOAT8[]</code> - Array of Wald p-values, \( \boldsymbol p \)</li>
<li><code>odds_ratios FLOAT8[]</code>: Array of odds ratios, \( \mathit{odds}(c_1), \dots, \mathit{odds}(c_k) \)</li>
<li><code>condition_no FLOAT8</code> - The condition number of matrix \( X^T A X \) during the iteration immediately <em>preceding</em> convergence (i.e., \( A \) is computed using the coefficients of the previous iteration)</li>
<li><code>num_iterations INTEGER</code> - The number of iterations before the algorithm terminated</li>
</ul>
</dd></dl>
<dl class="user"><dt><b>Usage:</b></dt><dd><ul>
<li>Get vector of coefficients \( \boldsymbol c \) and all diagnostic statistics:<br/>
<pre>SELECT * FROM mlogregr('<em>sourceName</em>', '<em>dependentVariable</em>',
'<em>numCategories</em>', '<em>independentVariables</em>');</pre></li>
<li>Get vector of coefficients \( \boldsymbol c \):<br/>
<pre>SELECT (mlogregr('<em>sourceName</em>', '<em>dependentVariable</em>',
'<em>numCategories</em>', '<em>independentVariables</em>')).coef;</pre></li>
<li>Get a subset of the output columns, e.g., only the array of coefficients \( \boldsymbol c \), the log-likelihood of determination \( l(\boldsymbol c) \), and the array of p-values \( \boldsymbol p \): <pre>SELECT coef, log_likelihood, p_values
FROM mlogregr('<em>sourceName</em>', '<em>dependentVariable</em>',
'<em>numCategories</em>', '<em>independentVariables</em>');</pre></li>
</ul>
</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>This function starts an iterative algorithm. It is not an aggregate function. Source and column names have to be passed as strings (due to limitations of the SQL syntax). </dd></dl>
<p>Definition at line <a class="el" href="multilogistic_8sql__in_source.html#l00362">362</a> of file <a class="el" href="multilogistic_8sql__in_source.html">multilogistic.sql_in</a>.</p>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="multilogistic_8sql__in.html">multilogistic.sql_in</a> </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<li class="footer">Generated on Tue Apr 2 2013 14:57:03 for MADlib by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
</ul>
</div>
</body>
</html>