R/dda.R

Defines functions dda

Documented in dda

dda <- function(xnew, x, ina) {
  if ( !is.matrix(xnew) )  xnew <- matrix(xnew, nrow = 1)
  ina <- as.numeric(ina)
  g <- max(ina)  ## how many groups are there
  mat <- matrix(nrow = dim(xnew)[1], ncol = g)
  
  for (j in 1:g) {
    a <- Compositional::diri.nr(x[ina == j, ])$param
    mat[, j] <- Compositional::ddiri(xnew, a, logged = TRUE)
  }
  
  Rfast::rowMaxs(mat)
}

Try the Compositional package in your browser

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

Compositional documentation built on Oct. 9, 2024, 5:10 p.m.