fvalue and mse_model are -inf if only 1 regressor

Bug #440151 reported by joep
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
statsmodels
Confirmed
Undecided
Unassigned

Bug Description

the tests for dimension of exog, endog for model fail because -if is not equal -inf.
The source I think is if exog is only 1d or one column, then the df_model = 0, which, I think, causes a zero division for fvalue and mse_model

It is necessary to fix test and to check whether the -inf result is actually correct.
I did the initial correction in the test for fvalue, but commented it out again, because we need to check first if -inf is correct.

In the example, the df_model should be 1 instead of 0.
I think we need a `hasconstant` indicator so we can use
the correct df if there is only 1 (non-constant) regressor.

If we correct df_model by not subtracting 1, then we won't get -inf in the
case of this ticket, and we can ignore that -inf != -inf with numpy <= 1.3

Revision history for this message
joep (josef-pktd) wrote :
Download full text (7.5 KiB)

 The test failures are with numpy 1.3., this has been changed in trunk
 http://projects.scipy.org/numpy/changeset/7262/trunk/numpy/testing

 allow inf-inf and nan-nan comparisons to be True in testing

below are the results of the test run, (the same failures are in trunk)

>add_statsmodels-skipper_path.py
C:\Josef\eclipsegworkspace\statsmodels-skipper\scikits\statsmodels\__init__.pyc
Running unit tests for numpy
NumPy version 1.3.0
NumPy is installed in C:\Programs\Python25\lib\site-packages\numpy
Python version 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Int
el)]
nose version 0.11.1
....Warning message:
package 'MASS' was built under R version 2.7.2
.SS....K.S....SS......S........S............S............S........SS......S....S
.......S....SS......S........S.......KSS......S...KSS......S....SS......S.......
.S.............F.F.........
Attaching package: 'car'

        The following object(s) are masked from package:Hmisc :

         recode

Warning message:
package 'car' was built under R version 2.7.2
................................................................F.F.............
..F.F...............F.F..............................S..........SS.S.S..S.......
S.........................................S....S..S.........S....S..S........S..
.......S....S..S........S.......................................................
.......
======================================================================
FAIL: test_regression.TestDataDimensions.test_fvalue
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\programs\python25\lib\site-packages\nose-0.11.1-py2.5.egg\nose\case.p
y", line 183, in runTest
    self.test(*self.arg)
  File "C:\Josef\eclipsegworkspace\statsmodels-skipper\scikits\statsmodels\tests
\test_regression.py", line 95, in test_fvalue
    assert_almost_equal(self.res1.fvalue, self.res2.fvalue, DECIMAL)
  File "C:\Programs\Python25\Lib\site-packages\numpy\testing\utils.py", line 265
, in assert_almost_equal
    raise AssertionError(msg)
AssertionError:
Items are not equal:
 ACTUAL: -inf
 DESIRED: -inf

======================================================================
FAIL: test_regression.TestDataDimensions.test_mean_squared_error
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\programs\python25\lib\site-packages\nose-0.11.1-py2.5.egg\nose\case.p
y", line 183, in runTest
    self.test(*self.arg)
  File "C:\Josef\eclipsegworkspace\statsmodels-skipper\scikits\statsmodels\tests
\test_regression.py", line 88, in test_mean_squared_error
    assert_almost_equal(self.res1.mse_model, self.res2.mse_model, DECIMAL)
  File "C:\Programs\Python25\Lib\site-packages\numpy\testing\utils.py", line 265
, in assert_almost_equal
    raise AssertionError(msg)
AssertionError:
Items are not equal:
 ACTUAL: -inf
 DESIRED: -inf

======================================================================
FAIL: test_regression.TestNxNx.test_fvalue
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\programs\python25\lib\site-packages\nose-0.11.1...

Read more...

Revision history for this message
Skipper Seabold (jsseabold) wrote :

Can we change the status on this one?

Changed in statsmodels:
status: New → Confirmed
joep (josef-pktd)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.