3
$\begingroup$

I am fitting a random slope and random intercept model using R. I used both lme and lmer funciton for the same model. However I got different results as shown below (different variance component estimates and so on). I think that is really confusing. They should produce close results. Anyone has any thoughts or suggestions. Also, which one should be comparable to sas results? Thanks! Hanna

## using lme function
> mod_lme <- lme(ti  ~ type*months, random=~ 1+months|lot, na.action=na.omit,
+ data=one, control = lmeControl(opt = "optim"))
> summary(mod_lme)
Linear mixed-effects model fit by REML
 Data: one
        AIC       BIC   logLik
  -82.60042 -70.15763 49.30021

Random effects:
 Formula: ~1 + months | lot
 Structure: General positive-definite, Log-Cholesky parametrization
            StdDev       Corr
(Intercept) 8.907584e-03 (Intr)
months      6.039781e-05 -0.096
Residual    4.471243e-02

Fixed effects: ti ~ type * months
                 Value   Std.Error DF   t-value p-value
(Intercept)     0.25831245 0.016891587 31 15.292373  0.0000
type            0.13502089 0.026676101  4  5.061493  0.0072
months          0.00804790 0.001218941 31  6.602368  0.0000
type:months -0.00693679 0.002981859 31 -2.326329  0.0267
 Correlation:
               (Intr) typPPQ months
type           -0.633
months         -0.785  0.497
type:months  0.321 -0.762 -0.409

Standardized Within-Group Residuals:
          Min            Q1           Med            Q3           Max
-2.162856e+00 -1.962972e-01 -2.771184e-05  3.749035e-01  2.088392e+00

Number of Observations: 39
Number of Groups: 6

And:

###Using lmer function
> mod_lmer <-lmer(ti  ~ type*months+(1+months|lot), na.action=na.omit, data=one)
> summary(mod_lmer)
Linear mixed model fit by REML t-tests use Satterthwaite approximations to
  degrees of freedom [merModLmerTest]
Formula: ti ~ type * months + (1 + months | lot)
   Data: one

REML criterion at convergence: -98.8

Scaled residuals:
    Min      1Q  Median      3Q     Max
-2.1347 -0.2156 -0.0067  0.3615  2.0840

Random effects:
 Groups   Name        Variance  Std.Dev.  Corr
 lot      (Intercept) 2.870e-04 0.0169424
          months      4.135e-07 0.0006431 -1.00
 Residual             1.950e-03 0.0441644
Number of obs: 39, groups:  lot, 6

Fixed effects:
                Estimate Std. Error        df t value Pr(>|t|)
(Intercept)     0.258312   0.018661  4.820000  13.842 4.59e-05 ***
type            0.135021   0.028880  6.802000   4.675  0.00245 **
months          0.008048   0.001259 11.943000   6.390 3.53e-05 ***
type:months    -0.006937   0.002991 28.910000  -2.319  0.02767 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr) typPPQ months
type        -0.646
months      -0.825  0.533
type:month   0.347 -0.768 -0.421
$\endgroup$
1
$\begingroup$

The fits are not massively different. Your fixed effects are essentially the same; their correlations are not too different either. The variance components in the case of lmer are evidently not successfully estimated. Look at their correlation, -1? That is clear singularity that is quite possibly due to the fact that the variance of your months effects is orders of magnitude smaller than the variance due to lot or the general Residual.

You do not say which lme4 version you are using. Try changing the optimizer used; go from "bobyqa" to "Nelder_Mead" or vice versa. This may alleviate the issue you experience. Also take in account that you have just 39 observations and you are estimating 7+ parameters, you are almost destined to hit local minima and/or over-fit (unfortunately).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.