User Documentation
 All Files Functions Groups
marginal.sql_in File Reference

SQL functions for linear regression. More...

Go to the source code of this file.

Functions

aggregate marginal_logregr_result marginal_logregr (boolean dependentVariable, float8[] independentVariables, float8[] coef)
 Compute marginal effects for logistic regression. More...
 
void margins_logregr (varchar source_table, varchar out_table, varchar dependent_varname, varchar input_independent_varname, varchar input_group_cols, integer[] marginal_vars, integer max_iter, varchar optimizer, float8 tolerance, boolean verbose_mode)
 A wrapper function for the various marginal regression analyzes. More...
 
CREATE OR REPLACE FUNCTION MADlib margins_logregr (source_table VARCHAR--name of input table, out_table VARCHAR--name of output table, dependent_variable VARCHAR--name of dependent variable, independent_variable VARCHAR--name of independent variable) RETURNS VOID AS $$BEGIN PERFORM MADlib.margins_logregr(source_table
 Marginal effects with default variables.
 
CREATE OR REPLACE FUNCTION MADlib margins_logregr (source_table VARCHAR--name of input table, out_table VARCHAR--name of output table, dependent_variable VARCHAR--name of dependent variable, independent_variable VARCHAR--name of independent variable, grouping_cols VARCHAR--name of grouping cols) RETURNS VOID AS $$BEGIN PERFORM MADlib.margins_logregr(source_table
 Marginal effects with default variable_names.
 
CREATE OR REPLACE FUNCTION MADlib margins_logregr (source_table VARCHAR--name of input table, out_table VARCHAR--name of output table, dependent_variable VARCHAR--name of dependent variable, independent_variable VARCHAR--name of independent variable, grouping_cols VARCHAR--name of grouping cols, marginal_vars INTEGER[]--indices of variables to calculate marginal effects on) RETURNS VOID AS $$BEGIN PERFORM MADlib.margins_logregr(source_table
 Marginal effects with default variable_names.
 
CREATE OR REPLACE FUNCTION MADlib margins_logregr (source_table VARCHAR--name of input table, out_table VARCHAR--name of output table, dependent_variable VARCHAR--name of dependent variable, independent_variable VARCHAR--name of independent variable, grouping_cols VARCHAR--name of grouping cols, marginal_vars INTEGER[]--indices of variables to calculate marginal effects on, max_iter INTEGER--Max iterations for the logstic regression inner call) RETURNS VOID AS $$BEGIN PERFORM MADlib.margins_logregr(source_table
 Marginal effects with default variable_names.
 
CREATE OR REPLACE FUNCTION MADlib margins_logregr (source_table VARCHAR--name of input table, out_table VARCHAR--name of output table, dependent_variable VARCHAR--name of dependent variable, independent_variable VARCHAR--name of independent variable, grouping_cols VARCHAR--name of grouping cols, marginal_vars INTEGER[]--indices of variables to calculate marginal effects on, max_iter INTEGER--Max iterations for the logstic regression inner call, optimizer VARCHAR--Logistic regression optimizer) RETURNS VOID AS $$BEGIN PERFORM MADlib.margins_logregr(source_table
 Marginal effects with default variable_names.
 
CREATE OR REPLACE FUNCTION MADlib margins_logregr (source_table VARCHAR--name of input table, out_table VARCHAR--name of output table, dependent_variable VARCHAR--name of dependent variable, independent_variable VARCHAR--name of independent variable, grouping_cols VARCHAR--name of grouping cols, marginal_vars INTEGER[]--indices of variables to calculate marginal effects on, max_iter INTEGER--Max iterations for the logstic regression inner call, optimizer VARCHAR--Logistic regression optimizer, tolerance DOUBLE PRECISION--Tolerance) RETURNS VOID AS $$BEGIN PERFORM MADlib.margins_logregr(source_table
 Marginal effects with default variable_names.
 

Detailed Description

Date
January 2011
See Also
Calculates marginal effects for various regression models.

Definition in file marginal.sql_in.

Function Documentation

aggregate marginal_logregr_result marginal_logregr ( boolean  dependentVariable,
float8[]  independentVariables,
float8[]  coef 
)
Parameters
dependentVariableColumn containing the dependent variable
independentVariablesColumn containing the array of independent variables
coefColumn containing the array of the coefficients (as obtained by logregr)
To include an intercept in the model, set one coordinate in the independentVariables array to 1.
Returns
A composite value:
  • margins FLOAT8[] - Array of marginal effects
  • coefFLOAT8[] - The coefficients for the regression
  • std_err FLOAT8[] - Array of standard-errors (calculated by the delta method),
  • t_stats FLOAT8[] - Array of t-statistics
  • p_values FLOAT8[] - Array of p-values
Usage:
  • Get all the diagnostic statistics:
 SELECT marginal_logregr(dependentVariable,
 independentVariables, coef)
 FROM dataTable;

Definition at line 366 of file marginal.sql_in.

void margins_logregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_varname,
varchar  input_independent_varname,
varchar  input_group_cols,
integer[]  marginal_vars,
integer  max_iter,
varchar  optimizer,
float8  tolerance,
boolean  verbose_mode 
)
Parameters
source_tableString identifying the input table
out_tableString identifying the output table to be created
dependent_varnameColumn containing the dependent variable
input_independent_varnameColumn containing the array of independent variables
grouping_colsSet of columns to group by.
marginal_varsSubset of independent variables to calculate marginal effects for.
max_iterMaximum number of iterations
optimzerOptimizer to be used (newton/irls, cg or idg)
toleranceResiual tolerance
verbose_modeVerbose mode (on/off)
To include an intercept in the model, set one coordinate in the independentVariables array to 1.
Returns
void
Usage:
For function summary information. Run sql> select margins_logregr('help'); OR sql> select margins_logregr(); OR sql> select margins_logregr('?'); For function usage information. Run sql> select margins_logregr('usage');
  • Compute the coefficients, and the get the marginal diagnostic statistics:
      select margins_logregr(source_table, out_table, dependentVariable, independentVariables);
     

Definition at line 496 of file marginal.sql_in.