R/rMSNC.R

Defines functions rMSNC

Documented in rMSNC

rMSNC <-
function(n, mu, Sigma, lambda){
if(is.null(n))
    stop("sample size must be specified")
  if(is.null(mu))
    stop("mu must be specified")
  if(is.null(Sigma))
    stop("Sigma must be specified")
    if(is.vector(Sigma)) Sigma=matrix(Sigma)
  if(is.null(lambda))
    stop("lambda must be specified")
  if(round(n)!=n | n<=0)
    stop("sample size must be a positive integer")      
  if(!is.matrix(mu)) mu<-matrix(mu, ncol=length(mu),nrow=1)
  if (!isSymmetric(Sigma))
        stop("Sigma is not symmetric")
  if (min(eigen(Sigma)$values)<=0)
        stop("Sigma is not a positive-definite matrix")
  if (ncol(Sigma) != ncol(mu))
        stop("The dimension of mu does not agree with the dimension of Sigma")
  if (ncol(Sigma) != length(lambda))
        stop("The dimension of lambda does not agree with the dimension of Sigma")
  if (ncol(mu) != length(lambda))
        stop("The dimension of mu does not agree with the dimension of lambda")
  p<-ncol(Sigma)
    lambda=matrix(lambda,ncol=1)
    delta <- lambda/c(sqrt(1 + t(lambda)%*%lambda))
    y <- matrix(0,n,p)
    for (i in 1:n)
   {
    v<- abs(rnorm(1))
    y[i,] <- c(mu) + matrix.sqrt(Sigma)%*% t(rMSN(1,mu=rep(0,p),Sigma=diag(p),lambda=v*lambda))
  }
    return(y)
  }

Try the skewMLRM package in your browser

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

skewMLRM documentation built on Nov. 24, 2021, 9:07 a.m.