R/convCheck.R

Defines functions convCheck.absolute convCheck.square convCheck.relative

Documented in convCheck.absolute convCheck.relative convCheck.square

# =========== Convergence checks for weight functions ===========

#'Convergence checks
#'
#'The convergence check functions compare two weight matrices and returns the value of the
#'convergence criterion describing the difference between the two weight matrices.
#'
#'@param Wnew Current weight matrix
#'@param Wold Weight matrix from the previous iteration
#'
#'@return Scalar value of the convergence criterion
#'
#'@name convCheck
NULL


#'@describeIn convCheck  maximum of relative differences between
#'weights from two iterations
#'
#'@export
convCheck.relative <- function(Wnew, Wold){
  max(abs((Wold[Wnew != 0]-Wnew[Wnew != 0])/Wnew[Wnew != 0]))
}

#'@describeIn convCheck maximum of squared absolute 
#'differences between weights from two iterations.
#'
#'@export

convCheck.square <- function(Wnew, Wold){
  max((Wold-Wnew)^2)
}

#'@describeIn convCheck maximum of absolute differences
#'between weights from two iterations
#'
#'@export


convCheck.absolute <- function(Wnew, Wold){
  max(abs(Wold-Wnew))
}

Try the matrixpls package in your browser

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

matrixpls documentation built on April 28, 2021, 5:07 p.m.