R/print.SurvAM.R

Defines functions print.SurvAM

Documented in print.SurvAM

#' Print an object of class SurvAM--output from survEstMeasures
#' 
#'  
#' @param x,output from the function survEstMeasures
#' @return NULL


print.SurvAM <- function(x, ...){
  #methods to print an object of class "SurvAM"
  # want to display the estimates, standard errors, and confidence intervals
  # just like coxph
  
  #x is a list with elements 'estimates', 'se', 'CIbounds', 'cutoff', 'CImethod', 'SEmethod', and 'predict.time'
  
  cat("\n")
  cat(paste(ifelse(is.element(x$estimation.method, c("Cox")), "Semi-Parametric Cox", "Non-Parametric IPW"), "estimates of accuracy measures:\n"))
  cat(paste("   (SE's calculated using", 
            ifelse(substr(x$se.method, 1, 4)=="asym", "asymptotic variance)", "the bootstrap)")))
  cat("\n\n")
  mynames = names(x$estimates)
  
  if(any(mynames %in% c("FPR", "TPR" , "NPV" , "PPV"))){
    whitespace <- rep(" ",4)
  }else{
    whitespace <- rep(" ", 4)
  }
  
  cat(whitespace, paste("estimate     se      lower ",
            1-x$alpha, "  upper ",
            1-x$alpha, "\n",sep = ""))
  
  

  for(i in 1:length(mynames)){
    if(mynames[i] %in% c("FPR", "TPR" , "NPV" , "PPV") ) mynames[i] = paste(mynames[i], "(c)", sep = "")
    cat(paste(sprintf("%-6s", mynames[i]), 
              sprintf("%10.3f", round(x$estimate[i], 3)), 
              sprintf("%10.3f ", round(x$se[i], 3)), 
              sprintf("%13.3f ", round(x$CIbounds[2,i], 3)), 
              sprintf("%11.3f ", round(x$CIbounds[1,i], 3))
              , sep = "")); 
    cat("\n")
    
  }
  
  cat("\n")
  
if(x$threshold.type != "marker"){
  cat(paste0("threshold c: ",x$threshold.type, "(c) = ",  x$threshold, "\n"))
}else{
  cat(paste0("marker threshold: c = ",  x$threshold, "\n"))
}
cat("\n")
cat("Information for ROC curve found in x$roc.")
  
  
}
mdbrown/survAccuracyMeasures documentation built on May 22, 2019, 3:23 p.m.