dot-fit.lm: Linear regression for 'tidyfit'

.fit.lmR Documentation

Linear regression for tidyfit

Description

Fits a linear regression on a 'tidyFit' R6 class. The function can be used with regress.

Usage

## S3 method for class 'lm'
.fit(self, data = NULL)

Arguments

self

a 'tidyFit' R6 class.

data

a data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

Details

Hyperparameters:

None. Cross validation not applicable.

Important method arguments (passed to m)

The function provides a wrapper for stats::lm. See ?lm for more details.

Implementation

An argument vcov. can be passed in control or to ... in m to estimate the model with robust standard errors. vcov. can be one of "BS", "HAC", "HC" and "OPG" and is passed to the sandwich package.

Value

A fitted 'tidyFit' class model.

Author(s)

Johann Pfitzinger

See Also

.fit.robust, .fit.glm and m methods

Examples

# Load data
data <- tidyfit::Factor_Industry_Returns

# Stand-alone function
fit <- m("lm", Return ~ `Mkt-RF` + HML + SMB, data)
fit

# Within 'regress' function
fit <- regress(data, Return ~ ., m("lm"), .mask = c("Date", "Industry"))
coef(fit)

# With robust standard errors
fit <- m("lm", Return ~ `Mkt-RF` + HML + SMB, data, vcov. = "HAC")
fit


tidyfit documentation built on Oct. 3, 2024, 5:06 p.m.