Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于selection.py中StatsModel的loglikelihood方法 #115

Open
NKNaN opened this issue Jan 29, 2023 · 1 comment
Open

关于selection.py中StatsModel的loglikelihood方法 #115

NKNaN opened this issue Jan 29, 2023 · 1 comment

Comments

@NKNaN
Copy link

NKNaN commented Jan 29, 2023

我尝试借助statsmodels库里封装的逻辑回归,以aic为criteria,自己写了lr的stepwise regression,发现与toad的stepwise中得出的最终结果不一致,最后发现用toad筛选出的模型的aic与statsmodels中计算得到的aic值不同。

在看过源码后,发现selection.py中StatsModel的loglikelihood计算方法是统一用了mse,按我的理解源码里的公式应该只能用在estimator是ols的情况,lr的loglikelihood的计算应为 sum over i( yi * beta^t * xi - log( 1 + exp( beta^t * xi )))。

而且对于lasso和ridge来说,同样用ols的mse计算方式来计算loglikelihood应该也不合适,我目前还在查找lasso和ridge的aic和bic应该怎么算比较合理。

@Secbone
Copy link
Member

Secbone commented Mar 7, 2024

@NKNaN 抱歉很晚才回复,这部分内容确实存在问题,最初为了实现方便没有单独对不同模型重写 loglikelihood,欢迎提PR进行更正~ 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants