R/loss.R

Defines functions loss

loss = function(y, alpha, q){
  q = as.matrix(q)
  loss = matrix(nrow = length(y), ncol = length(alpha))
  for(i in 1:length(y)){
    for(k in 1:length(alpha)){
      if(y[i] > q[i, k]){
        loss[i, k] = alpha[k] * abs(y[i] - q[i, k])
      }
      else{
        loss[i, k] = (1-alpha[k]) * abs(y[i] - q[i, k])
      }
    }
  }
  return(loss)
} 

Try the quantregRanger package in your browser

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

quantregRanger documentation built on May 2, 2019, 3:26 a.m.