R/functionFactory_Covariance.R

Defines functions covarianceFactory

Documented in covarianceFactory

covarianceFactory <- function(covariance, cov.args = list()){

  #######################################################################
  # Run checks
  # [Note: reasonable to allow specifying function by character argument?]
  #----------------------------------------------------------------------

  covariance <- tryCatch(match.fun(covariance),
                         error = function(cond){
                           stop("Covariance function does not exist",
                                "or is not a valid function.")
  })

  fixed_range  <- cov.args[["fixed_range_value"]]
  fixed_nugget <- cov.args[["fixed_nugget_value"]]


  #######################################################################
  # Function blueprint
  #----------------------------------------------------------------------
  covarianceFunction <- function(h, theta, ...) {

    theta <- c(fixed_range, theta, fixed_nugget)
    result <- covariance(h = h, theta = theta, ..., cov.args = cov.args)

    return(result)
  }

  return(covarianceFunction)
}

Try the GeneralizedWendland package in your browser

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

GeneralizedWendland documentation built on June 22, 2022, 9:06 a.m.