You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Chetan Gadgil (JIRA)" <ji...@apache.org> on 2010/07/16 04:48:50 UTC
[jira] Created: (MATH-386) R2 / Adjusted R2 for multiple linear
regression
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
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.
[jira] Commented: (MATH-386) R2 / Adjusted R2 for multiple linear
regression
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903901#action_12903901 ]
Phil Steitz commented on MATH-386:
----------------------------------
Sorry my previous response to the comment above was incorrect. Using newSampleData(double[], nvars, nobs) will create a model that includes an intercept term and this will be the first element of the coefficient array. The newSampleData(double[], double[]) method used in the example above omits the intercept term (to get an intercept using that method, you need to add a column of "1"s in the X matrix). This will be fixed in math 2.2. A separate ticket has been opened for this issue as MATH-411. Thanks for reporting this.
> 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.
[jira] Updated: (MATH-386) R2 / Adjusted R2 for multiple linear
regression
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz updated MATH-386:
-----------------------------
Comment: was deleted
(was: Sorry, I should have been clearer in my last comment above. To estimate a model including an intercept, you need to include a column identically equal to 1 in the design matrix. This is what I meant by weakness in the documentation. The documentation issue has been raised as MATH-407. )
> 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.
[jira] Reopened: (MATH-386) R2 / Adjusted R2 for multiple linear
regression
Posted by "Chetan Gadgil (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Resolved: (MATH-386) R2 / Adjusted R2 for multiple linear
regression
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz resolved MATH-386.
------------------------------
Resolution: Fixed
Sorry, I should have been clearer in my last comment above. To estimate a model including an intercept, you need to include a column identically equal to 1 in the design matrix. This is what I meant by weakness in the documentation. The documentation issue has been raised as MATH-407.
> 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.
[jira] Commented: (MATH-386) R2 / Adjusted R2 for multiple linear
regression
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901806#action_12901806 ]
Phil Steitz commented on MATH-386:
----------------------------------
MATH-409 has been raised specifically for estimating models with intercepts.
> 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.
[jira] Updated: (MATH-386) R2 / Adjusted R2 for multiple linear
regression
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz updated MATH-386:
-----------------------------
Fix Version/s: 2.2
> 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.
[jira] Issue Comment Edited: (MATH-386) R2 / Adjusted R2 for
multiple linear regression
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901806#action_12901806 ]
Phil Steitz edited comment on MATH-386 at 8/28/10 4:41 PM:
-----------------------------------------------------------
MATH-409 has been raised specifically for estimating models without intercepts.
was (Author: psteitz):
MATH-409 has been raised specifically for estimating models with intercepts.
> 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.
[jira] Resolved: (MATH-386) R2 / Adjusted R2 for multiple linear
regression
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz resolved MATH-386.
------------------------------
Resolution: Fixed
R-squared, adjusted R-squared added in r987983.
The intercept is the first element of the beta coefficients array. Documentation needs to be improved. I will open a separate ticket for this.
> 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.