Learn R Programming

reghelper (version 0.3.3)

coef.block_lm: Extract model coefficients.

Description

coef method for class "block_lm".

Usage

# S3 method for block_lm
coef(object, num = NULL, ...)

Arguments

object

An object of class "block_lm", usually, a result of a call to build_model.

num

Numeric vector with the index of model(s) from which to return the coefficients.

...

Further arguments passed to or from other methods.

Value

The coefficients of block(s) `num`, or if `num` is NULL, a list of coefficients from all blocks.

See Also

build_model, coef.block_lm_summary, fitted.block_lm, residuals.block_lm

Examples

Run this code
# NOT RUN {
# 2 blocks: Petal.Length; Petal.Length + Petal.Width
model1 <- build_model(Sepal.Length, Petal.Length, Petal.Width, data=iris, model='lm')
summary(model1)
coef(model1)  # returns both blocks 1 and 2

# 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width
model2 <- build_model(Sepal.Length, Species, c(Petal.Length * Petal.Width), data=iris, model='lm')
summary(model2)
coef(model2, num=2)  # returns second block
# }

Run the code above in your browser using DataLab