R/regmed.grid.bestfit.R

Defines functions regmed.grid.bestfit

Documented in regmed.grid.bestfit

regmed.grid.bestfit <- function(fit.grid){
  ## input:
  ## fit.grid is output of regmed.grid
    
  if(!("regmed.grid" %in% class(fit.grid))) {
      stop("input not regmed.grid class")
  }
    
  lambda <- fit.grid$grid.data$lambda
  bic <- fit.grid$grid.data$bic
  index.best <- (1:length(lambda))[bic == min(bic)]
  fit.best <- fit.grid$fit.list[index.best][[1]]  
  fit.best$MedCov <- fit.grid$MedCov
  class(fit.best) <- c("regmed", "list")
  return(fit.best) 
}

Try the regmed package in your browser

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

regmed documentation built on Jan. 22, 2023, 1:30 a.m.