Hello, I have a data set with 80 observations (21 groups) on which I have run an MLM (using lme). I want to extract the coefficients for the intercept from my MLM using:
coefficients(summary(mig1.mlm))$'(Intercept)' This produces a list of 21 intercepts, one for each group. For another test I want to run, I need to know which coefficient corresponds to which group, however, it is not clear to me how the list of intercepts are ordered. Thus, I do not know which group size to assign to each intercept. Does anyone know if there is a set order in which coefficients get listed when using the 'coefficients()' function on an lme object? Is there a way to extract group ID along with these coefficients? I have provided the dput code for reproducing the results of my lme object on a small sample of my data set, which only includes observations for 16 groups. I apologize that the dput code is a bit long, but if I use fewer observations the lme() will not run. structure(list(modelStruct = structure(list(reStruct = structure(list( mig1.data.group.id = structure(c(0.542553815682571, -3.00715767259167, -0.0442257816422898), formula = ~1 + mig1.data.minutes, Dimnames = list( c("(Intercept)", "mig1.data.minutes"), c("(Intercept)", "mig1.data.minutes")), class = c("pdLogChol", "pdSymm", "pdMat"))), .Names = "mig1.data.group.id", settings = c(1, 1, 0, 4), class = "reStruct", plen = structure(3L, .Names = " mig1.data.group.id"))), .Names = "reStruct", settings = c(1, 0, 1, 4), class = c("lmeStructInt", "lmeStruct", "modelStruct" ), pmap = structure(c(TRUE, TRUE, TRUE), .Dim = c(3L, 1L), .Dimnames = list( NULL, "reStruct"))), dims = structure(list(N = 19L, Q = 1L, qvec = c(2, 0, 0), ngrps = structure(c(14L, 1L, 1L), .Names = c(" mig1.data.group.id", "X", "y")), ncol = c(2, 6, 1)), .Names = c("N", "Q", "qvec", "ngrps", "ncol")), contrasts = structure(list(), .Names = character(0)), coefficients = structure(list(fixed = structure(c(0.592247813206646, -0.014327735870407, 0.511918311092002, 0.115144106181435, -0.528777081078343, -0.672133737297911), .Names = c("(Intercept)", "c.group.size", "poly(c.minutes, 2)1", "poly(c.minutes, 2)2", "c.group.size:poly(c.minutes, 2)1", "c.group.size:poly(c.minutes, 2)2" )), random = structure(list(mig1.data.group.id = structure(c(0.0570720466445653, -0.0201731190981803, 0.0799015267182444, -0.031341565397712, -0.0381722036361848, 0.0114736430861277, -0.066744648680322, -0.00465893340911505, 0.020902212048436, 0.103713939575392, 0.0341701969323794, -0.127867324157186, 0.0139879650936152, -0.0322637357200584, 0.000462148038646844, 0.00106241177658854, -0.000443527404792683, 0.000657233443565595, 0.00098128378165296, -0.00165073855689212, -0.000552460717034177, -3.8563057004643e-05, -0.000438319931643705, -0.00268379571707918, -0.000716549920599101, 0.00328705496268145, -0.000204144495804703, 0.000277967797714908 ), .Dim = c(14L, 2L), .Dimnames = list(c("2", "3", "4", "5", "7", "8", "10", "11", "12", "13", "16", "17", "20", "21"), c("(Intercept)", "mig1.data.minutes")))), .Names = " mig1.data.group.id")), .Names = c("fixed", "random")), varFix = structure(c(0.000801580029879769, -4.89031257398402e-06, 0.000560846217563802, 0.00158064241688306, -0.00222841423081078, -0.0013850278556988, -4.89031257398402e-06, 0.000998585707455886, -0.0034436196730218, -0.0015456585682428, 0.00116336495693562, 0.00434765229782492, 0.000560846217563802, -0.0034436196730218, 0.0244392316273714, 0.00996105608959828, -0.00854131836998962, -0.0224942435104164, 0.00158064241688306, -0.0015456585682428, 0.00996105608959828, 0.0158945692774124, -0.0133452835173244, -0.0153057275817998, -0.00222841423081078, 0.00116336495693562, -0.00854131836998962, -0.0133452835173244, 0.0227078394482903, 0.0170647625679209, -0.0013850278556988, 0.00434765229782492, -0.0224942435104164, -0.0153057275817998, 0.0170647625679209, 0.0349630532188317), .Dim = c(6L, 6L), .Dimnames = list(c("(Intercept)", "c.group.size", "poly(c.minutes, 2)1", "poly(c.minutes, 2)2", "c.group.size:poly(c.minutes, 2)1", "c.group.size:poly(c.minutes, 2)2" ), c("(Intercept)", "c.group.size", "poly(c.minutes, 2)1", "poly(c.minutes, 2)2", "c.group.size:poly(c.minutes, 2)1", "c.group.size:poly(c.minutes, 2)2"))), sigma = 0.0524019104240361, apVar = structure(c(0.195521445237494, 0.385341061075355, -0.286676275652333, -0.150058129917539, 0.385341061075355, 3.44522079913615, 0.17521882332131, -0.88335110165811, -0.286676275652333, 0.17521882332131, 2.73770494209246, -0.319576762409392, -0.150058129917539, -0.88335110165811, -0.319576762409392, 0.493177764041453), .Dim = c(4L, 4L), .Dimnames = list(c("reStruct.mig1.data.group.id1", "reStruct.mig1.data.group.id2", "reStruct.mig1.data.group.id3", "lSigma"), c("reStruct.mig1.data.group.id1", "reStruct.mig1.data.group.id2", "reStruct.mig1.data.group.id3", "lSigma")), Pars = structure(c(-2.40625841416319, -5.66195117995023, -1.60981405306962, -2.94881222984576), .Names = c("reStruct.mig1.data.group.id1", "reStruct.mig1.data.group.id2", "reStruct.mig1.data.group.id3", "lSigma")), natural = TRUE), logLik = 11.3100253625345, numIter = NULL, groups = structure(list(mig1.data.group.id = structure(c(5L, 2L, 12L, 1L, 10L, 10L, 7L, 1L, 6L, 8L, 9L, 13L, 2L, 4L, 3L, 6L, 14L, 14L, 11L), .Label = c("2", "3", "4", "5", "7", "8", "10", "11", "12", "13", "16", "17", "20", "21"), class = "factor")), .Names = "mig1.data.group.id", row.names = c("216", "347", "413", "555", "446", "182", "481", "559", "387", "471", "126", "549", "90", "173", "30", "245", "43", "44", "422" ), class = "data.frame"), call = lme.formula(fixed = mig1.data.stnd.alpha ~ c.group.size * poly(c.minutes, 2), data = mig1.small.sample, random = ~1 + mig1.data.minutes | mig1.data.group.id, na.action = "na.exclude"), terms = mig1.data.stnd.alpha ~ c.group.size * poly(c.minutes, 2), method = "REML", fitted = structure(c(0.481069271212693, 0.407996506778899, 0.481069271212693, 0.654207415156227, 0.660323053771328, 0.481069271212693, 0.654207415156227, 0.502826045508831, 0.619699566918199, 0.678669969616632, 0.473185648482867, 0.641692134120051, 0.619699566918199, 0.570206450385443, 0.562812539762185, 0.67376954812038, 0.217915945757991, 0.279144044677716, 0.376164846580292, 0.442897067576508, 0.425007799861318, 0.353201947055507, 0.720522422573729, 0.710361079005136, 0.584783210788085, 0.576413552135221, 0.559898092153396, 0.589904746082024, 0.673239775067424, 0.491896260873085, 0.65363865425562, 0.626086742234732, 0.542151052205559, 0.636061155408539, 0.660482112853126, 0.188431888015082, 0.248270147946232, 0.406752293909676), .Dim = c(19L, 2L), .Dimnames = list( c("216", "347", "413", "555", "446", "182", "481", "559", "387", "471", "126", "549", "90", "173", "30", "245", "43", "44", "422"), c("fixed", "mig1.data.group.id"))), residuals = structure(c(-0.0510692712126929, 0.0420034932211007, -0.171069271212693, 0.105792584843773, 0.0496769462286719, 0.138930728787307, -0.124207415156227, 0.0571739544911692, -0.0696995669181989, -0.00866996961663191, 0.0268143515171326, 0.0183078658799486, -0.019699566918199, -0.040206450385443, 0.117187460237815, 0.0162304518796199, -0.0579159457579912, -0.019144044677716, 0.0438351534197082, -0.0128970675765082, 0.0249922001386821, -0.0432019470555072, 0.0394775774262709, -0.000361079005136378, 0.0352167892119151, -0.0464135521352211, 0.00010190784660391, -0.0399047460820235, -0.00323977506742401, 0.00810373912691509, 0.00636134574438041, -0.0260867422347322, -0.0121510522055589, 0.0439388445914611, 0.029517887146874, -0.0284318880150819, 0.0117298520537678, 0.0132477060903243 ), .Dim = c(19L, 2L), .Dimnames = list(c("216", "347", "413", "555", "446", "182", "481", "559", "387", "471", "126", "549", "90", "173", "30", "245", "43", "44", "422"), c("fixed", "mig1.data.group.id")), std = c(0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361, 0.0524019104240361)), fixDF = structure(list( X = structure(c(12, 12, 1, 1, 1, 1), .Names = c("(Intercept)", "c.group.size", "poly(c.minutes, 2)1", "poly(c.minutes, 2)2", "c.group.size:poly(c.minutes, 2)1", "c.group.size:poly(c.minutes, 2)2" )), terms = structure(c(12, 12, 1, 1), .Names = c("(Intercept)", "c.group.size", "poly(c.minutes, 2)", "c.group.size:poly(c.minutes, 2)" ))), .Names = c("X", "terms"), assign = structure(list( `(Intercept)` = 1L, c.group.size = 2L, `poly(c.minutes, 2)` = 3:4, `c.group.size:poly(c.minutes, 2)` = 5:6), .Names = c("(Intercept)", "c.group.size", "poly(c.minutes, 2)", "c.group.size:poly(c.minutes, 2)" )), varFixFact = structure(c(0.0234727714330888, 0.00308441687443628, -0.00126641961760248, 0.00412548417580657, 0.0129462509558636, 0.00740719592892987, 0, 0.0192212361398047, -0.00494132395826749, -0.000413333499730955, 0.00799450545612366, -0.0232514546681108, 0, 0, 0.0968118427734171, 0.0134638356779811, -0.0203288282252088, 0.120300301736998, 0, 0, 0, 0.0824249430578822, 0.0489931708259258, 0.0818557710350283, 0, 0, 0, 0, -0.119911935622324, -0.0912631751781513, 0, 0, 0, 0, 0, -0.186984098839531), .Dim = c(6L, 6L))), na.action = structure(c(1L, 2L, 3L, 5L, 8L, 23L), .Names = c("172", "497", "250", "147", "82", "249"), class = "exclude"), data = structure(list(mig1.data.stnd.alpha = c(NA, NA, NA, 0.43, NA, 0.45, 0.31, NA, 0.76, 0.71, 0.62, 0.53, 0.56, 0.55, 0.67, 0.5, 0.66, 0.6, 0.53, 0.68, 0.69, 0.16, NA, 0.26, 0.42), c.group.size = c(0.7, -0.3, 1.7, -0.3, -0.3, 0.7, -0.3, 0.7, -1.3, -0.3, -0.3, -1.3, -1.3, 0.7, 2.7, -0.3, 0.7, 0.7, 0.7, -0.3, 0.7, -2.3, 1.7, -2.3, -1.3), c.minutes = c(12.5, 17.5, 7.5, -17.5, 7.5, 17.5, -17.5, 7.5, 2.5, 2.5, -17.5, 2.5, -17.5, 7.5, 2.5, -12.5, -7.5, 7.5, -12.5, -2.5, -2.5, -7.5, 17.5, -12.5, -12.5), mig1.data.minutes = c(30, 35, 25, 0, 25, 35, 0, 25, 20, 20, 0, 20, 0, 25, 20, 5, 10, 25, 5, 15, 15, 10, 35, 5, 5), mig1.data.group.id = c(5L, 14L, 18L, 7L, 17L, 3L, 17L, 5L, 2L, 13L, 13L, 10L, 2L, 8L, 11L, 12L, 20L, 3L, 5L, 4L, 8L, 21L, 18L, 21L, 16L)), .Names = c("mig1.data.stnd.alpha", "c.group.size", "c.minutes", "mig1.data.minutes", "mig1.data.group.id" ), row.names = c(172L, 497L, 250L, 216L, 147L, 347L, 413L, 82L, 555L, 446L, 182L, 481L, 559L, 387L, 471L, 126L, 549L, 90L, 173L, 30L, 245L, 43L, 249L, 44L, 422L), class = "data.frame")), .Names = c("modelStruct", "dims", "contrasts", "coefficients", "varFix", "sigma", "apVar", "logLik", "numIter", "groups", "call", "terms", "method", "fitted", "residuals", "fixDF", "na.action", "data"), class = "lme") -- Chad M. Danyluck, MA PhD Candidate, Psychology University of Toronto “There is nothing either good or bad but thinking makes it so.” - William Shakespeare [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.