R/coef-SVC_mle.R

Defines functions coef.SVC_selection coef.SVC_mle

Documented in coef.SVC_mle coef.SVC_selection

#' @title Extact Mean Effects
#'
#' @description Method to extract the mean effects from an \code{\link{SVC_mle}}
#' or \code{\link{SVC_selection}} object.
#'
#' @param object \code{\link{SVC_mle}} or \code{\link{SVC_selection}} object
#' @param ...    further arguments
#'
#' @return named vector with mean effects, i.e. \eqn{\mu} from
#' \code{\link[varycoef]{SVC_mle}}
#'
#' @author Jakob Dambon
#'
#' @importFrom stats coef
#' @export
coef.SVC_mle <- function(object, ...) {
  mu <- as.numeric(object$coefficients)

  X.vars <- colnames(object$data$X)

  names(mu) <- if (is.null(X.vars)) {
    paste0("Var", 1:length(mu))
  } else {
    X.vars
  }

  mu
}

#' @rdname coef.SVC_mle
#' @importFrom stats coef na.omit
#' @export
coef.SVC_selection <- function(object, ...) {
  mu <- as.numeric(tail(na.omit(object$PMLE_pars$mu.par), 1))

  X.vars <- colnames(object$obj.fun$args$X)

  names(mu) <- if (is.null(X.vars)) {
    paste0("Var", 1:length(mu))
  } else {
    X.vars
  }

  mu
}

Try the varycoef package in your browser

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

varycoef documentation built on Sept. 18, 2022, 1:07 a.m.