0

I am trying to simulate a data based on multivariate linear mixed effects model by using package lme in R. The data is

> 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
> 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  

Then divided the data depends on outcome variable by using melt function such:

> 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

The model is

f1 <- 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)

each response has intercepts and slopes (fixed and random effects). But I got an error :

Error in logLik.reStruct(object, conLin) : 
  NA/NaN/Inf in foreign function call (arg 3)

I am not sure what does it mean and how to solve it?

alexwhitworth
  • 4,839
  • 5
  • 32
  • 59
R. Saeiti
  • 89
  • 3
  • 11
  • This usually means an overfitted/unstable model. Probably can't answer without a reproducible example. Can you at least give more information about number of observations, number of `pat` groups, which predictors are factors and how many levels they have ... ? – Ben Bolker Jan 20 '16 at 14:22
  • see e.g. http://stackoverflow.com/questions/16488736/r-error-in-lme-function-na-nan-inf-in-foreign-function-call-arg-3 – Ben Bolker Jan 20 '16 at 14:24
  • Thanks Ben, I will add more information. – R. Saeiti Jan 20 '16 at 14:32
  • (1) are `cs_d0` and `va_d0` in your data set the same as `cs_d1` and `va_d1` in your data set? (2) it might be worth trying this in lme4 - the varIdent call can be mimicked by adding a random effect `(0+cs_d1|observation)` to the model ... – Ben Bolker Jan 20 '16 at 15:01
  • (1) yes there are the same. I will try 'lmer4' to run the data. (2) the varIdent call can be mimicked by adding a random effect (0+cs_d1|observation)? what is observation here?? – R. Saeiti Jan 21 '16 at 07:25

0 Answers0