R/lmp.R

#' Extract P-value from linear model object
#' 
#' This function returns the P-value from a linear model object. 
#' 
#' Note that for dichotomous dummy variable it is the P-value of non-reference group (i.e. not intercept)
#' 
#' @param modelobject Linear model object generated by lm() function
#' @export


lmp <- function (modelobject) {
  if (class(modelobject) != "lm") stop("Not an object of class 'lm' ")
  f <- summary(modelobject)$fstatistic
  p <- pf(f[1],f[2],f[3],lower.tail=F)
  attributes(p) <- NULL
  return(p)
}
msxakk89/dat documentation built on Aug. 3, 2020, 6:39 p.m.