lazylm | R Documentation |
lazyarray
Fitting linear models using lazyarray
lazylm(
formula,
data,
fitted = FALSE,
weights = NULL,
offset = NULL,
contrasts = NULL,
na.action = getOption("na.action"),
qr.tol = 1e-07,
...
)
formula |
an object of class |
data |
a |
fitted |
whether to calculate fitted data and residuals. This may take time and memory if data is large |
weights, offset, contrasts, na.action |
see |
qr.tol |
the tolerance for detecting linear dependencies in the
partitions of |
... |
passed to |
The array will be reshaped to a matrix first before fitting the
linear models. A 100 x 20 x 5
array will be reshaped to a
2000 x 5
lazy matrix.
The variables are the partitions of the array. If dimnames
are set for the last margin index, then those will be used as variable
names, otherwise lazylm
automatically assign
"V1", "V2", "V3", ...
as each partition names.
An object of class c("lazylm", "lm")
or for multiple
responses of class c("lazylm", "mlm")
.
library(lazyarray)
arr <- array(rnorm(72), c(6,3,4))
arr[1,1,1] <- NA # Allow NA to be treated
offset = rnorm(18) # offset and weights are optional
weights = runif(18)
formula <- V1 ~ .-V2-1 + (V2 > 0)
data <- as.lazyarray(arr, type = 'file')
object <- lazylm(formula, data, weights = weights, offset = offset)
# Compare to stats::lm
dim(arr) <- c(18, 4)
lm_data <- as.data.frame(arr)
flm <- lm(formula, lm_data, weights = weights, offset = offset)
cbind(coef(object), coef(flm))
cbind(resid(object), resid(flm))
cbind(fitted(object), fitted(flm))
summary(object)
summary(flm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.