Computing generalized least squares regression

In this recipe, we will see another variant of least squares regression named generalized least squares regression. GLSMultipleLinearRegression implements Generalized Least Squares to fit the linear model Y=X*b+u.

How to do it...

  1. Create a method that takes a two-dimensional double array, a one-dimensional double array, and a two-dimensional double array for the regression's omega parameter:
            public void calculateGlsRegression(double[][] x, double[] y, 
              double[][] omega){ 
    
  2. Create a GLS regression object, the data points, and the omega parameter:
            GLSMultipleLinearRegression regression = new  
              GLSMultipleLinearRegression(); 
            regression.newSampleData(y, x, omega); 
    
  3. Using the methods of the GLSMultipleLinearRegression ...

Get Java Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.