org.fhcrc.cpl.toolbox.statistics
Class RegressionUtilities

java.lang.Object
  extended by org.fhcrc.cpl.toolbox.statistics.RegressionUtilities

public class RegressionUtilities
extends java.lang.Object

Utilities for regression analysis


Nested Class Summary
static class RegressionUtilities.AnovaResult
           
 
Field Summary
protected static org.apache.log4j.Logger _log
           
static int DEFAULT_MAX_MILLIS_FOR_ROBUST_REGRESSION
           
static java.lang.String REGRESSION_INTERCEPT_KEY
           
static java.lang.String REGRESSION_SIGMA_KEY
           
static java.lang.String REGRESSION_SLOPE_KEY
           
 
Constructor Summary
RegressionUtilities()
           
 
Method Summary
static double mapValueUsingCoefficients(double[] coefficients, double valueToMap)
           
static double[] modalRegression(double[] xset, double[] yset)
          Default: two coefficients
static double[] modalRegression(double[] xset, double[] yset, int degree)
          Call Yan's Modal Regression R code.
static RegressionUtilities.AnovaResult oneWayAnova(double[] categories, double[] outcomes)
           
static RegressionUtilities.AnovaResult oneWayAnova(java.util.List<? extends java.lang.Number> categories, java.util.List<? extends java.lang.Number> outcomes)
          Cover method.
static double predictXFromY(double slope, double intercept, double y)
          Given a slope and intercept of a line relating x and y, predict y from x
static double predictYFromX(double slope, double intercept, double x)
          Given a slope and intercept of a line relating x and y, predict x from y
static double[] robustRegression(double[] xset, double[] yset)
           
static double[] robustRegression(double[] xset, double[] yset, int millis)
           
static java.lang.Integer[] selectIndexesWithLowAbsoluteSomething(double[] somethings, double maxSomething)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

protected static org.apache.log4j.Logger _log

REGRESSION_SLOPE_KEY

public static final java.lang.String REGRESSION_SLOPE_KEY
See Also:
Constant Field Values

REGRESSION_INTERCEPT_KEY

public static final java.lang.String REGRESSION_INTERCEPT_KEY
See Also:
Constant Field Values

REGRESSION_SIGMA_KEY

public static final java.lang.String REGRESSION_SIGMA_KEY
See Also:
Constant Field Values

DEFAULT_MAX_MILLIS_FOR_ROBUST_REGRESSION

public static final int DEFAULT_MAX_MILLIS_FOR_ROBUST_REGRESSION
See Also:
Constant Field Values
Constructor Detail

RegressionUtilities

public RegressionUtilities()
Method Detail

oneWayAnova

public static RegressionUtilities.AnovaResult oneWayAnova(java.util.List<? extends java.lang.Number> categories,
                                                          java.util.List<? extends java.lang.Number> outcomes)
Cover method. Inefficiently converts to doubles

Parameters:
categories - these should be distinct values -- practically speaking, ints would have been better. double[] for simplicity
outcomes -
Returns:

oneWayAnova

public static RegressionUtilities.AnovaResult oneWayAnova(double[] categories,
                                                          double[] outcomes)
Parameters:
categories - these should be distinct values -- practically speaking, ints would have been better. double[] for simplicity
outcomes -
Returns:

robustRegression

public static double[] robustRegression(double[] xset,
                                        double[] yset)

robustRegression

public static double[] robustRegression(double[] xset,
                                        double[] yset,
                                        int millis)

predictYFromX

public static double predictYFromX(double slope,
                                   double intercept,
                                   double x)
Given a slope and intercept of a line relating x and y, predict x from y

Parameters:
slope -
intercept -
x -
Returns:

predictXFromY

public static double predictXFromY(double slope,
                                   double intercept,
                                   double y)
Given a slope and intercept of a line relating x and y, predict y from x

Parameters:
slope -
intercept -
Returns:

modalRegression

public static double[] modalRegression(double[] xset,
                                       double[] yset)
                                throws java.io.IOException
Default: two coefficients

Parameters:
xset -
yset -
Returns:
Throws:
java.io.IOException

modalRegression

public static double[] modalRegression(double[] xset,
                                       double[] yset,
                                       int degree)
                                throws java.io.IOException
Call Yan's Modal Regression R code. This code is dependent on the "quantreg" library being installed. If that package isn't installed, it will throw IOException. Steps to install: source("http://bioconductor.org/biocLite.R") biocLite(c("quantreg")) todo: require some minum cardinality (5?), and throw an IllegalArg if not enough datapoints. Because R will fail

Parameters:
xset -
yset -
degree - The degree of the polynomial. Minimum 1
Returns:
Throws:
java.io.IOException

selectIndexesWithLowAbsoluteSomething

public static java.lang.Integer[] selectIndexesWithLowAbsoluteSomething(double[] somethings,
                                                                        double maxSomething)

mapValueUsingCoefficients

public static double mapValueUsingCoefficients(double[] coefficients,
                                               double valueToMap)


Fred Hutchinson Cancer Research Center