AttributeError:“ModelData”对象没有属性“design_info”

问题描述 投票:0回答:0

我无法在线性回归模型上执行annova。我附上了下面的简化代码。请让我知道如何解决它。

import statsmodels.api as sm
import numpy as np

# define the data
x1 = np.random.rand(100)
x2 = np.random.rand(100)
y = 2*x1 + 3*x2 + np.random.normal(size=100)

# build the model with all independent variables
X = sm.add_constant(np.column_stack((x1, x2)))
model = sm.OLS(y, X).fit()

# perform the F-test
f_value, p_value, _ = sm.stats.anova_lm(model, typ=1)

错误截图:

python-3.x anova statmodels
© www.soinside.com 2019 - 2024. All rights reserved.