flm | R Documentation |

`flm`

is a fast linear model command that (by default) only returns a coefficient matrix. 6 different efficient fitting methods are implemented: 4 using base R linear algebra, and 2 utilizing the *RcppArmadillo* and *RcppEigen* packages. The function itself only has an overhead of 5-10 microseconds, and is thus well suited as a bootstrap workhorse.

```
flm(...) # Internal method dispatch: default if is.atomic(..1)
## Default S3 method:
flm(y, X, w = NULL, add.icpt = FALSE, return.raw = FALSE,
method = c("lm", "solve", "qr", "arma", "chol", "eigen"),
eigen.method = 3L, ...)
## S3 method for class 'formula'
flm(formula, data = NULL, weights = NULL, add.icpt = TRUE, ...)
```

`y` |
a response vector or matrix. Multiple dependent variables are only supported by methods "lm", "solve", "qr" and "chol". | ||||||||||||||||||||||||||||||||||||

`X` |
a matrix of regressors. | ||||||||||||||||||||||||||||||||||||

`w` |
a weight vector. | ||||||||||||||||||||||||||||||||||||

`add.icpt` |
logical. | ||||||||||||||||||||||||||||||||||||

`formula` |
a | ||||||||||||||||||||||||||||||||||||

`data` |
a named list or data frame. | ||||||||||||||||||||||||||||||||||||

`weights` |
a weights vector or expression that results in a vector when evaluated in the | ||||||||||||||||||||||||||||||||||||

`return.raw` |
logical. | ||||||||||||||||||||||||||||||||||||

`method` |
an integer or character string specifying the method of computation:
| ||||||||||||||||||||||||||||||||||||

`eigen.method` |
integer. Select the method of computation used by
See | ||||||||||||||||||||||||||||||||||||

`...` |
further arguments passed to other methods. For the formula method further arguments passed to the default method. Additional arguments can also be passed to the default method e.g. |

If `return.raw = FALSE`

, a matrix of coefficients with the rows corresponding to the columns of `X`

, otherwise the raw results from the various methods are returned.

Method "qr" supports sparse matrices, so for an `X`

matrix with many dummy variables consider method "qr" passing `as(X, "dgCMatrix")`

instead of just `X`

.

`fhdwithin/HDW`

, `fFtest`

, Data Transformations, Collapse Overview

```
# Simple usage
coef <- flm(mpg ~ hp + carb, mtcars, w = wt)
# Same thing in programming usage
flm(mtcars$mpg, qM(mtcars[c("hp","carb")]), mtcars$wt, add.icpt = TRUE)
# Check this is correct
lmcoef <- coef(lm(mpg ~ hp + carb, weights = wt, mtcars))
all.equal(drop(coef), lmcoef)
# Multi-dependent variable (only some methods)
flm(cbind(mpg, qsec) ~ hp + carb, mtcars, w = wt)
# Returning raw results from solver: different for different methods
flm(mpg ~ hp + carb, mtcars, return.raw = TRUE)
flm(mpg ~ hp + carb, mtcars, method = "qr", return.raw = TRUE)
# Test that all methods give the same result
all_obj_equal(lapply(1:6, function(i)
flm(mpg ~ hp + carb, mtcars, w = wt, method = i)))
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.