R/coef.HDBRR.R

Defines functions coef.HDBRR

Documented in coef.HDBRR

#' Extract coefficients from an HDBRR model
#'
#' @param object An `HDBRR` object, typically created by [HDBRR()].
#' @param all Logical; if `TRUE`, print all coefficients. Otherwise, at most
#'   the first 250 coefficients are printed.
#' @param ... Additional arguments passed to or from other methods.
#' @rdname coef
#' @export

coef.HDBRR <- function(object, all = FALSE, ...){
  if(!inherits(object, "HDBRR")) stop("This function only works for objects of class 'HDBRR'\n");
  coefs <- object$betahat
  
  if(all == FALSE){
    if(length(coefs) > 250){
      coefs1 <- as.vector(round(coefs[1:250],5))
    }
    else{
      coefs1 <- as.vector(round(coefs,5))
    }
    cat("\nCoefficients:\n\n")
    print(coefs1)
    if(length(coefs) > 250){
      r <- length(coefs) - 250
      cat("\n...",r,"coefficients was omitted")
    }
    cat("\n")
  }
  else{
    cat("\nCoefficients:\n\n")
    coefs <- as.vector(round(coefs,5))
    print(coefs)
  }
  
  invisible(coefs)
}

Try the HDBRR package in your browser

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

HDBRR documentation built on Sept. 23, 2026, 5:07 p.m.