commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1423) SingularMatrixException on Non-Square Matrix
Date Thu, 29 Jun 2017 18:10:00 GMT

    [ https://issues.apache.org/jira/browse/MATH-1423?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16068729#comment-16068729
] 

Phil Steitz commented on MATH-1423:
-----------------------------------

I don't think there is a bug here - more a question for the user list and maybe documentation
improvement.  In order for there to be a unique solution to the OLS parameter estimation problem,
the columns of the X matrix have to be linearly independent and there must be at least as
many rows as there are columns.   if your dimensions above are (row, column), there will be
no solution because 60 observations are not sufficient to estimate a model with 2160 independent
variables).  It is the XX' matrix that ends up singular in this case, which is what ultimately
triggers the SingularMatrixException.

If it is 2160 rows and 60 columns, that will work as long as the columns are linearly independent.
If one of your variables is (very close to) a linear combination of some subset of the others,
you will end up with a SingularMatrixException.  Check to make sure that all of the columns
are distinct and that none is just a multiple of another.

The javadoc should advertise SME and maybe explain this or provide a link to a reference on
OLS.



> SingularMatrixException on Non-Square Matrix
> --------------------------------------------
>
>                 Key: MATH-1423
>                 URL: https://issues.apache.org/jira/browse/MATH-1423
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.5
>         Environment: Oracle JDK 1.8.121
>            Reporter: Cody Warren
>            Priority: Minor
>              Labels: OLSMutlipleRegression, SingularMatrixException
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> I'm trying to implement an OLSMultipleLinearRegression class in the apache commons math
java library and I keep getting a "SingularMatrixException". This is confusing to me because
my data isn't even square (60 x 2160) which I thought was a requirement for a Singular Matrix.
> I've played with the data by pruning rows off and adding them back on, and found differing
numbers of rows that will work/fail with this dataset.
> Also, I've checked my matrix for columns or rows that are full of zeros as suggested
in this post:
> Using Apache Library for OLS Regression : Matrix is singular exception
> Is there something else with this library that I don't understand? Is there a way I can
make this more robust or predict a singular array beforehand?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message