我正在執行線性迴歸以擬合y = x + c1 + c2 + c3 + c4 + ... + cn(c1..cn是協變量)。Statsmodels OLS線性迴歸 - 爲什麼我有多個迴歸參數?
一個奇怪的現象正在發生,一旦我輸出彙總結果,我不知道爲什麼是這樣的話:
OLS Regression Results
==============================================================================
Dep. Variable: pgrs R-squared: 0.038
Model: OLS Adj. R-squared: -0.012
Method: Least Squares F-statistic: 0.7565
Date: Wed, 16 Aug 2017 Prob (F-statistic): 0.716
Time: 11:12:02 Log-Likelihood: -18.623
No. Observations: 284 AIC: 67.25
Df Residuals: 269 BIC: 122.0
Df Model: 14
Covariance Type: nonrobust
================================================================================
coef std err t P>|t| [0.025 0.975]
--------------------------------------------------------------------------------
Intercept 0.5331 0.272 1.957 0.051 -0.003 1.069
x[T.0] -0.2568 0.327 -0.786 0.433 -0.900 0.387
x[T.1] -0.0574 0.280 -0.205 0.837 -0.608 0.493
x[T.2] -0.1556 0.277 -0.562 0.575 -0.701 0.390
x[T.3] 0.0182 0.273 0.067 0.947 -0.519 0.555
x[T.4] -0.0114 0.271 -0.042 0.967 -0.545 0.523
x[T.5] 0.0067 0.272 0.025 0.980 -0.529 0.542
x[T.6] -0.0321 0.269 -0.119 0.905 -0.562 0.498
x[T.7] 0.0262 0.271 0.097 0.923 -0.507 0.559
x[T.8] -0.0542 0.270 -0.200 0.841 -0.586 0.478
x[T.9] -0.0529 0.272 -0.195 0.846 -0.588 0.482
c1 0.0625 0.039 1.615 0.107 -0.014 0.139
c2 -0.0016 0.007 -0.219 0.827 -0.016 0.013
c3 0.2052 0.356 0.576 0.565 -0.496 0.906
c4 0.0986 0.397 0.249 0.804 -0.682 0.880
==============================================================================
Omnibus: 2.789 Durbin-Watson: 1.865
Prob(Omnibus): 0.248 Jarque-Bera (JB): 3.018
Skew: -0.000 Prob(JB): 0.221
Kurtosis: 3.505 Cond. No. 525.
==============================================================================
Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
爲什麼我有多個X參數?只有當x是我數據集中的特定功能時,纔會出現這種情況。有什麼辦法可以解決這個問題嗎?或者這是一種有意的行爲,這是什麼意思?具體來說,[T.0],... [T.9]是什麼意思?
我使用statsmodels來適應上述功能。
# Returns a string y ~ trait + c1 + ... + cn
f = math_expr([trait] + covariates, y)
lm = ols(formula=f, data=df).fit()
您能否告訴我們您使用的statsmodels代碼是否合適? –
當然,我現在包括他們。 – TimelordViktorious
我不熟悉'math_expr'。如果它有什麼用處,當我試圖弄清楚使用了什麼模型時,我已經使用了https://patsy.readthedocs.io/en/v0.1.0/formulas.html來查看設計矩陣。 –