# Extracting fixed effects table output from lme object

I am trying to fit a model which is similar to the

fm2orth.lm<-lme(distance~age,data=OrthoFem, random=~1|Subject)


and did

summary(fm2Orth.lm)


1. Aic/BIC
2. Random Effects
3. Fixed Effects table
4. Correlation.

My question is I am interested in only the third output above and tried

fm2Orth.lm$coefficients  and had coefficients of the individual subjects, which is not what I want, can someone show me how I could get only the fixed effects table with the p-values. - add comment ## 2 Answers The answer is quite easy: summary(fm2Orth.lm)$tTable


will give you the full table (not just the coefficients).

In general, use:

names(fm2Orth.lm)


and

names(summary(fm2Orth.lm))


to see what objects are contained in those lists. Then you can explore those objects and you will often find what you need.

-
+1 answer. Both names and str are very useful for poking into structures like that. Unless it's an S4 class (you use an 'foo@bar' instead of 'foo$bar' to access members), in which case you'll need slotNames. – Wayne Sep 22 '11 at 15:26 Yes, thanks for mentioning str and the difference with S4 classes. I think the output from str can be confusing for a novice (especially for complex structures like those created by the lme function), but once you get the hang of it, it is an indispensable tool. – Wolfgang Sep 23 '11 at 9:14 You're right: at first I never used str because of information overload, but now I find that it often saves an additional step (i.e. find a name, figure it might be of interest, then class or dim or print it to figure out what it really is). – Wayne Sep 23 '11 at 14:24 add comment The class of the output of lme is, not surprisingly, lme. You can find this by running class(fm2orth.lm). As a consequence, when you call summary on it, what is really called is summary.lme. This function is not exported from the nlme package (you can discover this when you type summary.lme at the prompt: you get a message that the object is not found), but you can still get to its source like this: getAnywhere("summary.lme"). You will see there some of the objects of the summary are built up and what name they are given (e.g. object$tTable <- ...) You will also see that the result of summary.lme is an object of class summary.lme (again, no surprises there).

Finally, you can check print.summary.lme, because print is what is automatically called by R to display the return value of the last statement, but like summary, it is dispatched to a version that is class-specific. Note, once again, this function is not exported from the package, so you'll have to use getAnywhere.

Finally, in this function's source, you'll see a call cat("Fixed effects: ") that obviously marks the start of printing the information you're interested in. There you can see that what is really printed (cat(deparse)), is based upon the summary's member call\$fixed but may depend on the way the original model was built.

This should give you enough info to find out how to get to it.

Edit: I just noticed that the object returned from summary.lme is really the orginal fit (so the return value of lme itself, with some extra list items added to it. As such, this call member used in print.summary.lme is already part of the original fit (, since it is not added by summary.lme). Result: you probably don't really need the summary to get to the fixed effects.

-