Người ta có thể thực hiện hồi quy logit trong R bằng cách sử dụng mã như vậy:
> library(MASS)
> data(menarche)
> glm.out = glm(cbind(Menarche, Total-Menarche) ~ Age,
+                                              family=binomial(logit), data=menarche)
> coefficients(glm.out)
(Intercept)         Age 
 -21.226395    1.631968
Có vẻ như thuật toán tối ưu hóa đã hội tụ - có thông tin về số bước của thuật toán chấm điểm câu cá:
Call:
glm(formula = cbind(Menarche, Total - Menarche) ~ Age, family = binomial(logit), 
    data = menarche)
Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.0363  -0.9953  -0.4900   0.7780   1.3675  
Coefficients:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept) -21.22639    0.77068  -27.54   <2e-16 ***
Age           1.63197    0.05895   27.68   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
    Null deviance: 3693.884  on 24  degrees of freedom
Residual deviance:   26.703  on 23  degrees of freedom
AIC: 114.76
Number of Fisher Scoring iterations: 4
Tôi tò mò về thuật toán tối ưu nó là gì? Có phải là thuật toán Newton-Raphson (giảm độ dốc bậc hai) không? Tôi có thể đặt một số tham số để sử dụng thuật toán Cauchy (giảm độ dốc bậc một) không?
Newton's methodlà một phương pháp giảm độ dốc bậc hai.