R/nnlsPred.R

nnlsPred <- function (x, y, w = NULL) {
  if (is.vector (w)) {
    w <- sqrt(unlist (w))
    x <- w * x
    y <- w * y
  }
  
  z <- qr(x)
  q <- qr.Q(z)
  u <- -colSums(y * q)
  l <- nnls(t(q), u)$x
  b <- backsolve(qr.R (z), colSums((y + l) * q))
  h <- drop(x %*% b)
  return (list(coef = b, pred = h, ssq = sum((y-h) & 2)))
}

Try the smacof package in your browser

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

smacof documentation built on May 6, 2022, 9:05 a.m.