lm_coefficients: Get coefficients of linear regression model

lm_coefficientsR Documentation

Get coefficients of linear regression model

Description

This function fits a linear regression model using the given data and formula, and returns the coefficients.

Usage

lm_coefficients(data, formula, standardize = FALSE, each = TRUE)

Arguments

data

A data frame containing the response variable and predictors.

formula

A formula specifying the structure of the linear regression model.

standardize

Whether to standardize the data before fitting the model.

each

each variable do a lm or whole multi-lm

Value

coefficients The coefficients of the linear regression model.

Examples

data <- data.frame(
  response = c(2, 4, 6, 7, 9),
  x1 = c(1, 2, 3, 4, 5),
  x2 = c(2, 3, 6, 8, 9),
  x3 = c(3, 6, 5, 12, 12)
)
coefficients_df <- lm_coefficients(data, response ~ x1 + x2 + x3)
print(coefficients_df)
plot(coefficients_df)

pcutils documentation built on June 26, 2024, 1:06 a.m.