commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chetan Gadgil (JIRA)" <j...@apache.org>
Subject [jira] Reopened: (MATH-386) R2 / Adjusted R2 for multiple linear regression
Date Tue, 24 Aug 2010 00:00:17 GMT

     [ https://issues.apache.org/jira/browse/MATH-386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Chetan Gadgil reopened MATH-386:
--------------------------------


I am not sure whether the intercept is really the first element in the regression coefficients
array. Here's a test case:



import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.math.stat.regression.OLSMultipleLinearRegression;



/**
 * @author cgadgil
 * 
 */
public class RegressionUtil {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		double[][] xdata = new double[][] { new double[] { 1, 2, 3, 4, 5 },
				new double[] { 3, 2, 4, 2, 11 }, new double[] { 4, 2, 4, 2, 1 } };
		double[] ydata = new double[] { 11, 24, 31, 42, 48 };
		double[][] xdata1 = new double[][] { new double[] { 1, 2, 3 },
				new double[] { 3, 2, 4 }, new double[] { 4, 2, 4 },
				new double[] { 6, 12, 54 }, new double[] { 6, 12, 54 } };
		double[] ydata1 = new double[] { 11, 24, 31, 42, 48 };
		double[] xd1 = new double[] { 1, 2, 3, 4, 5 };
		double[] yd1 = new double[] { 21, 32, 45, 51, 59 };

		OLSMultipleLinearRegression tomlr = new OLSMultipleLinearRegression();
		tomlr.newSampleData(ydata1, xdata1);
		System.out.println(Arrays.toString(tomlr.estimateRegressionParameters()));
		System.out.println(Arrays.toString(tomlr.estimateResiduals()));
		System.out.println(tomlr.calculateRSquared());
		System.out.println(tomlr.calculateAdjustedRSquared());

	}

}


Output:
[6.847874468264924, 2.932064681522383, -0.5791193621996226]
[0.025354255289176564, -0.09127531904104913, 0.06085021269403157, -2.9995774290785135, 3.0004225709214865]
0.9790257602146663
0.9580515204293326


> R2 / Adjusted R2 for multiple linear regression
> -----------------------------------------------
>
>                 Key: MATH-386
>                 URL: https://issues.apache.org/jira/browse/MATH-386
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 2.1
>            Reporter: Chetan Gadgil
>             Fix For: 2.2
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> I am used to using Minitab / other stat package which also returns other multiplelinear
regression data:
> R^2
> adjusted R^2
> Intercept (commons-math does not appear to normalize).
> Would be nice to have direct APIs for this data from MultipleLinearRegression

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message