You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Gilles <gi...@harfang.homelinux.org> on 2018/01/01 01:32:04 UTC

Re: [math] OLSMultipleLinearRegression

On Sun, 31 Dec 2017 17:35:26 -0600, Andy Arledge wrote:
> i had the row index 1st initially and got an error message that said:
>
> org.apache.commons.math3.exception.DimensionMismatchException: 17 != 
> 293
>
> so i tried reversing the row/columns, no luck got the message below.

Did you have a look at the unit tests[1]?
Hopefully, it should show how to set up your code.

Best,
Gilles

[1] 
https://git1-us-west.apache.org/repos/asf?p=commons-math.git;a=blob;f=src/test/java/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegressionTest.java;hb=HEAD

>
>
>
> On 12/31/2017 4:56 PM, Gilles wrote:
>> On Sun, 31 Dec 2017 15:01:23 -0600, Andy Arledge wrote:
>>> Hi,
>>>
>>> I get an
>>>
>>> "org.apache.commons.math3.exception.MathIllegalArgumentException: 
>>> not
>>> enough data (17 rows) for this many predictors (293 predictors)"
>>>
>>> with the following code : https://pastebin.com/aZ4DXQB3
>>>
>>> My class extends OLSMultipleLinearRegression. I have 293 rows of 
>>> data
>>> with 17 columns.
>>>
>>> Is there something I'm missing here? I'm basing my work on the 
>>> example @
>>>
>>>
>>> 
>>> http://commons.apache.org/proper/commons-math/userguide/stat.html#a1.5_Multiple_linear_regression
>>>
>>>
>>> Thanks for any guidance.
>>
>> In Java, the "row" index is the first dimension.
>> Try
>> ---CUT---
>>  double[][] data = new double[myList.size()][17];
>>  // etc.
>> ---CUT---
>>
>> HTH,
>> Gilles


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org