我尝试测试模型的异方差性。但是,它仍然返回错误,指出“ PanelEffectsResults”对象没有属性“ resid””。我不知道该如何解决。
我使用以下代码来构建模型:
#training and testing set
X_train, X_test, Y_train, Y_test = train_test_split(X,Y1, test_size =0.20, random_state= 8)
#creating an instance
regression_model= LinearRegression()
#fit
regression_model.fit(X_train, Y_train)
#predict
y_predict = regression_model.predict(X_test)
#Add the constant
X = sm.add_constant(X)
model = PanelOLS(Y,X, entity_effects=True)
est = model.fit()
est
#Homoscedasticity
diag.het_breuschpagan(est.resid, est.model.exog, retres=False)
我如何获得残渣?