R/predict.kerndwd.R

Defines functions predict.kerndwd

Documented in predict.kerndwd

predict.kerndwd = function(object, kern, x, newx,
    type=c("class", "link"), ...) {
  type = match.arg(type)
  newx = drop(as.matrix(newx))
  if (is.null(dim(newx))) dim(newx) = c(1, length(newx))
  if (class(kern)[[1]] == "vanillakernel" && NROW(x) > NCOL(x))
    nfit = newx %*% object$alpha[-1, , drop=FALSE] else 
    nfit = kernelMult(kern, newx, x, object$alpha[-1, , drop=FALSE])
  nfit = sweep(nfit, MARGIN=2, object$alpha[1, , drop=FALSE], "+")
  switch(type, 
    link = nfit, 
    class = ifelse(nfit > 0, 1, -1))
} 

Try the kerndwd package in your browser

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

kerndwd documentation built on Sept. 4, 2020, 1:08 a.m.