| glm_offset | R Documentation |
This function is a wrapper around stats::glm() that uses a column from
data as an offset.
glm_offset(
formula,
family = "gaussian",
data,
offset_col = "offset",
weights = NULL
)
formula |
A model formula |
family |
A function or character string describing the link function and error distribution. |
data |
Optional. A data frame containing variables used in the model. |
offset_col |
Character string. The name of a column in |
weights |
Optional weights to use in the fitting process. |
Outside of the tidymodels ecosystem, glm_offset() has no advantages over
stats::glm() since that function allows for offsets to be specified
in the formula interface or its offset argument.
Within tidymodels, glm_offset() provides an advantage because it will
ensure that offsets are included in the data whenever resamples are created.
The formula, family, data, and weights arguments have the same
meanings as stats::glm(). See that function's documentation for full
details.
A glm object. See stats::glm() for full details.
stats::glm()
if (interactive()) {
us_deaths$off <- log(us_deaths$population)
glm_offset(deaths ~ age_group + gender, family = "poisson",
us_deaths, offset_col = "off")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.