statsmodelで回帰分析を行った時のこと
import statsmodels.api as sm
model = sm.OLS(Y, X)
results = model.fit()
print(results.summary())
こんな感じのコードを書いていた
が、回帰分析で重要なInterceptが出てこない
An intercept is not included by default and should be added by the user. See
statsmodels.tools.add_constant.
デフォルトでは切片は出ないようだ
切片まで計算したい場合はadd_constantを使えと書いてある
import statsmodels.api as sm
X = sm.add_constant(X) # この行を追加
model = sm.OLS(Y, X)
results = model.fit()
print(results.summary())
これでOK
結果のconstantがInterceptを表していると思われる


コメント