简体   繁体   English

在逻辑回归的glm函数中,似然函数存储在哪里? 有家人吗

[英]In the glm function for logistic regression, where is the likelihood function stored? Is it in family?

I am currently trying to run a logistic regression on my own, using the functions optim , nlm , etc. However, I am somehow getting different coefficient values for the custom model as compared to when I run glm. 我目前正在尝试使用optimnlm等函数自行运行逻辑回归。但是,与运行glm相比,我在某种程度上为自定义模型获取了不同的系数值。

I suspect that my likelihood function might be different, but cannot find where the logit likelihood function is stored in glm . 我怀疑我的似然函数可能有所不同,但是找不到logit似然函数在glm存储的位置。 Does anyone know? 有人知道吗?

The likelihood function is not stored in the glm object. 似然函数未存储在glm对象中。 In R 3.1, only the following fields are present: 在R 3.1中,仅存在以下字段:

> m <- glm(y ~ x, data=df, family=binomial(link=logit))
> names(m)
 [1] "coefficients"      "residuals"         "fitted.values"    
 [4] "effects"           "R"                 "rank"             
 [7] "qr"                "family"            "linear.predictors"
[10] "deviance"          "aic"               "null.deviance"    
[13] "iter"              "weights"           "prior.weights"    
[16] "df.residual"       "df.null"           "y"                
[19] "converged"         "boundary"          "model"            
[22] "call"              "formula"           "terms"            
[25] "data"              "offset"            "control"          
[28] "method"            "contrasts"         "xlevels"

If you type glm.fit at the R prompt, you will see how the optimization proceeds. 如果在R提示符下键入glm.fit ,您将看到优化的过程。 In particular, there is no separate likelihood function that can be evaluated with different points in the parameter space. 特别是,没有单独的似然函数可以用参数空间中的不同点进行评估。 See the link in Steve's comment for what you need to do. 请参阅史蒂夫评论中的链接以了解需要执行的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM