問題タブ [log-likelihood]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Likelihood Ratio Test and pseudo Rsquared differ significantly (Logistic Regression)
I apply a logistic regression
and I would like to test for statistical sigificance of my overall model.
Now, the pseudo-Rsquared (McFaddon) Rsquared = 1 - L(c)/L(null)
returns the variance explained by the model - where L(c)
denotes the maximized likelihood value from the fitted model and L(null)
denotes the corresponding value for the null model (no covariates, only intercept).
The likelihood test statistic is LR = 2 * (L(c) - L(null))
which follows a Chi-squared
distribution and can be tested for significance according to the models degree of freedoms.
Anyways, I use the Chi-squared
to calculate a p-value
which is highly significant, but the pseudo Rsquared
is around 0.021
???
Why does Rsquared and the overall p-value differ so much?
Using an accuracy calulation for some test-data metrics.accuracy_score(y_test, y_pred)
, I see that the accuracy for the test data is only around 55% (for the training data its around 60%).
Can someone help me to interpret my results?
python - 控除可能なモデリング -- scipy.optimize.minimize で収束を達成するのが難しい
私はPythonが初めてです。私のコードがぎこちなく感じる場合は、事前にお詫び申し上げます。ここ数週間、私は控除可能なモデリングと呼ばれる難しい統計上の課題に取り組んできました。私が理解しているように、私の問題はプログラミング/最適化の問題であり、統計の問題ではありません。
必要に応じて、このスレッドをより適切なスタック交換サイトに移動してください。
8 つのパラメーターがあり、そのうちの 2 つは制約されており、正 (phi_freq
およびphi_sev
) である必要があります。基本的に、これらすべてのパラメーターの非凸、マルチモーダル、連続、実数値、非微分 (AFAIK) 関数である対数尤度関数を最大化しようとしています。うわぁ!
このような問題は、検索アルゴリズムに提供されるシード値が、収束するローカル/グローバル最適値に多大な影響を与えることを意味しますが、私の知る限り、私の開始値はしっかりしており、ハードコーディングされています (提供されたサンプルでは)以下)、単なる主観的な直感ではなく、補助的な最適化の結果でした。
Nelder-Mead
ライブラリのandSLSQP
メソッド (SLSQP
はコメントアウトされています) を使用してみましscipy.optimize.minimize
たが、返される値はぎこちなく、無意味です。
以下は MWE です。
現時点でデータを提供する必要があるかどうか、またどのように提供する必要があるかはわかりません (サンプル コードで参照されているpolicies
およびclaims
フラット ファイル)。私はそうする準備ができていますが、最初にそれらを匿名化する必要があります.
ですから、私は壁にぶつかりそうになっているので、この時点でどんな指針も歓迎されると思います. グローバルなソリューションが存在する必要があります。つまり、mle
(最尤推定量) が存在する必要があります。私のシード値は、モーメント マッチング (いわゆるmethod of moments
推定値) によって取得されたため、非常に現実的です。私が間違っていることが他にあるに違いないと感じています。また、不自由に聞こえるかもしれませんが、Excel
のソルバーを使用してまったく同じ問題を再現し、同様の数値収束の問題に遭遇しました。この問題に関して、技術的かどうかにかかわらず、補足的な詳細を提供させていただきます。