For this last example, we’ll explore the curve_lik() function, which can help generate profile likelihood functions, and deviance statistics with the help of the ProfileLikelihood package.1. For an introduction to what profile likelihoods are, see the following paper.2

library(ProfileLikelihood)
#> Loading required package: nlme
#> Loading required package: MASS

We’ll use a simple example taken directly from the ProfileLikelihood documentation where we’ll calculate the likelihoods from a glm model

data(dataglm)
xx <- profilelike.glm(y ~ x1 + x2,
  data = dataglm, profile.theta = "group",
  family = binomial(link = "logit"), length = 500, round = 2
)
#> Warning message: provide lo.theta and hi.theta

Then, we’ll use curve_lik() on the object that the ProfileLikelihood package created.

lik <- curve_lik(xx, dataglm)

Next, we’ll plot three functions, the relative likelihood, the log-likelihood, the likelihood, and the deviance function.

ggcurve(lik[[1]], type = "l1", nullvalue = TRUE)

ggcurve(lik[[1]], type = "l2")

ggcurve(lik[[1]], type = "l3")

ggcurve(lik[[1]], type = "d")

The obvious advantage of using reduced likelihoods is that they are free of nuisance parameters

\[L_{t_{n}}(\theta)=f_{n}\left(F_{n}^{-1}\left(H_{p i v}(\theta)\right)\right)\left|\frac{\partial}{\partial t} \psi\left(t_{n}, \theta\right)\right|=h_{p i v}(\theta)\left|\frac{\partial}{\partial t} \psi(t, \theta)\right| /\left.\left|\frac{\partial}{\partial \theta} \psi(t, \theta)\right|\right|_{t=t_{n}}\] thus, giving summaries of the data that can be incorporated into combined analyses.

Session info

#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Catalina 10.15.6
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ProfileLikelihood_1.1 MASS_7.3-51.6         nlme_3.1-148         
#> [4] concurve_2.7.0       
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyr_1.1.1       splines_4.0.2     carData_3.0-4     assertthat_0.2.1 
#>  [5] metafor_2.4-0     cellranger_1.1.0  yaml_2.2.1        bcaboot_0.2-1    
#>  [9] gdtools_0.2.2     pillar_1.4.6      backports_1.1.8   lattice_0.20-41  
#> [13] glue_1.4.1        uuid_0.1-4        digest_0.6.25     ggsignif_0.6.0   
#> [17] colorspace_1.4-1  htmltools_0.5.0   Matrix_1.2-18     pkgconfig_2.0.3  
#> [21] broom_0.7.0       haven_2.3.1       xtable_1.8-4      purrr_0.3.4      
#> [25] scales_1.1.1      km.ci_0.5-2       openxlsx_4.1.5    officer_0.3.12   
#> [29] rio_0.5.16        KMsurv_0.1-5      tibble_3.0.3      farver_2.0.3     
#> [33] generics_0.0.2    car_3.0-8         ggplot2_3.3.2     ellipsis_0.3.1   
#> [37] ggpubr_0.4.0      survival_3.2-3    magrittr_1.5      crayon_1.3.4     
#> [41] readxl_1.3.1      memoise_1.1.0     evaluate_0.14     fs_1.5.0         
#> [45] rstatix_0.6.0     forcats_0.5.0     xml2_1.3.2        foreign_0.8-80   
#> [49] tools_4.0.2       data.table_1.13.0 hms_0.5.3         lifecycle_0.2.0  
#> [53] stringr_1.4.0     flextable_0.5.10  munsell_0.5.0     zip_2.0.4        
#> [57] compiler_4.0.2    pkgdown_1.5.1     survminer_0.4.8   pbmcapply_1.5.0  
#> [61] systemfonts_0.2.3 rlang_0.4.7       grid_4.0.2        rstudioapi_0.11  
#> [65] labeling_0.3      base64enc_0.1-3   rmarkdown_2.3     boot_1.3-25      
#> [69] gtable_0.3.0      abind_1.4-5       curl_4.3          R6_2.4.1         
#> [73] zoo_1.8-8         gridExtra_2.3     knitr_1.29        dplyr_1.0.1      
#> [77] survMisc_0.5.5    rprojroot_1.3-2   desc_1.2.0        stringi_1.4.6    
#> [81] parallel_4.0.2    Rcpp_1.0.5        vctrs_0.3.2       tidyselect_1.1.0 
#> [85] xfun_0.16

References


1. Choi L. ProfileLikelihood: Profile Likelihood for a Parameter in Commonly Used Statistical Models.; 2011. https://CRAN.R-project.org/package=ProfileLikelihood.

2. Cole SR, Chu H, Greenland S. Maximum likelihood, profile likelihood, and penalized likelihood: A primer. American Journal of Epidemiology. 2013;179(2):252-260. doi:10/f5mx4q