3 Packages and version information

library(tidyverse)
library(cowplot)
library(numDeriv)
sessionInfo()
## R version 3.4.4 (2018-03-15)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.5 LTS
## 
## Matrix products: default
## BLAS: /usr/lib/libblas/libblas.so.3.6.0
## LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] numDeriv_2016.8-1  forcats_0.3.0      stringr_1.3.0     
##  [4] purrr_0.2.4        readr_1.1.1        tibble_1.4.2      
##  [7] tidyverse_1.2.1    optimization_1.0-7 Rcpp_0.12.16      
## [10] lme4_1.1-17        Matrix_1.2-14      tidyr_0.8.0       
## [13] cowplot_0.9.2      dplyr_0.7.4        ggplot2_2.2.1     
## 
## loaded via a namespace (and not attached):
##  [1] lubridate_1.7.4    lattice_0.20-35    utf8_1.1.3        
##  [4] assertthat_0.2.0   rprojroot_1.3-2    digest_0.6.15     
##  [7] psych_1.8.4        R6_2.2.2           cellranger_1.1.0  
## [10] plyr_1.8.4         backports_1.1.2    evaluate_0.10.1   
## [13] httr_1.3.1         highr_0.6          pillar_1.2.1      
## [16] rlang_0.2.0        lazyeval_0.2.1     readxl_1.1.0      
## [19] minqa_1.2.4        rstudioapi_0.7     nloptr_1.0.4      
## [22] rmarkdown_1.9      labeling_0.3       splines_3.4.4     
## [25] foreign_0.8-69     munsell_0.4.3      broom_0.4.4       
## [28] compiler_3.4.4     modelr_0.1.1       xfun_0.1          
## [31] pkgconfig_2.0.1    mnormt_1.5-5       htmltools_0.3.6   
## [34] tidyselect_0.2.4   bookdown_0.7       crayon_1.3.4      
## [37] MASS_7.3-49        grid_3.4.4         nlme_3.1-137      
## [40] jsonlite_1.5       gtable_0.2.0       magrittr_1.5      
## [43] scales_0.5.0       cli_1.0.0          stringi_1.1.7     
## [46] reshape2_1.4.3     bindrcpp_0.2.2     xml2_1.2.0        
## [49] RColorBrewer_1.1-2 tools_3.4.4        glue_1.2.0        
## [52] hms_0.4.2          parallel_3.4.4     yaml_2.1.18       
## [55] colorspace_1.3-2   rvest_0.3.2        knitr_1.20        
## [58] bindr_0.1.1        haven_1.1.1

4 MLE of logistic regression - Three Methods

In this section, I will use three methods, Newton-Raphson, Fisher Scoring and IRLS(iteratively reweighted least squares) to estimate \(\beta_0, \beta_1\). The data set used in this section came from execrise 17.1 of Richard M. Heiberger (2015).

4.7 R glm output

Using stats::glm function we have identical estimations comparing from MLE-logit link via Newton-Raphson to MLE-logit link via IRLS.

However, for probit link, estimations we have from MLE-probit link via Newton-Raphson to MLE-probit link via IRLS are slightly different from estimations via stats::glm function. There must be hiden secret that I don’t know. It will be inteseting to find out how exactly stats::glm do estimation for logistic regression.

##Logit logistic regression
glm1 <- glm(y ~ xx, data=df1, family=binomial)
glm1$coefficients
## (Intercept)          xx 
##   2.2704607  -0.9081843
##Build probit logistic regression
glm2 <- glm(y ~ xx, data=df1, family=binomial(link = "probit"))
glm2$coefficients
## (Intercept)          xx 
##   1.4769772  -0.5907909

References

Agresti (2016) Richard M. Heiberger (2015)

Agresti, Alan. 2016. Foundations of Linear and Generalized Linear Models. First Edition.

Richard M. Heiberger, Burt Holland. 2015. Statistical Analysis and Data Display an Intermediate Course with Examples in R. Second Edition.