R/algorithms__knots_check_boundary.R

Defines functions knots_check_boundary

Documented in knots_check_boundary

#' Boundary check for the moving knots model

#' It is easy to check with in 2D. But how to manage it in >3D space.  Check if weather
#' each dim if fit.  The usual way shoud be check if new convex hull is same as the old
#' convex hull by adding new data in. But that is always time comsumming. But if we know
#' the boundary of each dimmesion, that can be easier.
#' @param P4X NA
#' @param method "character"
#' @param ... Input with respect to different methods.
#' @return "character" "ok": the knots are at good position. "bad": bad knots locations.
#' @author Feng Li, Department of Statistics, Stockholm University, Sweden.
#' @export
knots_check_boundary <- function(P4X, method = "singular")
  {
    ## Check if the design matrix is singular
    ## Very hight tolerance but efficient.
    if(tolower(method) ==  "singular")
      {
        if(missing(P4X))
          {
            stop("Missing input \"P4X\" (X'X where X is the design matrix)")
          }
        singular <- is.singular(P4X)
        if(any(TRUE  == singular))
          {
            out <- "bad"
          }
        else
          {
            out <- "ok"
          }
      }
    else if (tolower(method) ==  "simple")
      { ## FIXME: This is far from perfect. but very fast.
      }
    else if(tolower(method) == "mv")
      {
        ## Villani's Suggestion
        ## Time consuming
      }

    return(out)
  }
feng-li/movingknots documentation built on March 30, 2021, 11:58 a.m.