title: Confidence interval of random effects with lmer
body: <p>I am using <code>lmer</code> from <code>lme4</code> package to calculate confidence interval for variance component .</p>
  <p>When I fit the model there is warning messages :</p>
  <pre><code>fit &lt;- lmer(Y~X+Z+X:Z+(X|group),data=sim_data)
  Warning messages:
  1: In checkConv(attr(opt, &quot;derivs&quot;), opt$par, ctrl = control$checkConv,  :
    unable to evaluate scaled gradient
  2: In checkConv(attr(opt, &quot;derivs&quot;), opt$par, ctrl = control$checkConv,  :
    Model failed to converge: degenerate  Hessian with 1 negative eigenvalues
  </code></pre>
  <p>I searched a lot to understand why does the error occur and finally come to a decision that <code>there is difference between error and warning in the R world</code> .</p>
  <p>I want to compute confidence interval for the model parameters and run the code which shows error :</p>
  <pre><code> confint.merMod(fit,oldNames=FALSE)
   Computing profile confidence intervals ...
   Error in if (all(x[iu &lt;- upper.tri(x)] == 0)) t(x[!iu]) else t(x)[!iu] : 
   missing value where TRUE/FALSE needed
  </code></pre>
  <p>Is there another way to obtain CI of random effects with lmer?</p>
  <h2>EDIT :</h2>
  <pre><code>simfun &lt;- function(J,n_j,g00,g10,g01,g11,sig2_0,sig01,sig2_1){
      N &lt;- sum(rep(n_j,J))  
      x &lt;- rnorm(N)         
      z &lt;- rnorm(J)        
  
      mu &lt;- c(0,0)
      sig &lt;- matrix(c(sig2_0,sig01,sig01,sig2_1),ncol=2)
      u   &lt;- rmvnorm(J,mean=mu,sigma=sig)
  
      b_0j &lt;- g00 + g01*z + u[,1]
      b_1j &lt;- g10 + g11*z + u[,2]
  
      y &lt;- rep(b_0j,each=n_j)+rep(b_1j,each=n_j)*x + rnorm(N,0,0.5)
      data &lt;- data.frame(Y=y,X=x,Z=rep(z,each=n_j),group=rep(1:J,each=n_j))
    } 
  
  noncoverage &lt;- function(J,n_j,g00,g10,g01,g11,sig2_0,sig01,sig2_1){
      dat &lt;- simfun(J,n_j,g00,g10,g01,g11,sig2_0,sig01,sig2_1)
      fit &lt;- lmer(Y~X+Z+X:Z+(X|group),data=dat)
   }
  
  comb1 = replicate(1000,noncoverage(10,5,1,.3,.3,.3,(1/18),0,(1/18)))
  comb26 = replicate(1000,noncoverage(100,50,1,.3,.3,.3,(1/8),0,(1/8)))
  </code></pre>