R/plotLoss.R

Defines functions plotLoss.default plotLoss.rlm plotLoss

Documented in plotLoss plotLoss.default plotLoss.rlm

#' @title plotLoss: Plot loss vs iteration graph
#' @description Plot the result of loss function vs number of iterations.
#' @export
#' @importFrom graphics plot
plotLoss <- function(object) UseMethod("plotLoss")

#' @describeIn plotLoss Plot loss vs iteration of rlm object
#' @method plotLoss rlm
#' @param object an object of class rlm
#' @param ... other arguments
#' @export
plotLoss.rlm <- function(object, ...) {
  if(length(object$loss_iter)){
    plot(object$loss_iter$iter, object$loss_iter$loss, type='b', xlab='iter', ylab='loss function')
  } else {
    print("No residuals\n")
  }
}

#' @describeIn plotLoss Plot loss vs iteration
#' @export
plotLoss.default <- function(object, ...) {
  if(length(object$loss_iter)){
    plot(object$loss_iter$iter, object$loss_iter$loss, type='b', xlab='iter', ylab='loss function')
  } else {
    print("No residuals\n")
  }
}

Try the rcane package in your browser

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

rcane documentation built on June 4, 2018, 5:04 p.m.