R/weightEstim.R

Defines functions weightEstim

Documented in weightEstim

weightEstim <- function(dat,lam=0.4,a=1,tol=1e-6){

  # Initialize the weight vector
  w.mb <- rep(1,ncol(dat))

  if (length(w.mb) == 1) ## w.mb has to be a vector
  stop("weight should be a vector whose length is equal to column size of design matrix")

  # Normalize the weights
  w.mat <- w.mb/sum(w.mb)

  # Update equation for weights
  converge = FALSE

  while (converge==FALSE){
    w.mat.old <- w.mat
    w.mat <- (1-a)*w.mat + a*weightComp(dat,lam,w.mat)
    eps <- sum((w.mat.old-w.mat)^2)

    if (eps < tol){
      converge = TRUE
    }
    w.dat <- w.mat
  }
  return(w.dat)
}

Try the DWLasso package in your browser

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

DWLasso documentation built on May 2, 2019, 7:27 a.m.