R/ProxGrad_Construction_Functions.R

Defines functions construct.cv.ProxGrad construct.ProxGrad

# -----------------------------------------------------------------------
# Object Construction for ProxGrad object
#
# object: the ProxGrad object
# fn_call: the function call
# -----------------------------------------------------------------------
construct.ProxGrad <- function(object, fn_call, glm_type, lambda_sparsity){
  
  class(object) <- append("ProxGrad", class(object))
  object$call <- fn_call
  
  object$glm_type <- glm_type
  
  object$lambda_sparsity <- lambda_sparsity
  
  object$coef <- c(object$Intercept, object$Betas)
  
  return(object)
}

# -----------------------------------------------------------------------
# Object Construction for cv.ProxGrad object
#
# object: the cv.ProxGrad object
# fn_call: the function call
# -----------------------------------------------------------------------
construct.cv.ProxGrad <- function(object, fn_call, glm_type, n_lambda_sparsity){
  
  class(object) <- append("cv.ProxGrad", class(object))
  object$call <- fn_call
  
  object$glm_type <- glm_type
  
  object$n_lambda_sparsity <- n_lambda_sparsity

  object$coef <- c(object$Intercept[object$Optimal_Index], object$Betas[,object$Optimal_Index])
  
  return(object)
}

Try the CPGLIB package in your browser

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

CPGLIB documentation built on Nov. 22, 2022, 5:08 p.m.