File tree 4 files changed +22
-4
lines changed
4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,16 @@ pandas 0.6.2
91
91
- Fix handling of missing columns (was combine_first-specific) in
92
92
DataFrame.combine for general case (GH #529)
93
93
- Fix type inference logic with boolean lists and arrays in DataFrame indexing
94
+ - Use centered sum of squares in R-square computation if entity_effects=True
95
+ in panel regression
94
96
95
97
Thanks
96
98
------
97
99
- Craig Austin
98
100
- Andreas Hilboll
99
101
- Adam Klein
100
102
- Matt Harrison
103
+ - Mario Gamboa-Cavazos
101
104
- Arthur Gerigk
102
105
- Gregg Lind
103
106
- Solomon Negusse
Original file line number Diff line number Diff line change @@ -257,12 +257,16 @@ def p_value(self):
257
257
@cache_readonly
258
258
def _r2_raw (self ):
259
259
"""Returns the raw r-squared values."""
260
- has_intercept = np .abs (self ._resid_raw .sum ()) < _FP_ERR
261
- if self ._intercept :
260
+ if self ._use_centered_tss :
262
261
return 1 - self .sm_ols .ssr / self .sm_ols .centered_tss
263
262
else :
264
263
return 1 - self .sm_ols .ssr / self .sm_ols .uncentered_tss
265
264
265
+ @property
266
+ def _use_centered_tss (self ):
267
+ # has_intercept = np.abs(self._resid_raw.sum()) < _FP_ERR
268
+ return self ._intercept
269
+
266
270
@cache_readonly
267
271
def r2 (self ):
268
272
"""Returns the r-squared values."""
@@ -934,7 +938,7 @@ def _rmse_raw(self):
934
938
def _r2_raw (self ):
935
939
rs = self ._resid_stats
936
940
937
- if self ._intercept :
941
+ if self ._use_centered_tss :
938
942
return 1 - rs ['sse' ] / rs ['centered_tss' ]
939
943
else :
940
944
return 1 - rs ['sse' ] / rs ['uncentered_tss' ]
Original file line number Diff line number Diff line change @@ -328,10 +328,19 @@ def _r2_raw(self):
328
328
resid = Y - np .dot (X , self ._beta_raw )
329
329
330
330
SSE = (resid ** 2 ).sum ()
331
- SST = ((Y - np .mean (Y )) ** 2 ).sum ()
331
+
332
+ if self ._use_centered_tss :
333
+ SST = ((Y - np .mean (Y )) ** 2 ).sum ()
334
+ else :
335
+ SST = (Y ** 2 ).sum ()
332
336
333
337
return 1 - SSE / SST
334
338
339
+ @property
340
+ def _use_centered_tss (self ):
341
+ # has_intercept = np.abs(self._resid_raw.sum()) < _FP_ERR
342
+ return self ._intercept or self ._entity_effects or self ._time_effects
343
+
335
344
@cache_readonly
336
345
def _r2_adj_raw (self ):
337
346
"""Returns the raw r-squared adjusted values."""
Original file line number Diff line number Diff line change @@ -562,6 +562,8 @@ def testRolling(self):
562
562
def testRollingWithFixedEffects (self ):
563
563
self .checkMovingOLS (self .panel_x , self .panel_y ,
564
564
entity_effects = True )
565
+ self .checkMovingOLS (self .panel_x , self .panel_y , intercept = False ,
566
+ entity_effects = True )
565
567
566
568
def testRollingWithTimeEffects (self ):
567
569
self .checkMovingOLS (self .panel_x , self .panel_y ,
You can’t perform that action at this time.
0 commit comments