R/validate.outcome.R

Defines functions validate.outcome

validate.outcome <- function(null, resp.var, family){
  
  resp.level <- unique(null[, resp.var])
  
  if(length(resp.level) == 2){
  	if(family == 'binomial'){
	    if(!setequal(resp.level, c(0, 1))){
	      msg <- "response variable in formula should be 0 and/or 1"
	      stop(msg)
	    }
	  }else{
	  	msg <- 'response variable in formula has only two levels, while family = \'gaussian\'. Would family be \'binomial\'?'
	  	warning(msg)
	  }
  }else{
  	if(family == 'binomial'){
  		msg <- "response variable in formula should have two levels if family = \'binomial\'"
  		stop(msg)
  	}
  }
  
}
zhangh12/ARTP2 documentation built on Aug. 16, 2019, 7:27 p.m.