R/wgts.R

Defines functions wgts

# Optimal linear mean abs error combination of matrix x for vector y
wgts <- function(y, x){
  n <- ncol(x)
  init <- rep(1/n, n)
  f1 <- function(w)mean(abs(y - w %*% t(x)))
  sbplx(init, f1, rep(0, n), rep(1, n), control = list(maxeval = 5000))
}
steinarv/k1 documentation built on Oct. 19, 2017, 4:41 a.m.