[R] different results from lme and lmer function
li li
hannah.hlx at gmail.com
Wed May 27 01:09:39 CEST 2015
Hi all,
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
###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
More information about the R-help
mailing list