R/envKernel.R

Defines functions envKernel

Documented in envKernel

#'@title  Empirical variance-covariance kernels
#'
#'
#' @description Creates an empirical environmental kernel using environmental covariates
#' @author Germano Martins F Costa Neto <germano.cneto@usp.br>
#' @param .dfcov matrix of environmental covariates
#' @keywords genomic prediction
#' @seealso BGGE
#' @seealso envK

envKernel =function(.dfcov){
  if(is.null(.dfcov)){stop("matrix of environmental covariates is missing")}
  if(!is.data.frame(.dfcov)){stop(",dfcov must to be a matrix file")}

  O <- tcrossprod(.dfcov)/ncol(.dfcov)
  H <- crossprod(.dfcov)/nrow(.dfcov)
  O <- O +diag(1E-4,nrow=nrow(.dfcov))
  H <- H +diag(1E-4,nrow=ncol(.dfcov)
  return(list(H=H,O=O))
}
gcostaneto/envirotype documentation built on Feb. 19, 2020, 10:36 p.m.