farray_lm | R Documentation |
farray
Fitting linear models using farray
farray_lm( 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 file 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 farray_lm
automatically assign
"V1", "V2", "V3", ... as each partition names.
An object of class c("farray_lm", "lm")
or for multiple
responses of class c("farray_lm", "mlm")
.
Zhengjia Wang
library(farray) 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.farray(arr) object <- farray_lm(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.