How to generate a bounded random correlation matrix? Can anyone suggest a method for generating random correlation matrix with $90\%$ of the off-diagonal entries between $[-0.3, 0.3]$. The other $10\%$ should be larger than $0.3$ or smaller than $-0.3$.
 A: Here's a heuristic that I coded up quickly that seems to do quite well:


*

*Initialize a matrix with 1 on the diagonals.

*Fill out the upper triangular sub-matrix according to your distribution (90% are uniform on (-.3,.3) and 10% outside that).

*Make the matrix symmetric.

*Now iterate between

*

*Project the matrix onto the PSD cone.

*Project the matrix onto the set of matrices with diagonal 1.


*Alternating projections converges, so we just hope that the matrix we get out has values according to your distribution (see simulation for the check).



   pickone <- function(x){
  if(runif(1)<.9){
    return(runif(1,-.3,.3))
  } else {
    return(sample(c(-1,1),1)*runif(1,.3,1))
  }
}

generateMat <- function(x){
  X <- matrix(0,nrow=10,ncol=10)
  diag(X) <- rep(1,10)
  X[upper.tri(X)] <- sapply(1:45,pickone)
  X <- X + t(X)-diag(rep(1,10))
  Xnew <- X

  for(i in 1:50){
    eig <- eigen(Xnew)
    ##project onto the PSD cone
    Xnew <- eig$vectors%*%diag(sapply(eig$values,max,0))%*%t(eig$vectors)
    ##project onto the set of matrices with diagonal 1
    diag(Xnew) <- rep(1,10)
  }

  vals <- Xnew[upper.tri(Xnew)]
  return(mean(vals < .3 & vals > -.3))
}

summary(sapply(1:100,generateMat))

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.7556  0.8667  0.8889  0.8960  0.9333  0.9778


It seems like most of the values after simulating 100 times are close to 90% within (-.3,.3).
A: If all you care about is the proportion of entries between $\pm 0.3$ then sure - generate a random correlation matrix, compute the proportion of entries which are greater than $0.3$ in absolute value, and if there are too many pick some at random and reassign them to random values between $\pm 0.3$. Similarly if there are too few.
Edit: Never you mind, this won't work; see the comments...
A: Here's an older answer to a similar question on SO.   It has some code that you could try/modify:
Similar Question
Some other links:
Forecasting Covariance Matrices
Various Matrix Techniques
Matrix Shrinkage Technique
