R/covariance2weights.R

Defines functions covariance2weights

# This does not verify that a matrix input for x is diagonal.
covariance2weights <- function(x, n){
  stopifnot(is.numeric(x))
  if(isTRUE(length(x) == 1)){
    output <- rep(x, times = n)
  } else {
    if(isTRUE(is.matrix(x))){
      output <- diag(x)
    } else {
      stopifnot(length(x) == n)
      output <- x
    }
  }
  return(output)
}

Try the distfreereg package in your browser

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

distfreereg documentation built on April 4, 2025, 12:30 a.m.