R/ash_estmode.R

Defines functions ash.estmode

# a wrapper function that estimates the mode, using optimize
# called by ash if mode="estimate"
ash.estmode = function(betahat, modemin, modemax, ...){
  opt.fn = function(c) {
    return(-ash(betahat = betahat, mode = c, outputlevel = "loglik", ...)$loglik)
  }
  opt = stats::optimize(opt.fn, 
                        interval = c(modemin, modemax),
                        tol = abs(modemax - modemin) * .Machine$double.eps^0.25)
  return(opt$minimum)
}

Try the ashr package in your browser

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

ashr documentation built on Aug. 22, 2023, 1:07 a.m.