Skip to content

Different random intercepts but same random slope for groups

8 messages · Thierry Onkelinx, Bert Gunter, Ken Beath +2 more

#
Hi all,
  I'd like to fit a random intercept and random slope model. In my
data, there are three groups. I want to have different random
intercept for each group but the same random slope effect for all
three groups. I used the following R command.
However, there seems to be some problem. Any suggestions?



mod2 <- lmer(result  ~ group*time+(0+group1+ group2 +
group3+time|lot), na.action=na.omit, data=alldata)
Model is not identifiable...
summary from lme4 is returned
some computational error has occurred in lmerTest
Linear mixed model fit by REML ['merModLmerTest']
Formula: result ~ group * time + (0 + group1 + group2 + group3 + time |
    lot)
   Data: alldata

REML criterion at convergence: 807.9

Scaled residuals:
    Min      1Q  Median      3Q     Max
-3.0112 -0.3364  0.0425  0.2903  3.2017

Random effects:
 Groups   Name     Variance Std.Dev. Corr
 lot      group1   0.00000 0.000
          group2   86.20156 9.284      NaN
          group3 55.91479 7.478      NaN  0.06
          time      0.02855 0.169      NaN -0.99  0.10
 Residual          39.91968 6.318
Number of obs: 119, groups:  lot, 15

Fixed effects:
                            Estimate Std. Error t value
(Intercept)                 100.1566     2.5108   39.89
group  group2        -2.9707     3.7490   -0.79
group  group3           -0.0717     2.8144   -0.03
time                         -0.1346     0.1780   -0.76
group  group2 :time   0.1450     0.2939    0.49
group  group3:time        0.1663     0.2152    0.77

Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 0.147314 (tol = 0.002, component 2)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 2 negative eigenvalues
#
Your model is too complex for the data. This gives you two options: a)
simplify the model and b) get more data.

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-06-09 21:57 GMT+02:00 li li <hannah.hlx at gmail.com>:

  
  
#
Thierry:

I don't think so. It looks to me like her syntax/understanding is confused.
I think the call should be:

mod2 <- lmer(result  ~ group*time+(group + time|lot), na.action=na.omit,
data=alldata)

Her request for "the same random slope for each group" -- I assume it's for
time -- means to me that the time slope will vary "randomly" by lot only,
the slope would be the same for all groups within the lot.

Of course, I may be wrong also. If so, I suggest that she follow the
posting guide and post at least head(alldata) using dput() to enable folks
to understand the structure of her data. And only on r-sig-mixed-models --
crossposting is frowned upon here and the mixed models list is the best bet
for this sort of question anyway.

As always, corrections and criticism welcome.

Cheers,
Bert

Bert Gunter

"Data is not information. Information is not knowledge. And knowledge is
certainly not wisdom."
   -- Clifford Stoll

On Tue, Jun 9, 2015 at 1:49 PM, Thierry Onkelinx <thierry.onkelinx at inbo.be>
wrote:

  
  
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

  I don't understand your model specification.  What do you mean,
precisely, by "a different random intercept for each group but the
same random slope effect for all three groups"?  That sounds a lot
like a random intercept model? Do you mean that you want to specify a
single random-effects *variance* among slopes for all lots (regardless
of group) but different among-lot intercept variances for each group?

  If group1, group2, group3 are numeric dummy variables, then

lmer(result  ~ group*time+(0+time|lot) + (group1|lot) + (group2|lot) +
(group3|lot), data=alldata)

might work.

  That said, Thierry may still be right.  You have 15 groups and are
trying to fit 3 separate intercept-variance parameters ...
On 15-06-09 04:49 PM, Thierry Onkelinx wrote:
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJVd2PnAAoJEOCV5YRblxUHmRoH/22AjJ5RyFl3YEOeJ4/YerMf
byc8etuVyjX/QpB5VG5XidwdaLCb9tf98SttwR9iWKeYUB6sm+UEtPhzmhNuQVSS
O1aL8XgiTuoK0kNy1W8h7ZJovbaTeEl1FLy2sQ3ma5sRMvxfG30FZXI99NgvdLZf
qhClz3egICgwa7sz4DiT/UwPjvbgY993ZEKhjiWpzu2Zgy6HPVo1GrT/OKEqJwdD
4gczHoAOMkGdc38c+br1AmgPK1Me+Gc/OoZ2gQwniSTpTN0lrluvs3l6Y20/zVjD
0CmvQ+hSKkpPLWRENWGMwBlNpzINXMc+OXcE+LIqaxTuCWFOu9uh78ZjyD8EaHA=
=9aTo
-----END PGP SIGNATURE-----
#
Why not

mod2 <- lmer(result  ~ group*time+(1+time|lot), na.action=na.omit,
data=alldata)

This gives different slopes by group but same random effect variance for
all lots, which I think is what you actually want. A random intercept must
always be included with a random slope (there are probably exceptions but I
can't think of any).
On 10 June 2015 at 08:08, Ben Bolker <bbolker at gmail.com> wrote:

            

  
    
#
Thanks all for the reply,

I think what Bert specified is what I wanted. Thanks very much.
So this model allows different random intercept term but the same
random slope term for the three methods.

I have an additional question. I would like to require differnt
residual variance also for the three groups. Is that possible?

Thanks!!

2015-06-09 17:25 GMT-04:00, Bert Gunter <bgunter.4567 at gmail.com>:
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Li li: *please* stop cc'ing r-help on the reply.

  If group2 and group3 are numeric dummy variables you can add a
difference in the residual variance as follows ...

  alldata$obs <- factor(seq(nrow(alldata)))

  ... + (group2|obs) + (group3|obs) + ...

 you may need to use lmerControl() to override some of the
warnings/errors about having as many levels of the random effect as
there are observations.

  Or you could do this in lme and use weights=varIdent(form=~1|group)
On 15-06-10 12:40 PM, li li wrote:
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJVeGmOAAoJEOCV5YRblxUH+sQIANQ/wAdPE8ERp95iEKqmpK2B
FFCL7pBIGbO/mEry3GHk57v9h5QR0FhFwsRClJ6zrxXDCpsRW4juaulsqXGQog5Q
aI6WwMyime/pdIQgSozKCTVnpPBPWY6BNs9ZWcR1zwt6oPnwBGtDEcfKS2I6c2cw
Zi0OIoWf8xbD9Oujup7WrLG3RCPu/nS+UlaNxl/h6sFM7dHzhXXDsbaS9B2rwY3n
lkmE+bbHb6UuZJ7NVA5B+F17av7GeTF5F+M6AHH8z5XutnLHCb74CFgpsaCZkQo0
fMdOYAVmcp1hXAaGVsi6nBTXiomnGqfOGmbzCwSw5vQvzy8XCpeh1AUWpxwnugE=
=9z6N
-----END PGP SIGNATURE-----
#
2015-06-10 12:45 GMT-04:00, Ben Bolker <bbolker at gmail.com>: