You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dimitri Pourbaix (JIRA)" <ji...@apache.org> on 2010/06/17 11:07:23 UTC

[jira] Created: (MATH-377) weight versus sigma in AbstractLeastSquares

weight versus sigma in AbstractLeastSquares
-------------------------------------------

                 Key: MATH-377
                 URL: https://issues.apache.org/jira/browse/MATH-377
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 2.1
            Reporter: Dimitri Pourbaix
             Fix For: 2.2


In AbstractLeastSquares, residualsWeights contains the WEIGHTS assigned to each observation.  In the method getRMS(), these weights are multiplicative as they should. unlike in getChiSquare() where it appears at the denominator!   If the weight is really the weight of the observation, it should multiply the square of the residual even in the computation of the chi2.

 Once corrected, getRMS() can even reduce

 public double getRMS() {return Math.sqrt(getChiSquare()/rows);}

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


[jira] Commented: (MATH-377) weight versus sigma in AbstractLeastSquares

Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12880827#action_12880827 ] 

Phil Steitz commented on MATH-377:
----------------------------------

I could be missing something, but I see no reason that the weighted sum of squared residuals computed here (after the proposed change) should in general follow a chi-square distribution or be related to a chi-square test statistic of any kind.   Why is it called chi-square?  Sorry if I am missing something simple here.

> weight versus sigma in AbstractLeastSquares
> -------------------------------------------
>
>                 Key: MATH-377
>                 URL: https://issues.apache.org/jira/browse/MATH-377
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Dimitri Pourbaix
>             Fix For: 2.2
>
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> In AbstractLeastSquares, residualsWeights contains the WEIGHTS assigned to each observation.  In the method getRMS(), these weights are multiplicative as they should. unlike in getChiSquare() where it appears at the denominator!   If the weight is really the weight of the observation, it should multiply the square of the residual even in the computation of the chi2.
>  Once corrected, getRMS() can even reduce
>  public double getRMS() {return Math.sqrt(getChiSquare()/rows);}

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


[jira] Commented: (MATH-377) weight versus sigma in AbstractLeastSquares

Posted by "Dimitri Pourbaix (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12880637#action_12880637 ] 

Dimitri Pourbaix commented on MATH-377:
---------------------------------------

OK, let us define ChiSquare as the sum of the weighted square of the residual in order to be consistent with the rest of the definitions in that class.  That would also be consistent with what users expect from a parameter labeled 'weight' rather than 'sigma'.  If we reach consensus on that definition, I can take care of that issue.

> weight versus sigma in AbstractLeastSquares
> -------------------------------------------
>
>                 Key: MATH-377
>                 URL: https://issues.apache.org/jira/browse/MATH-377
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Dimitri Pourbaix
>             Fix For: 2.2
>
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> In AbstractLeastSquares, residualsWeights contains the WEIGHTS assigned to each observation.  In the method getRMS(), these weights are multiplicative as they should. unlike in getChiSquare() where it appears at the denominator!   If the weight is really the weight of the observation, it should multiply the square of the residual even in the computation of the chi2.
>  Once corrected, getRMS() can even reduce
>  public double getRMS() {return Math.sqrt(getChiSquare()/rows);}

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


[jira] Commented: (MATH-377) weight versus sigma in AbstractLeastSquares

Posted by "Dimitri Pourbaix (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12880848#action_12880848 ] 

Dimitri Pourbaix commented on MATH-377:
---------------------------------------

Indeed, the confusion comes from the fact that, in some textbooks, each residual is divided by 'sigma_i' which leads to a weight of 1/(sigma_i^2).  In CM, we adopted the terminology 'weight' without reference to sigma.  I will change the javadoc accordingly.

> weight versus sigma in AbstractLeastSquares
> -------------------------------------------
>
>                 Key: MATH-377
>                 URL: https://issues.apache.org/jira/browse/MATH-377
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Dimitri Pourbaix
>             Fix For: 2.2
>
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> In AbstractLeastSquares, residualsWeights contains the WEIGHTS assigned to each observation.  In the method getRMS(), these weights are multiplicative as they should. unlike in getChiSquare() where it appears at the denominator!   If the weight is really the weight of the observation, it should multiply the square of the residual even in the computation of the chi2.
>  Once corrected, getRMS() can even reduce
>  public double getRMS() {return Math.sqrt(getChiSquare()/rows);}

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


[jira] Resolved: (MATH-377) weight versus sigma in AbstractLeastSquares

Posted by "Dimitri Pourbaix (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dimitri Pourbaix resolved MATH-377.
-----------------------------------

    Resolution: Fixed

> weight versus sigma in AbstractLeastSquares
> -------------------------------------------
>
>                 Key: MATH-377
>                 URL: https://issues.apache.org/jira/browse/MATH-377
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Dimitri Pourbaix
>            Assignee: Dimitri Pourbaix
>             Fix For: 2.2
>
>         Attachments: Math377fix.diff
>
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> In AbstractLeastSquares, residualsWeights contains the WEIGHTS assigned to each observation.  In the method getRMS(), these weights are multiplicative as they should. unlike in getChiSquare() where it appears at the denominator!   If the weight is really the weight of the observation, it should multiply the square of the residual even in the computation of the chi2.
>  Once corrected, getRMS() can even reduce
>  public double getRMS() {return Math.sqrt(getChiSquare()/rows);}

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


[jira] Commented: (MATH-377) weight versus sigma in AbstractLeastSquares

Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12880832#action_12880832 ] 

Phil Steitz commented on MATH-377:
----------------------------------

I guess if you assume normalliy distributed errors, it makes sense, so drop the last comment and I am +1 for the change (with definition added to the javadoc).

> weight versus sigma in AbstractLeastSquares
> -------------------------------------------
>
>                 Key: MATH-377
>                 URL: https://issues.apache.org/jira/browse/MATH-377
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Dimitri Pourbaix
>             Fix For: 2.2
>
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> In AbstractLeastSquares, residualsWeights contains the WEIGHTS assigned to each observation.  In the method getRMS(), these weights are multiplicative as they should. unlike in getChiSquare() where it appears at the denominator!   If the weight is really the weight of the observation, it should multiply the square of the residual even in the computation of the chi2.
>  Once corrected, getRMS() can even reduce
>  public double getRMS() {return Math.sqrt(getChiSquare()/rows);}

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


[jira] Commented: (MATH-377) weight versus sigma in AbstractLeastSquares

Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12880527#action_12880527 ] 

Phil Steitz commented on MATH-377:
----------------------------------

It is not clear to me exactly what is being computed in getChiSquare.  Step 0 is to get an actual definition in the javadoc for what it is trying to compute.  I agree it seems odd to be dividing by residual weights; but I could be missing the intent.

> weight versus sigma in AbstractLeastSquares
> -------------------------------------------
>
>                 Key: MATH-377
>                 URL: https://issues.apache.org/jira/browse/MATH-377
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Dimitri Pourbaix
>             Fix For: 2.2
>
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> In AbstractLeastSquares, residualsWeights contains the WEIGHTS assigned to each observation.  In the method getRMS(), these weights are multiplicative as they should. unlike in getChiSquare() where it appears at the denominator!   If the weight is really the weight of the observation, it should multiply the square of the residual even in the computation of the chi2.
>  Once corrected, getRMS() can even reduce
>  public double getRMS() {return Math.sqrt(getChiSquare()/rows);}

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


[jira] Updated: (MATH-377) weight versus sigma in AbstractLeastSquares

Posted by "Dimitri Pourbaix (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dimitri Pourbaix updated MATH-377:
----------------------------------

    Attachment: Math377fix.diff

Patch to correct issue MATH-377.  The change in getChiSquare let to a tiny update in one of Levenberg-Marquardt unit tests.

> weight versus sigma in AbstractLeastSquares
> -------------------------------------------
>
>                 Key: MATH-377
>                 URL: https://issues.apache.org/jira/browse/MATH-377
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Dimitri Pourbaix
>            Assignee: Dimitri Pourbaix
>             Fix For: 2.2
>
>         Attachments: Math377fix.diff
>
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> In AbstractLeastSquares, residualsWeights contains the WEIGHTS assigned to each observation.  In the method getRMS(), these weights are multiplicative as they should. unlike in getChiSquare() where it appears at the denominator!   If the weight is really the weight of the observation, it should multiply the square of the residual even in the computation of the chi2.
>  Once corrected, getRMS() can even reduce
>  public double getRMS() {return Math.sqrt(getChiSquare()/rows);}

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