{"id":28710752,"url":"https://github.com/paulnorthrop/profileci","last_synced_at":"2025-06-14T21:07:53.169Z","repository":{"id":296522613,"uuid":"984995071","full_name":"paulnorthrop/profileCI","owner":"paulnorthrop","description":"Profiling a Log-Likelihood to Calculate a Confidence Interval","archived":false,"fork":false,"pushed_at":"2025-05-31T18:52:11.000Z","size":3802,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T21:13:12.984Z","etag":null,"topics":["confidence-interval","confidence-intervals","likelihood-based","log-likelihood","log-likelihood-functions","statistical-uncertainties","uncertainty-estimation"],"latest_commit_sha":null,"homepage":"https://paulnorthrop.github.io/profileCI/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulnorthrop.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-16T21:49:02.000Z","updated_at":"2025-05-31T18:56:39.000Z","dependencies_parsed_at":"2025-05-31T21:13:19.345Z","dependency_job_id":"6cd7ac24-9aed-4f3b-b31a-07e7cf190797","html_url":"https://github.com/paulnorthrop/profileCI","commit_stats":null,"previous_names":["paulnorthrop/profileci"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/paulnorthrop/profileCI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulnorthrop%2FprofileCI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulnorthrop%2FprofileCI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulnorthrop%2FprofileCI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulnorthrop%2FprofileCI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulnorthrop","download_url":"https://codeload.github.com/paulnorthrop/profileCI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulnorthrop%2FprofileCI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259884458,"owners_count":22926445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["confidence-interval","confidence-intervals","likelihood-based","log-likelihood","log-likelihood-functions","statistical-uncertainties","uncertainty-estimation"],"created_at":"2025-06-14T21:07:52.627Z","updated_at":"2025-06-14T21:07:53.160Z","avatar_url":"https://github.com/paulnorthrop.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# profileCI\n\n[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/99jojhgk9t4agdmv/branch/main?svg=true)](https://ci.appveyor.com/project/paulnorthrop/profileCI/branch/main)\n[![R-CMD-check](https://github.com/paulnorthrop/profileCI/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/paulnorthrop/profileCI/actions/workflows/R-CMD-check.yaml)\n[![Coverage Status](https://codecov.io/github/paulnorthrop/profileCI/coverage.svg?branch=master)](https://app.codecov.io/github/paulnorthrop/profileCI?branch=master)\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/profileCI)](https://cran.r-project.org/package=profileCI)\n[![Downloads (monthly)](https://cranlogs.r-pkg.org/badges/profileCI?color=brightgreen)](https://cran.r-project.org/package=profileCI)\n[![Downloads (total)](https://cranlogs.r-pkg.org/badges/grand-total/profileCI?color=brightgreen)](https://cran.r-project.org/package=profileCI)\n\n## Profiling a Log-likelihood to Calculate Confidence Intervals\n\nThis package computes confidence intervals based on profile log-likelihood for one or more parameters in a user-supplied fitted multi-parameter model. The functionality of the main function, `profileCI()`, is like that of `confint.glm`, which calculates confidence intervals for the parameters of a Generalised Linear Model (GLM). \n\nSpeed of computation can be improved by starting the profiling from limits based on large sample normal theory. The accuracy of the limits can be set by the user. A plot method visualises the log-likelihood and confidence interval. Only convex log-likelihoods are supported, that is, disjoint confidence intervals will not be found.\n    \n## An example\n\nWe illustrate the use of `profileCI()` using an example from the help file for `stats::glm()`. \n\n```{r}\n## From example(glm)\ncounts \u003c- c(18, 17, 15, 20, 10, 20, 25, 13, 12)\noutcome \u003c- gl(3, 1, 9)\ntreatment \u003c- gl(3, 3)\nglm.D93 \u003c- glm(counts ~ outcome + treatment, family = poisson())\n# Intervals based on profile log-likelihood\nconfint(glm.D93)\n```\n\nTo calculate these intervals using `profileCI` we provide a function that calculates the log-likelihood for this Poisson GLM for an input parameter vector `pars`.\n\n```{r}\npoisson_loglik \u003c- function(pars) {\n  lambda \u003c- exp(model.matrix(glm.D93) %*% pars)\n  loglik \u003c- stats::dpois(x = glm.D93$y, lambda = lambda, log = TRUE)\n  return(sum(loglik))\n}\n```\n\nThe function `profileCI()` profiles the log-likelihood, with respect to one parameter at a time. For a given value of this parameter the log-likelihood is maximised over the other parameters. The aim is to search below and above the MLE of the parameter until the profile log-likelihood drops to a level corresponding to the limits of the confidence interval of a desired confidence level. \n\nTwo arguments can be used to affect the speed with which the confidence limits are obtained: `mult` determines the amount, as a percentage of the estimated standard error of the estimator of the parameter of interest, by which the value of the parameter is incremented when profiling. Larger values of `mult` should result in a faster calculation but increase the risk that one of the optimisations required will fail. If the argument `faster = TRUE` then the searches for the lower and upper confidence limits are started from limits based on the approximate large  sample normal distribution for the maximum likelihood estimator of a parameter, rather than the maximum likelihood estimate. The defaults are `mult = 32` and `faster = TRUE`.\n    \n```{r}\nlibrary(profileCI)\nprof \u003c- profileCI(glm.D93, loglik = poisson_loglik)\nprof\n```\n\nWe can visualise the profile likelihood for a parameter using a plot method. \n\n```{r }\nplot(prof, parm = \"outcome2\")\n```\n\nTo obtain smooth version of this plot, we call `profileCI()` with `mult = 8` and `faster = FALSE`, but this is much slower calculation. \n\n```{r}\nprof \u003c- profileCI(glm.D93, loglik = poisson_loglik, mult = 8, faster = FALSE)\nplot(prof, parm = \"outcome2\")\n```\n\n\nBy default, once it has been determined that a limit lies between two values of the parameter, quadratic interpolation is used to estimate the value of the limit. If a specific degree of accuracy is required then this can be set by passing a positive tolerance `epsilon` to the `itp` function in the [itp package](https://cran.r-project.org/package=itp).\n\nAn alternative to passing the log-likelihood function using the argument `loglik` is to provide the same function via a `logLikFn` S3 method for the fitted model object.\n\n## Installation\n\nTo get the current released version from CRAN:\n\n```{r installation, eval = FALSE}\ninstall.packages(\"profileCI\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulnorthrop%2Fprofileci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulnorthrop%2Fprofileci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulnorthrop%2Fprofileci/lists"}