coef( )

Extract model coefficients. coef() is a generic function in base R (stats package).

Required Library

# coef() is in base R (stats), loaded by default — no package installation needed

Syntax

coef(object)

coef(object) extracts estimated coefficients from a fitted model object. For a simple linear model, this usually returns intercept and slope.

coefs <- coef(model)

intercept <- coefs[[1]]
slope <- coefs[[2]]

Use indexing when you need individual coefficient values for calculations, plotting, or formatted output.

Use coef(model) when you only need the coefficient estimates. Use summary(model)$coefficients when you also need standard errors, t-values, and p-values.

Examples

Extract intercept and slope from an lm() model
Access coefficients by name
Use coef() values to draw a regression line in ggplot
Compare coef() with summary() coefficient table

Argument Overview

Required arguments must be included when using a function while optional arguments can be included on demand.

object — fitted model object model object Required

The fitted object from which coefficients should be extracted. Commonly produced by lm(), but coef() also works for many other model classes.

model <- lm(absorbance ~ conc_ug_ml, data = calibration)
coef(model)

Data Types: model object (for example lm, glm, nls)

— method-specific options various Optional

Additional arguments passed to class-specific methods. For many everyday lm() uses, you do not need to set any extra arguments.

Data Types: depends on model class