title: lme: NA/NaN/Inf in foreign function call (arg 3)
body: <p>I am trying to simulate a data based on multivariate linear mixed effects model by using package <code>lme</code> in <code>R</code>. The data is </p>
  
  <pre><code>&gt; data_simO[1:10,]
     pat time outcome       csse         vase
  1    1    0       0   35.94075  -0.08586536
  2    1    3       0   29.98295  -3.84084267
  3    1    6       0   24.80345  -7.95054467
  4    1    9       0   18.05502 -11.85375518
  5    2    0       0   35.78939  -0.39146190
  6    2    3       0  -24.13811  22.92276577
  7    2    6       0  -84.15957  46.32400538
  8    2    9       0 -144.33715  69.66958083
  9    3    0       0   36.47212   0.10686316
  10   3    3       0   72.50521  -5.72415186
  &gt; summary(data_simO)
        pat              time      outcome       csse               vase         
   Min.   :   1.0   Min.   :0.00   0:7080   Min.   :-367.196   Min.   :-209.065  
   1st Qu.: 750.8   1st Qu.:2.25   1:4920   1st Qu.:   9.851   1st Qu.:  -5.114  
   Median :1500.5   Median :4.50            Median :  35.694   Median :   4.866  
   Mean   :1500.5   Mean   :4.50            Mean   :  30.655   Mean   :  14.661  
   3rd Qu.:2250.2   3rd Qu.:6.75            3rd Qu.:  55.881   3rd Qu.:  43.773  
   Max.   :3000.0   Max.   :9.00            Max.   : 404.946   Max.   : 250.006  
  </code></pre>
  
  <p>Then divided the data depends on outcome variable  by using <code>melt</code> function such:</p>
  
  <pre><code>&gt; D0Train[1:10,]
     pat time outcome variable      value cs_d0 va_d0
  1   11    0       0     csse  37.101886     1     0
  2   11    3       0     csse  12.117602     1     0
  3   11    6       0     csse -12.678002     1     0
  4   11    9       0     csse -36.600898     1     0
  5   13    0       0     csse  36.254159     1     0
  6   13    3       0     csse  27.938812     1     0
  7   13    6       0     csse  18.471065     1     0
  8   13    9       0     csse   9.552347     1     0
  9   14    0       0     csse  35.605628     1     0
  10  14    3       0     csse  43.438193     1     0
  </code></pre>
  
  <p>The model is</p>
  
  <pre><code>f1 &lt;- lme(value ~-1+ cs_d1 + va_d1 + time:cs_d1 + time:va_d1,
  +        random =  ~ -1 + (cs_d1 + va_d1) + time:( cs_d1 + va_d1)|pat,  weights=varIdent(form=~1| cs_d1)
  +       ,control=lmeControl(maxIter=100,returnObject=TRUE,singular.ok=TRUE, opt="optim"), data =D1Train)
  </code></pre>
  
  <p>each response has intercepts and slopes (fixed and random effects). But I got an error :</p>
  
  <pre><code>Error in logLik.reStruct(object, conLin) : 
    NA/NaN/Inf in foreign function call (arg 3)
  </code></pre>
  
  <p>I am not sure what does it mean and how to solve it?</p>