R/stdEr.R

Defines functions stdEr stdEr.default stdEr.lm

Documented in stdEr stdEr.default stdEr.lm

### methods for extracting standard errors from the models

stdEr <- function(x, ...)
    ## Extract standard deviations from models (as coefficients)
    UseMethod("stdEr")

stdEr.default <- function(x, ...) {
   if( !isS4( x ) ) {
      if( !is.null( x$std ) ) {
         return(x$std)
      }
   }
   if(!is.null(vc <- vcov(x))) {
      s <- sqrt(diag(vc))
      names(s) <- names(coef(x))
      return(s)
   }
   return(NULL)
                           # if neither std nor vcov is defined, we return NULL...
}

stdEr.lm <- function(x, ...)
    sqrt(diag(vcov(x)))

Try the miscTools package in your browser

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

miscTools documentation built on Dec. 9, 2019, 3 a.m.