1.19.0
User Documentation for Apache MADlib
marginal.sql_in File Reference

SQL functions for linear regression. More...

Functions

float8 [] marginal_logregr_step_transition (float8[] state, boolean y, float8[] x, float8[] coef)
 
float8 [] marginal_logregr_step_merge_states (float8[] state1, float8[] state2)
 
marginal_logregr_result marginal_logregr_step_final (float8[] state)
 
aggregate marginal_logregr_result marginal_logregr (boolean dependentVariable, float8[] independentVariables, float8[] coef)
 Compute marginal effects for logistic regression. More...
 
varchar margins_logregr (varchar message)
 
varchar margins_logregr ()
 
void margins_logregr (varchar source_table, varchar out_table, varchar dependent_varname, varchar independent_varname, varchar grouping_cols, integer[] marginal_vars, integer max_iter, varchar optimizer, float8 tolerance, boolean verbose_mode)
 A wrapper function for the various marginal regression analyzes. More...
 
void margins_logregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable)
 Marginal effects with default variables. More...
 
void margins_logregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, varchar grouping_cols)
 Marginal effects with default variable_names. More...
 
void margins_logregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, varchar grouping_cols, integer[] marginal_vars)
 Marginal effects with default variable_names. More...
 
void margins_logregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, varchar grouping_cols, integer[] marginal_vars, integer max_iter)
 Marginal effects with default variable_names. More...
 
void margins_logregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, varchar grouping_cols, integer[] marginal_vars, integer max_iter, varchar optimizer)
 Marginal effects with default variable_names. More...
 
void margins_logregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, varchar grouping_cols, integer[] marginal_vars, integer max_iter, varchar optimizer, float8 tolerance)
 Marginal effects with default variable_names. More...
 
float8 [] mlogregr_marginal_step_transition (float8[] state, integer y, integer num_categories, integer ref_category, float8[] x, float8[] coef)
 
float8 [] mlogregr_marginal_step_merge_states (float8[] state1, float8[] state2)
 
marginal_mlogregr_result mlogregr_marginal_step_final (float8[] state)
 
aggregate marginal_mlogregr_result marginal_mlogregr (integer dependentVariable, integer num_categories, integer ref_category, float8[] independentVariables, float8[] coef)
 Compute marginal effects for multinomial logistic regression. More...
 
varchar margins_mlogregr (varchar message)
 
varchar margins_mlogregr ()
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_varname, varchar independent_varname, integer ref_category, varchar grouping_cols, integer[] marginal_vars, varchar optimizer_params, boolean verbose_mode)
 A wrapper function for the various marginal multinomial regression. More...
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_varname, varchar independent_varname, integer ref_category, varchar grouping_cols, integer[] marginal_vars, varchar optimizer_params)
 Marginal effects with default variable_names. More...
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_varname, varchar independent_varname, integer ref_category, varchar grouping_cols, integer[] marginal_vars, integer max_iter, varchar optimizer, float8 tolerance, boolean verbose_mode)
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, integer ref_category, varchar grouping_cols, integer[] marginal_vars, integer max_iter)
 Marginal effects with default variable_names. More...
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, integer ref_category, varchar grouping_cols, integer[] marginal_vars, integer max_iter, varchar optimizer)
 Marginal effects with default variable_names. More...
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, integer ref_category, varchar grouping_cols, integer[] marginal_vars, integer max_iter, varchar optimizer, float8 tolerance)
 Marginal effects with default variable_names. More...
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable)
 Marginal effects with default variables. More...
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, integer ref_category)
 Marginal effects with default variables. More...
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, integer ref_category, varchar grouping_cols)
 Marginal effects with default variable_names. More...
 
void margins_mlogregr (varchar source_table, varchar out_table, varchar dependent_variable, varchar independent_variable, integer ref_category, varchar grouping_cols, integer[] marginal_vars)
 Marginal effects with default variable_names. More...
 
float8 [] __sub_array (float8[] value_array, integer[] index_array)
 
float8 [] __margins_linregr_int_transition (float8[] state, float8[] x, float8[] coef, float8[] vcov, float8[] derivative)
 
float8 [] __margins_linregr_int_merge (float8[] state1, float8[] state2)
 
margins_result __margins_linregr_int_final (float8[] state)
 
aggregate margins_result __margins_int_linregr_agg (float8[] independentVariables, float8[] coef, float8[] vcov, float8[] derivative_matrix)
 Compute marginal effects for linear regression. More...
 
float8 [] __margins_logregr_int_transition (float8[] state, float8[] x, float8[] coef, float8[] vcov, float8[] basis_indices, float8[] derivative, float8[] categorical_indices, float8[] x_set, float8[] x_unset)
 
float8 [] __margins_logregr_int_merge (float8[] state1, float8[] state2)
 
margins_result __margins_logregr_int_final (float8[] state)
 
aggregate margins_result __margins_int_logregr_agg (float8[] independentVariables, float8[] coef, float8[] vcov, float8[] basis_indices, float8[] derivative_matrix, float8[] categorical_indices, float8[] x_set, float8[] x_unset)
 Compute marginal effects for logistic regression. More...
 
float8 [] __margins_mlogregr_int_transition (float8[] state, float8[] x, float8[] coef, float8[] vcov, float8[] basis_indices, float8[] derivative_matrix, float8[] categorical_indices, float8[] x_set, float8[] x_unset)
 
float8 [] __margins_mlogregr_int_merge (float8[] state1, float8[] state2)
 
margins_result __margins_mlogregr_int_final (float8[] state)
 
aggregate margins_result __margins_int_mlogregr_agg (float8[] independentVariables, float8[] coef, float8[] vcov, float8[] basis_indices, float8[] derivative_matrix, float8[] categorical_indices, float8[] x_set, float8[] x_unset)
 Compute marginal effects for multinomial logistic regression. More...
 
float8 [] __margins_coxph_int_transition (float8[] state, float8[] x, float8[] coef, float8[] vcov, float8[] basis_indices, float8[] derivative_matrix, float8[] categorical_indices, float8[] x_set, float8[] x_unset)
 
float8 [] __margins_coxph_int_merge (float8[] state1, float8[] state2)
 
margins_result __margins_coxph_int_final (float8[] state)
 
margins_result __margins_compute_stats (float8[] marginal_effects, float8[] std_err)
 
aggregate margins_result __margins_int_coxph_agg (float8[] independentVariables, float8[] coef, float8[] vcov, float8[] basis_indices, float8[] derivative_matrix, float8[] categorical_indices, float8[] x_set, float8[] x_unset)
 Compute marginal effects for multinomial logistic regression. More...
 
void margins (varchar model_table, varchar out_table, varchar x_design, varchar source_table, varchar marginal_vars)
 Marginal effects with default variable_names. More...
 
void margins (varchar model_table, varchar out_table, varchar x_design, varchar source_table)
 
void margins (varchar model_table, varchar out_table, varchar x_design)
 
void margins (varchar model_table, varchar out_table)
 
varchar margins (varchar message)
 
varchar margins ()
 

Detailed Description

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

Function Documentation

◆ __margins_compute_stats()

margins_result __margins_compute_stats ( float8 []  marginal_effects,
float8 []  std_err 
)

◆ __margins_coxph_int_final()

margins_result __margins_coxph_int_final ( float8 []  state)

◆ __margins_coxph_int_merge()

float8 [] __margins_coxph_int_merge ( float8 []  state1,
float8 []  state2 
)

◆ __margins_coxph_int_transition()

float8 [] __margins_coxph_int_transition ( float8 []  state,
float8 []  x,
float8 []  coef,
float8 []  vcov,
float8 []  basis_indices,
float8 []  derivative_matrix,
float8 []  categorical_indices,
float8 []  x_set,
float8 []  x_unset 
)

◆ __margins_int_coxph_agg()

aggregate margins_result __margins_int_coxph_agg ( float8 []  independentVariables,
float8 []  coef,
float8 []  vcov,
float8 []  basis_indices,
float8 []  derivative_matrix,
float8 []  categorical_indices,
float8 []  x_set,
float8 []  x_unset 
)
Parameters
dependentVariableColumn containing the dependent variable
independentVariablesColumn containing the array of independent variables
coefColumn containing the array of the coefficients (as obtained by logregr)
Returns
A composite value:
  • margins FLOAT8[] - Array of marginal effects
  • std_err FLOAT8[] - Array of standard-errors (calculated by the delta method),
  • z_stats FLOAT8[] - Array of z-statistics
  • p_values FLOAT8[] - Array of p-values
Usage
  • Get all the diagnostic statistics:

◆ __margins_int_linregr_agg()

aggregate margins_result __margins_int_linregr_agg ( float8 []  independentVariables,
float8 []  coef,
float8 []  vcov,
float8 []  derivative_matrix 
)
Parameters
independentVariablesColumn containing the array of independent variables
coefColumn containing the array of the coefficients (as obtained by logregr)
Returns
A composite value:
  • margins FLOAT8[] - Array of marginal effects
  • std_err FLOAT8[] - Array of standard-errors (calculated by the delta method),
  • z_stats FLOAT8[] - Array of z-statistics
  • p_values FLOAT8[] - Array of p-values *

◆ __margins_int_logregr_agg()

aggregate margins_result __margins_int_logregr_agg ( float8 []  independentVariables,
float8 []  coef,
float8 []  vcov,
float8 []  basis_indices,
float8 []  derivative_matrix,
float8 []  categorical_indices,
float8 []  x_set,
float8 []  x_unset 
)
Parameters
dependentVariableColumn containing the dependent variable
independentVariablesColumn containing the array of independent variables
coefColumn containing the array of the coefficients (as obtained by logregr)
Returns
A composite value:
  • margins FLOAT8[] - Array of marginal effects
  • std_err FLOAT8[] - Array of standard-errors (calculated by the delta method),
  • z_stats FLOAT8[] - Array of z-statistics
  • p_values FLOAT8[] - Array of p-values
Usage
  • Get all the diagnostic statistics:

◆ __margins_int_mlogregr_agg()

aggregate margins_result __margins_int_mlogregr_agg ( float8 []  independentVariables,
float8 []  coef,
float8 []  vcov,
float8 []  basis_indices,
float8 []  derivative_matrix,
float8 []  categorical_indices,
float8 []  x_set,
float8 []  x_unset 
)
Parameters
dependentVariableColumn containing the dependent variable
independentVariablesColumn containing the array of independent variables
coefColumn containing the array of the coefficients (as obtained by logregr)
Returns
A composite value:
  • margins FLOAT8[] - Array of marginal effects
  • std_err FLOAT8[] - Array of standard-errors (calculated by the delta method),
  • z_stats FLOAT8[] - Array of z-statistics
  • p_values FLOAT8[] - Array of p-values
Usage
  • Get all the diagnostic statistics:

◆ __margins_linregr_int_final()

margins_result __margins_linregr_int_final ( float8 []  state)

◆ __margins_linregr_int_merge()

float8 [] __margins_linregr_int_merge ( float8 []  state1,
float8 []  state2 
)

◆ __margins_linregr_int_transition()

float8 [] __margins_linregr_int_transition ( float8 []  state,
float8 []  x,
float8 []  coef,
float8 []  vcov,
float8 []  derivative 
)

◆ __margins_logregr_int_final()

margins_result __margins_logregr_int_final ( float8 []  state)

◆ __margins_logregr_int_merge()

float8 [] __margins_logregr_int_merge ( float8 []  state1,
float8 []  state2 
)

◆ __margins_logregr_int_transition()

float8 [] __margins_logregr_int_transition ( float8 []  state,
float8 []  x,
float8 []  coef,
float8 []  vcov,
float8 []  basis_indices,
float8 []  derivative,
float8 []  categorical_indices,
float8 []  x_set,
float8 []  x_unset 
)

◆ __margins_mlogregr_int_final()

margins_result __margins_mlogregr_int_final ( float8 []  state)

◆ __margins_mlogregr_int_merge()

float8 [] __margins_mlogregr_int_merge ( float8 []  state1,
float8 []  state2 
)

◆ __margins_mlogregr_int_transition()

float8 [] __margins_mlogregr_int_transition ( float8 []  state,
float8 []  x,
float8 []  coef,
float8 []  vcov,
float8 []  basis_indices,
float8 []  derivative_matrix,
float8 []  categorical_indices,
float8 []  x_set,
float8 []  x_unset 
)

◆ __sub_array()

float8 [] __sub_array ( float8 []  value_array,
integer []  index_array 
)

◆ marginal_logregr()

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),
  • z_stats FLOAT8[] - Array of z-statistics
  • p_values FLOAT8[] - Array of p-values
Usage
  • Get all the diagnostic statistics:
     SELECT marginal_logregr(dependentVariable,
     independentVariables, coef)
     FROM dataTable;
    

◆ marginal_logregr_step_final()

marginal_logregr_result marginal_logregr_step_final ( float8 []  state)

◆ marginal_logregr_step_merge_states()

float8 [] marginal_logregr_step_merge_states ( float8 []  state1,
float8 []  state2 
)

◆ marginal_logregr_step_transition()

float8 [] marginal_logregr_step_transition ( float8 []  state,
boolean  y,
float8 []  x,
float8 []  coef 
)

◆ marginal_mlogregr()

aggregate marginal_mlogregr_result marginal_mlogregr ( integer  dependentVariable,
integer  num_categories,
integer  ref_category,
float8 []  independentVariables,
float8 []  coef 
)
Parameters
dependentVariableColumn containing the dependent variable
independentVariablesColumn containing the array of independent variables
num_categoriesNumber of categories
ref_categoryReference category
coefColumn containing the array of the coefficients (as obtained by mlogregr)
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
  • coef FLOAT8[] - The coefficients for the regression
  • std_err FLOAT8[] - Array of standard-errors (using the delta method),
  • z_stats FLOAT8[] - Array of z-statistics
  • p_values FLOAT8[] - Array of p-values
Usage
  • Get all the diagnostic statistics:
     SELECT marginal_mlogregr(dependentVariable,
     independentVariables, coef)
     FROM dataTable;
    

◆ margins() [1/6]

void margins ( varchar  model_table,
varchar  out_table,
varchar  x_design,
varchar  source_table,
varchar  marginal_vars 
)

◆ margins() [2/6]

void margins ( varchar  model_table,
varchar  out_table,
varchar  x_design,
varchar  source_table 
)

◆ margins() [3/6]

void margins ( varchar  model_table,
varchar  out_table,
varchar  x_design 
)

◆ margins() [4/6]

void margins ( varchar  model_table,
varchar  out_table 
)

◆ margins() [5/6]

varchar margins ( varchar  message)

◆ margins() [6/6]

varchar margins ( )

◆ margins_logregr() [1/9]

varchar margins_logregr ( varchar  message)

◆ margins_logregr() [2/9]

varchar margins_logregr ( )

◆ margins_logregr() [3/9]

void margins_logregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_varname,
varchar  independent_varname,
varchar  grouping_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
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
optimizerOptimizer 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);
     

◆ margins_logregr() [4/9]

void margins_logregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable 
)

◆ margins_logregr() [5/9]

void margins_logregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
varchar  grouping_cols 
)

◆ margins_logregr() [6/9]

void margins_logregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
varchar  grouping_cols,
integer []  marginal_vars 
)

◆ margins_logregr() [7/9]

void margins_logregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
varchar  grouping_cols,
integer []  marginal_vars,
integer  max_iter 
)

◆ margins_logregr() [8/9]

void margins_logregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
varchar  grouping_cols,
integer []  marginal_vars,
integer  max_iter,
varchar  optimizer 
)

◆ margins_logregr() [9/9]

void margins_logregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
varchar  grouping_cols,
integer []  marginal_vars,
integer  max_iter,
varchar  optimizer,
float8  tolerance 
)

◆ margins_mlogregr() [1/12]

varchar margins_mlogregr ( varchar  message)

◆ margins_mlogregr() [2/12]

varchar margins_mlogregr ( )

◆ margins_mlogregr() [3/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_varname,
varchar  independent_varname,
integer  ref_category,
varchar  grouping_cols,
integer []  marginal_vars,
varchar  optimizer_params,
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
independent_varnameColumn containing the array of independent variables
ref_categoryReference category for the multinomial logistic regression
grouping_colsSet of columns to group by.
marginal_varsSubset of independent variables to calculate marginal effects for.
max_iterMaximum number of iterations
optimizerOptimizer 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_mlogregr('help'); OR sql> select margins_mlogregr(); OR sql> select margins_mlogregr('?'); For function usage information. Run sql> select margins_mlogregr('usage');

◆ margins_mlogregr() [4/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_varname,
varchar  independent_varname,
integer  ref_category,
varchar  grouping_cols,
integer []  marginal_vars,
varchar  optimizer_params 
)

◆ margins_mlogregr() [5/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_varname,
varchar  independent_varname,
integer  ref_category,
varchar  grouping_cols,
integer []  marginal_vars,
integer  max_iter,
varchar  optimizer,
float8  tolerance,
boolean  verbose_mode 
)

◆ margins_mlogregr() [6/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
integer  ref_category,
varchar  grouping_cols,
integer []  marginal_vars,
integer  max_iter 
)

◆ margins_mlogregr() [7/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
integer  ref_category,
varchar  grouping_cols,
integer []  marginal_vars,
integer  max_iter,
varchar  optimizer 
)

◆ margins_mlogregr() [8/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
integer  ref_category,
varchar  grouping_cols,
integer []  marginal_vars,
integer  max_iter,
varchar  optimizer,
float8  tolerance 
)

◆ margins_mlogregr() [9/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable 
)

◆ margins_mlogregr() [10/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
integer  ref_category 
)

◆ margins_mlogregr() [11/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
integer  ref_category,
varchar  grouping_cols 
)

◆ margins_mlogregr() [12/12]

void margins_mlogregr ( varchar  source_table,
varchar  out_table,
varchar  dependent_variable,
varchar  independent_variable,
integer  ref_category,
varchar  grouping_cols,
integer []  marginal_vars 
)

◆ mlogregr_marginal_step_final()

marginal_mlogregr_result mlogregr_marginal_step_final ( float8 []  state)

◆ mlogregr_marginal_step_merge_states()

float8 [] mlogregr_marginal_step_merge_states ( float8 []  state1,
float8 []  state2 
)

◆ mlogregr_marginal_step_transition()

float8 [] mlogregr_marginal_step_transition ( float8 []  state,
integer  y,
integer  num_categories,
integer  ref_category,
float8 []  x,
float8 []  coef 
)