SSJ
V. 2.6.2.

umontreal.iro.lecuyer.functionfit
Class LeastSquares

java.lang.Object
  extended by umontreal.iro.lecuyer.functionfit.LeastSquares

public class LeastSquares
extends Object

This class implements different linear regression models, using the least squares method to estimate the regression coefficients. Given input data xij and response yi, one want to find the coefficients βj that minimize the residuals of the form (using matrix notation)

r = minβ| Y - |2,

where the L2 norm is used. Particular cases are

r = minβi(yi - β0 - ∑j=1kβjxij)2.

for k regressor variables xj. The well-known case of the single variable x is

r = minα, βi(yi - α - βxi)2.

Sometimes, one wants to use a basis of general functions ψj(t) with a minimization of the form

r = minβi(yi - ∑j=1kβjψj(ti))2.

For example, we could have ψj(t) = e-λjt or some other functions. In that case, one has to choose the points ti at which to compute the basis functions, and use a method below with xij = ψj(ti).


Constructor Summary
LeastSquares()
           
 
Method Summary
static double[] calcCoefficients(double[][] X, double[] Y)
          Computes the regression coefficients using the least squares method.
static double[] calcCoefficients(double[] X, double[] Y)
          Computes the regression coefficients using the least squares method.
static double[] calcCoefficients(double[] X, double[] Y, int deg)
          Computes the regression coefficients using the least squares method.
static double[] calcCoefficients0(double[][] X, double[] Y)
          Computes the regression coefficients using the least squares method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LeastSquares

public LeastSquares()
Method Detail

calcCoefficients

public static double[] calcCoefficients(double[] X,
                                        double[] Y)
Computes the regression coefficients using the least squares method. This is a simple linear regression with 2 regression coefficients, α and β. The model is

y = α + βx.

Given the n data points (Xi, Yi), i = 0, 1,…,(n - 1), the method computes and returns the array [α, β].

Parameters:
X - the regressor variables
Y - the response
Returns:
the regression coefficients

calcCoefficients

public static double[] calcCoefficients(double[] X,
                                        double[] Y,
                                        int deg)
Computes the regression coefficients using the least squares method. This is a linear regression with a polynomial of degree deg = k and k + 1 regression coefficients βj. The model is

y = β0 + ∑j=1kβjxj.

Given the n data points (Xi, Yi), i = 0, 1,…,(n - 1), the method computes and returns the array [β0, β1,…, βk]. Restriction: n > k.

Parameters:
X - the regressor variables
Y - the response
Returns:
the regression coefficients

calcCoefficients0

public static double[] calcCoefficients0(double[][] X,
                                         double[] Y)
Computes the regression coefficients using the least squares method. This is a model for multiple linear regression. There are k + 1 regression coefficients βj, and k regressors variables xj. The model is

y = β0 + ∑j=1kβjxj.

There are n data points Yi, Xij, i = 0, 1,…,(n - 1), and each Xi is a k-dimensional point. Given the response Y[i] and the regressor variables X[i][j], i = 0, 1,…,(n - 1), j = 0, 1,…,(k - 1), the method computes and returns the array [β0, β1,…, βk]. Restriction: n > k + 1.

Parameters:
X - the regressor variables
Y - the response
Returns:
the regression coefficients

calcCoefficients

public static double[] calcCoefficients(double[][] X,
                                        double[] Y)
Computes the regression coefficients using the least squares method. This is a model for multiple linear regression. There are k regression coefficients βj, j = 0, 1,…,(k - 1) and k regressors variables xj. The model is

y = ∑j=0k-1βjxj.

There are n data points Yi, Xij, i = 0, 1,…,(n - 1), and each Xi is a k-dimensional point. Given the response Y[i] and the regressor variables X[i][j], i = 0, 1,…,(n - 1), j = 0, 1,…,(k - 1), the method computes and returns the array [β0, β1,…, βk-1]. Restriction: n > k.

Parameters:
X - the regressor variables
Y - the response
Returns:
the regression coefficients

SSJ
V. 2.6.2.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.