R/lmr.R

Defines functions predict.Lmr coef.Lmr lmr

Documented in coef.Lmr lmr predict.Lmr

lmr <- function(X, Y, weights = NULL) {
    fm <- lm(Y ~ X, weights = weights)
    structure(
        fm,
        class = c("Lmr")
        )
    }

coef.Lmr <- function(object, ...) {
    z <- .mat(object$coefficients, "y")
    int <- z[1, ]
    B <- z[-1, , drop = FALSE]
    row.names(B) <- paste("x", seq(dim(B)[1]), sep = "")
    list(int = int, B = B) 
    }

predict.Lmr <- function(object, X, ...) {
    X <- .mat(X)
    rownam <- row.names(X)
    z <- coef(object)
    pred <- t(c(z$int) + t(X %*% z$B))
    list(pred = pred)
    }

Try the rchemo package in your browser

Any scripts or data that you put into this service are public.

rchemo documentation built on Sept. 11, 2024, 8:05 p.m.