admin管理员组

文章数量:1550529

说我在statsmodels中适合模型

mod = smf.ols('dependent ~ first_category + second_category + other', data=df).fit()

当我做mod.summary()时,我可能会看到以下内容:

Warnings:

[1] The condition number is large, 1.59e+05. This might indicate that there are

strong multicollinearity or other numerical problems.

有时警告是不同的(例如,基于设计矩阵的特征值).如何在变量中捕获高多重共线性条件?此警告是否存储在模型对象的某处?

另外,我在哪里可以找到summary()中字段的描述?

解决方法:

您可以通过检查相关矩阵的特征值来检测高多重共线性.非常低的特征值表明数据是共线的,并且相应的特征向量显示哪些变量是共线的.

如果数据中没有共线性,则可以预期没有任何特征值接近零:

>>> xs = np.random.randn(100, 5) # independent variables

>>> corr = np.corrcoef(xs, rowvar=0) # correlation matrix

>>> w, v = np.linalg.eig(corr) # eigen values & eigen vectors

>>> w

array([ 1.256 , 1.1937, 0.7273, 0.9516, 0.8714])

但是,如果说x [

本文标签: 线性Pythonstatsmodels