⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msc.r

📁 做主成分回归和偏最小二乘回归
💻 R
字号:
### msc.R: Multiplicative scatter/signal correction######	$Id: msc.R 2 2005-03-29 14:31:42Z  $	msc <- function(X, reference = NULL) {    if (is.null(reference)) reference <- colMeans(X)    Z <- cbind(1, reference)    ## The estimated regression coefficients (a_i, b_i), one pair per row:    B <- t(solve(crossprod(Z), t(X %*% Z)))    res <- (X - B[,1]) / B[,2]    attr(res, "reference") <- reference    class(res) <- c("msc", "matrix")    return(res)}predict.msc <- function(object, newdata, ...) {    if (missing(newdata)) return(object)    msc(newdata, reference = attr(object, "reference"))}## This method makes things like## `predict(plsr(y ~ msc(X), data = foo), newdata = bar)' work.makepredictcall.msc <- function(var, call) {    if (as.character(call)[1] != "msc")         return(call)    call$reference <- attr(var, "reference")    call}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -