Skip to main content
v2026.11,986 entries · CC-BY 4.0

confint in R: Syntax, Methods and Worked Examples

confint() in R returns confidence intervals for model parameters. See its syntax, how lm, glm and nls methods differ, and a worked example.

Written and maintained by CASRAI Editorial Board

Published

On this page

confint() is the base R function that returns confidence intervals for the parameters of a fitted model: call confint(fit) on an lm, glm or nls object and it gives a matrix with one row per coefficient and the lower and upper limits as columns, labelled 2.5 % and 97.5 % at the default level = 0.95. The method that runs depends on the model class, so the same call produces t-based intervals for lm and profile-likelihood intervals for glm.

What confint is used for in research

A regression coefficient on its own is a point estimate. Reviewers, funders and reporting guidelines ask for the interval around it, because the interval shows how precisely the data pin the effect down. confint() produces that interval for every parameter of a fitted model in a single call, so it sits at the end of most regression workflows: fit the model, check the diagnostics, then report each estimate with its interval. For a general explanation of what the interval means and how to word it, see the guide on confidence intervals explained and the dictionary entry for confidence interval.

The function is a generic. Per the R manual for the stats package, the generic is confint(object, parm, level = 0.95, ...), and R dispatches on the class of object to one of these methods:

  • Default method: based on inverting the Wald test, assuming approximate normality of the estimator. It needs suitable coef and vcov methods for the model class, and it can be called directly as confint.default() for comparison with other methods.
  • lm: uses the direct formulae based on t values.
  • glm and nls: call the appropriate profile method, then find the interval limits by interpolation in the profile traces. The glm method adds the arguments trace = FALSE and test = c("LRT", "Rao").

The method-by-model comparison is in the data table further down the page. The practical consequence is that an lm interval is exact under the usual linear-model assumptions, while a glm interval is a likelihood-based interval that is not forced to be symmetric around the estimate.

How to install or access confint in R

confint() lives in the stats package, which is one of the packages R loads at startup: the R Installation and Administration manual lists datasets, utils, grDevices, graphics, stats and methods (plus base) as the default set. Installing R is therefore enough; there is nothing to install for confint itself.

  1. Open the CRAN front page, cran.r-project.org, and under “Download and Install R” choose the link for Linux, macOS or Windows. The R-admin manual notes that sources, binaries and documentation for R can be obtained through CRAN, which is distributed through a list of mirrors.
  2. Start R (or RStudio, or Rscript) and confirm the function is found by typing ?confint, which opens the stats documentation page.
  3. No library() call is needed for the stats method.

Older R versions and the MASS package

The MASS documentation page for confint states that package MASS added methods for glm and nls fits, and that as from R 4.4.0 these have been migrated to package stats; MASS also adds a method for polr fits. If you run an R release older than 4.4.0, glm profile intervals come from MASS, so call library(MASS) first. MASS is a “recommended” package that ships with standard R installations, per the R-admin manual.

How to calculate confidence intervals with confint step by step

Step 1: Fit a model

The stats manual’s own linear-model example uses the built-in mtcars data:

fit = lm(100/mpg ~ disp + hp + wt + am, data = mtcars)

Step 2: Call confint on the fitted object

confint(fit)

The result is a matrix with one row for each coefficient, including the intercept, and two columns. Because the default level is 0.95, the columns are labelled 2.5 % and 97.5 %. The labels are computed from the level: they are (1 – level)/2 and 1 – (1 – level)/2 expressed in per cent.

Step 3: Restrict to one or more parameters with parm

The parm argument takes either a vector of numbers or a vector of names; if it is missing, all parameters are used. The manual’s example asks for a single coefficient by name:

confint(fit, "wt")
confint(fit, 4)             # the same coefficient by position
confint(fit, c("wt", "hp")) # several at once

Position counts rows of the coefficient table, so with the intercept first, 4 is the fourth coefficient in the formula order shown by names(coef(fit)). Names are safer than numbers because they survive a change of formula.

Step 4: Change the confidence level

confint(fit, level = 0.90)
confint(fit, "wt", level = 0.99)

The column labels change with the level, to 5 % and 95 % for 0.90 and to 0.5 % and 99.5 % for 0.99.

Step 5: Do the same for a generalized linear model

The manual’s glm example, taken from example(glm), is a Poisson regression on a nine-observation dataset:

counts = c(18,17,15,20,10,20,25,13,12)
outcome = gl(3, 1, 9); treatment = gl(3, 3)
glm.D93 = glm(counts ~ outcome + treatment, family = poisson())
confint(glm.D93)          # profile-likelihood intervals
confint.default(glm.D93)  # Wald intervals, based on asymptotic normality

The first call dispatches to the glm method, which profiles the likelihood. The second forces the default Wald method. Running both on the same model is the quickest way to see whether the choice of method matters for your data: with plenty of observations the two usually agree closely, and with small samples or sparse counts they can differ. For background on fitting such models, see the glm() function in R and logistic regression in R.

Step 6: Choose the profile test for glm (optional)

The glm method has test = c("LRT", "Rao"), so test = "LRT" (the first value, and therefore the default) profiles with the likelihood ratio test and test = "Rao" uses the Rao score test. trace = TRUE prints the profiling as it runs, which is useful when a fit is slow.

Worked example: intervals on the odds-ratio or rate-ratio scale

For a Poisson model with its default log link, or a logistic model with its logit link, the coefficients and their interval limits are on the log or log-odds scale. Exponentiating both limits of a coefficient converts them to a rate ratio or an odds ratio:

exp(cbind(estimate = coef(glm.D93), confint(glm.D93)))

This works because the exponential function is monotonic, so exponentiating the limits gives the interval for the exponentiated parameter. Do not exponentiate the intercept’s interval and interpret it as a ratio: it is the baseline rate. The same pattern with family = binomial() gives odds ratios, as covered in the logistic regression guide linked above.

How to read the output

The manual describes the value as a matrix (or vector) with columns giving the lower and upper confidence limits for each parameter. Read it one row at a time:

  • Row names are the coefficient names. A factor such as outcome with three levels appears as separate coefficients, named from the variable and the level, under R’s default contrasts; the reference level has no row. Use names(coef(fit)) to see the exact names you can pass to parm.
  • Column names are the two tail percentages, 2.5 % and 97.5 % at the default level.
  • Interpretation: if an interval for a coefficient excludes zero, the estimate differs from zero at the matching significance level for that parameter. On the exponentiated scale, the comparison value is 1, not 0.
  • Width reflects precision: narrower intervals mean the estimate is pinned down more tightly. A very wide interval is a prompt to check sample size and collinearity, not a result to hide.

A confidence interval is a statement about the procedure over repeated samples; it is not the probability that the true value lies in this one interval. Report the level together with the numbers, for example “0.95 confidence interval”, so readers can compare across papers.

Troubleshooting confint in R

  • Error that no method applies, or no coef/vcov. The default method needs suitable coef and vcov methods for the object. If your model class lacks them, supply the estimates and variance yourself, or use a package that provides a confint method for that class.
  • The name in parm does not match. Names must equal the coefficient names exactly, including the factor level suffix. Print names(coef(fit)) and copy from it.
  • Different numbers from a hand-calculated Wald interval. The glm method profiles the likelihood, whereas an estimate plus or minus 1.96 standard errors is the Wald interval. Use confint.default() if you want the Wald version, and say which one you report.
  • The glm call is slow or the profile will not finish. Profiling refits the model repeatedly. Set trace = TRUE to watch it, and consider the Wald interval as a fallback when the likelihood is poorly behaved, noting the method in your report.
  • The function was not found for glm on an old R. On releases before 4.4.0 the glm and nls methods are in MASS; load it with library(MASS).
  • The labels look odd. level is a probability, so write 0.95, not 95.

Free alternatives to confint

R itself is free software, and each option below is available without a licence fee in a standard R installation or from CRAN. They answer slightly different questions:

Option What it gives Where it is documented
confint.default() Wald intervals for any model with coef and vcov methods, useful for comparing with the profile result stats manual, confint page
confint() on a profile object The glm and nls methods accept an already computed profile object in place of the fitted model, which avoids repeating the profiling stats manual, confint page
boot.ci() in the boot package Nonparametric bootstrap intervals of up to five types: normal approximation, basic, studentized, percentile and BCa, requested with type and a conf level that defaults to 0.95 boot manual, boot.ci page

Bootstrap intervals make fewer distributional assumptions and are worth considering when model assumptions are doubtful; the step-by-step workflow is in the bootstrap in R guide. If you need predicted values with intervals rather than parameter intervals, see predict() in R.

Sources

Data: confint() and bootstrap interval methods in R: basis and arguments by function

Compares the interval methods behind confint() in the stats package and boot.ci() in the boot package: which objects each applies to, how the limits are derived, and the arguments beyond object, parm and level. Compiled from the official R reference pages for stats, MASS and boot, checked 2026-11-17.

confint() and bootstrap interval methods in R: basis and arguments by function
Function or methodApplies toHow the interval is derivedExtra argumentsDefault level
confint.defaultAny model with coef and vcov methods, including S4 fitsInverting the Wald test, assuming approximate normality of the estimatorNone beyond ...0.95
confint.lmObjects of class lmDirect formulae based on t valuesNone beyond ...0.95
confint.glmObjects of class glmProfile likelihood, limits found by interpolation in the profile tracestrace = FALSE; test = c("LRT", "Rao")0.95
confint.nlsObjects of class nlsProfile method, limits found by interpolation in the profile tracesNone beyond ...0.95
boot.ciObjects of class bootNonparametric bootstrap: norm, basic, stud, perc or bca (or all five)type; index; var.t0; var.t; h, hdot, hinv0.95 (argument conf)

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about confint in R: Syntax, Methods and Worked Examples

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →