John Sorkin
2016-Aug-25 14:48 UTC
[R] nlme: fewer observations than random effects in all level 1 groups
I am getting a warning message when I run lme: Warning message: In lme.formula(fixed = value ~ CorT + time + CorT * time, data = GD) : fewer observations than random effects in all level 1 groups I don't know what the message means, nor if I need to be concerned about the message. I would be grateful if someone could explain the message to me, and tell me if I need to have concern. My data and code follows. You should be able to copy, paste and run the code. (n.b. you will need nlme). Thank you, John library(nlme) data10 <- structure(list(SS = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L), group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Cont", "Inte"), class = "factor"), time = c(0L,0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L), value = c(2, 1, 3, 6, 1, 5, 4, 4, 3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, 7.86633577663451, 14.8276520497166, 5.82301333779469, 6.28030818421394, 7.63550981180742, 7.12941627483815, 14.4640282960609, 8.45473791006953, 9.05422623036429, 10.3654135158285, 7.75828687706962, 9.05671408865601, 9.35509188333526, 8.22054158896208, 5.03435689257458, 14.7296907380223, 6.12912589916959, 10.4857219522819, 13.7229738035239, 13.6259456002153, 7.28073637914354, 5.54352982843898, 8.01713229269774, 13.2061931600758, 3.76887153466896, 10.7523541087606, 9.6018583095559, 9.62481826991277, 8.90923221009558, 8.85276119502607, 10.9778885179292, 13.4521386035968, 9.95012926745246, 7.78767098907235, 5.47606805783807, 16.266090481022, 8.10664718517709, 3.98960108796381, 10.1788924241439, 9.16177207287154, 11.6541174116198, 19.055363149052, 10.4729343696394, 12.9615216852694, 10.3448541992752, 12.1246619594601, 17.9078516870675, 14.1546013378432, 14.3556335566072, 13.7020998307993, 12.2669613611438, 13.6968944583291, 16.0242423205925, 14.1618907899469, 11.6571628686932, 20.6208065318508, 10.5981108892906, 16.506205140693, 19.8382587955876, 18.8215423103255, 13.6293066791555, 10.679427547606, 14.5715854764237, 18.0672964438053, 8.64819129644325, 16.5046323205086, 14.933146372713, 13.0224731390702, 13.1364074268251, 12.7299140722498, 16.3687231173825, 17.3307585790136, 14.8835947338426, 13.7832964561028, 8.18806783970065, 20.4643754783345, 13.927444172043, 7.95214003187942, 15.8500600646401, 14.863828811346, 16.3418851303983, 23.9363727442689, 15.6973592017088, 16.8376901116903, 16.4265975193717, 18.3862045830691, 23.7260777608949, 19.6736595029528, 18.7411384574001, 21.5299075269243, 18.7672717818268, 18.6586905356669, 20.1908194122778, 19.6037057845507, 16.2952035024787, 25.2275624425201, 15.7628539929276, 21.2326533842687, 25.3146615100186, 24.5526929132951), baseline = c(2, 1, 3, 6, 1, 5, 4, 4, 3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, 7.86633577663451, 14.8276520497166, 5.82301333779469, 6.28030818421394, 7.63550981180742, 7.12941627483815, 14.4640282960609, 8.45473791006953, 9.05422623036429, 10.3654135158285, 7.75828687706962, 9.05671408865601, 9.35509188333526, 8.22054158896208, 5.03435689257458, 14.7296907380223, 6.12912589916959, 10.4857219522819, 13.7229738035239, 13.6259456002153, 2, 1, 3, 6, 1, 5, 4, 4, 3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, 7.86633577663451, 14.8276520497166, 5.82301333779469, 6.28030818421394, 7.63550981180742, 7.12941627483815, 14.4640282960609, 8.45473791006953, 9.05422623036429, 10.3654135158285, 7.75828687706962, 9.05671408865601, 9.35509188333526, 8.22054158896208, 5.03435689257458, 14.7296907380223, 6.12912589916959, 10.4857219522819, 13.7229738035239, 13.6259456002153, 2, 1, 3, 6, 1, 5, 4, 4, 3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, 7.86633577663451, 14.8276520497166, 5.82301333779469, 6.28030818421394, 7.63550981180742, 7.12941627483815, 14.4640282960609, 8.45473791006953, 9.05422623036429, 10.3654135158285, 7.75828687706962, 9.05671408865601, 9.35509188333526, 8.22054158896208, 5.03435689257458, 14.7296907380223, 6.12912589916959, 10.4857219522819, 13.7229738035239, 13.6259456002153), CorT = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), row.names = c(NA, -120L), .Names = c("SS", "group", "time", "value", "baseline", "CorT"), class = "data.frame") data10 GD2<- groupedData(value~time+CorT+time*CorT|SS,data=data10,FUN=mean) fit1 <- lme(GD2) summary(fit1) John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
Thierry Onkelinx
2016-Aug-26 08:29 UTC
[R] nlme: fewer observations than random effects in all level 1 groups
Dear John, Please send questions on mixed models to r-sig-mixedmodels. Your model is too complex for the data. You're fitted time*CorT as random slopes. These random effects require 10 parameters. But you have only 4 data points per level of SS. Furthermore within each level of SS only one level of CorT exists. So fitting the time:CorT interaction as random slope is nonsens. So you need to simplify of the model (or get more data). An intercept only random effect is about of far as you can go with this dataset. A random slope along time is doable but I won't trust it since you are fitting a model to only 4 points. fit1 <- lme(value ~ time * CorT, random = ~1|SS, data = data10) fit2 <- lme(value ~ time * CorT, random = ~time|SS, data = data10) 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 2016-08-25 16:48 GMT+02:00 John Sorkin <jsorkin at grecc.umaryland.edu>:> I am getting a warning message when I run lme: > > Warning message: > In lme.formula(fixed = value ~ CorT + time + CorT * time, data = GD) : > fewer observations than random effects in all level 1 groups > I don't know what the message means, nor if I need to be concerned about > the message. I would be > grateful if someone could explain the message to me, and tell me if I need > to have concern. > My data and code follows. You should be able to copy, paste and run the > code. (n.b. you will need nlme). > Thank you, > John > > library(nlme) > data10 <- structure(list(SS = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, > 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, > 21L, 22L, 23L, > 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, > 34L, 35L, 36L, > 37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, > 9L, 10L, > 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, > 21L, 22L, 23L, > 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, > 34L, 35L, 36L, > 37L, 38L, 39L, 40L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, > 9L, 10L, > 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, > 21L, 22L, 23L, > 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, > 34L, 35L, 36L, > 37L, 38L, 39L, 40L), > group = structure(c(1L, 1L, 1L, 1L, 1L, > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > 1L, 1L, 2L, > 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, > 2L, 2L, 2L, > 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > 1L, 1L, 1L, > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, > 2L, 2L, 2L, > 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, > 1L, 1L, 1L, > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > 1L, 1L, 2L, > 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, > 2L, 2L, 2L, > 2L, 2L, 2L), .Label = c("Cont", "Inte"), class > "factor"), > time = c(0L,0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, > 0L, 0L, 0L, 0L, 0L, 0L, > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, > 0L, 0L, 0L, > 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 3L, 3L, 3L, 3L, 3L, > 3L, 3L, 3L, > 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, > 3L, 3L, 3L, > 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, > 3L, 3L, 6L, > 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, > 6L, 6L, 6L, > 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, > 6L, 6L, 6L, > 6L, 6L, 6L, 6L, 6L, 6L, 6L), > value = c(2, 1, 3, 6, 1, 5, 4, 4, > 3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, > 7.86633577663451, 14.8276520497166, > 5.82301333779469, 6.28030818421394, > 7.63550981180742, 7.12941627483815, > 14.4640282960609, 8.45473791006953, > 9.05422623036429, 10.3654135158285, > 7.75828687706962, 9.05671408865601, > 9.35509188333526, 8.22054158896208, > 5.03435689257458, 14.7296907380223, > 6.12912589916959, 10.4857219522819, > 13.7229738035239, 13.6259456002153, > 7.28073637914354, 5.54352982843898, > 8.01713229269774, 13.2061931600758, > 3.76887153466896, 10.7523541087606, > 9.6018583095559, 9.62481826991277, 8.90923221009558, > 8.85276119502607, > 10.9778885179292, 13.4521386035968, > 9.95012926745246, 7.78767098907235, > 5.47606805783807, 16.266090481022, 8.10664718517709, > 3.98960108796381, > 10.1788924241439, 9.16177207287154, > 11.6541174116198, 19.055363149052, > 10.4729343696394, 12.9615216852694, > 10.3448541992752, 12.1246619594601, > 17.9078516870675, 14.1546013378432, > 14.3556335566072, 13.7020998307993, > 12.2669613611438, 13.6968944583291, > 16.0242423205925, 14.1618907899469, > 11.6571628686932, 20.6208065318508, > 10.5981108892906, 16.506205140693, > 19.8382587955876, 18.8215423103255, > 13.6293066791555, 10.679427547606, > 14.5715854764237, 18.0672964438053, > 8.64819129644325, 16.5046323205086, > 14.933146372713, 13.0224731390702, 13.1364074268251, > 12.7299140722498, > 16.3687231173825, 17.3307585790136, > 14.8835947338426, 13.7832964561028, > 8.18806783970065, 20.4643754783345, 13.927444172043, > 7.95214003187942, > 15.8500600646401, 14.863828811346, 16.3418851303983, > 23.9363727442689, > 15.6973592017088, 16.8376901116903, > 16.4265975193717, 18.3862045830691, > 23.7260777608949, 19.6736595029528, > 18.7411384574001, 21.5299075269243, > 18.7672717818268, 18.6586905356669, > 20.1908194122778, 19.6037057845507, > 16.2952035024787, 25.2275624425201, > 15.7628539929276, 21.2326533842687, > 25.3146615100186, 24.5526929132951), > baseline = c(2, 1, 3, 6, > 1, 5, 4, 4, 3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, > 7.86633577663451, > 14.8276520497166, 5.82301333779469, > 6.28030818421394, 7.63550981180742, > 7.12941627483815, 14.4640282960609, > 8.45473791006953, 9.05422623036429, > 10.3654135158285, 7.75828687706962, > 9.05671408865601, 9.35509188333526, > 8.22054158896208, 5.03435689257458, > 14.7296907380223, 6.12912589916959, > 10.4857219522819, 13.7229738035239, > 13.6259456002153, 2, 1, 3, > 6, 1, 5, 4, 4, 3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, > 7.86633577663451, > 14.8276520497166, 5.82301333779469, > 6.28030818421394, 7.63550981180742, > 7.12941627483815, 14.4640282960609, > 8.45473791006953, 9.05422623036429, > 10.3654135158285, 7.75828687706962, > 9.05671408865601, 9.35509188333526, > 8.22054158896208, 5.03435689257458, > 14.7296907380223, 6.12912589916959, > 10.4857219522819, 13.7229738035239, > 13.6259456002153, 2, 1, 3, > 6, 1, 5, 4, 4, 3, 4, 5, 8, 4, 4, 0, 10, 3, 0, 4, 6, > 7.86633577663451, > 14.8276520497166, 5.82301333779469, > 6.28030818421394, 7.63550981180742, > 7.12941627483815, 14.4640282960609, > 8.45473791006953, 9.05422623036429, > 10.3654135158285, 7.75828687706962, > 9.05671408865601, 9.35509188333526, > 8.22054158896208, 5.03435689257458, > 14.7296907380223, 6.12912589916959, > 10.4857219522819, 13.7229738035239, > 13.6259456002153), > CorT = c(0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, > 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, > 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), > row.names = c(NA, > -120L), .Names = c("SS", "group", "time", "value", > "baseline", > "CorT"), class = "data.frame") > data10 > > GD2<- groupedData(value~time+CorT+time*CorT|SS,data=data10,FUN=mean) > fit1 <- lme(GD2) > summary(fit1) > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for ...{{dropped:16}}