15
15
from pandas .core .series import Series
16
16
from pandas .core .sparse import SparsePanel
17
17
from pandas .stats .ols import OLS , MovingOLS
18
- import pandas .stats .common as common
18
+ import pandas .stats .common as com
19
19
import pandas .stats .math as math
20
20
from pandas .util .decorators import cache_readonly
21
21
@@ -24,6 +24,8 @@ class PanelOLS(OLS):
24
24
25
25
See ols function docs
26
26
"""
27
+ _panel_model = True
28
+
27
29
def __init__ (self , y , x , weights = None , intercept = True , nw_lags = None ,
28
30
entity_effects = False , time_effects = False , x_effects = None ,
29
31
cluster = None , dropped_dummies = None , verbose = False ,
@@ -39,14 +41,14 @@ def __init__(self, y, x, weights=None, intercept=True, nw_lags=None,
39
41
self ._time_effects = time_effects
40
42
self ._x_effects = x_effects
41
43
self ._dropped_dummies = dropped_dummies or {}
42
- self ._cluster = common ._get_cluster_type (cluster )
44
+ self ._cluster = com ._get_cluster_type (cluster )
43
45
self ._verbose = verbose
44
46
45
47
(self ._x , self ._x_trans ,
46
48
self ._x_filtered , self ._y ,
47
49
self ._y_trans ) = self ._prepare_data ()
48
50
49
- self ._index = self ._x .major_axis
51
+ self ._index = self ._x .index . levels [ 0 ]
50
52
51
53
self ._T = len (self ._index )
52
54
@@ -470,6 +472,8 @@ class MovingPanelOLS(MovingOLS, PanelOLS):
470
472
471
473
See ols function docs
472
474
"""
475
+ _panel_model = True
476
+
473
477
def __init__ (self , y , x , weights = None ,
474
478
window_type = 'expanding' , window = None ,
475
479
min_periods = None ,
@@ -499,7 +503,7 @@ def __init__(self, y, x, weights=None,
499
503
self ._set_window (window_type , window , min_periods )
500
504
501
505
if min_obs is None :
502
- min_obs = len (self ._x .items ) + 1
506
+ min_obs = len (self ._x .columns ) + 1
503
507
504
508
self ._min_obs = min_obs
505
509
@@ -553,7 +557,7 @@ def _var_beta_raw(self):
553
557
x = self ._x
554
558
y = self ._y
555
559
556
- dates = x .major_axis
560
+ dates = x .index . levels [ 0 ]
557
561
558
562
cluster_axis = None
559
563
if self ._cluster == 'time' :
@@ -639,7 +643,7 @@ def _enough_obs(self):
639
643
# XXX: what's the best way to determine where to start?
640
644
# TODO: write unit tests for this
641
645
642
- rank_threshold = len (self ._x .items ) + 1
646
+ rank_threshold = len (self ._x .columns ) + 1
643
647
if self ._min_obs < rank_threshold : # pragma: no cover
644
648
warnings .warn ('min_obs is smaller than rank of X matrix' )
645
649
@@ -763,7 +767,7 @@ def _var_beta_panel(y, x, beta, xx, rmse, cluster_axis,
763
767
nw_lags = 0
764
768
765
769
xox = 0
766
- for i in range (len (x .major_axis )):
770
+ for i in range (len (x .index . levels [ 0 ] )):
767
771
xox += math .newey_west (m [i : i + 1 ], nw_lags ,
768
772
nobs , df , nw_overlap )
769
773
0 commit comments