calc_resid <-
function(Y, fitted_values){
  # Calculate raw residuals.
  # message("class(fitted_values: ", class(fitted_values))
  # message("dim(fitted_values): ", paste(dim(fitted_values), collapse = ", "))
  stopifnot(is.numeric(Y), is.numeric(fitted_values),
            is.vector(Y), is.vector(fitted_values),
            identical(length(Y), length(fitted_values)))
  return(as.vector(Y - fitted_values))
}
