Reputation: 2439
In the standard example of the lme() function in the nlme package of R:
fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
summary(fm2)
there appears a correlation table:
Correlation:
(Intr) age
age -0.813
SexFemale -0.372 0.000
which can be huge if there are many factor combinations involved.
Is there any way to suppress the output in the summary command? I know that I can use
print(fm2, cor=F)
but this does not show me the rest of the usual output for example no p-value calculation.
Upvotes: 6
Views: 2192
Reputation: 3395
I just recently ran into the same issue when fitting models with lots of fixed effects and the correlation table was huge and really cluttered up the output. Looking at print.summary.lme()
(which isn't exported, so you have to use nlme:::print.summary.lme
) shows that the part comes from these lines:
if (nrow(x$tTable) > 1) {
corr <- x$corFixed
class(corr) <- "correlation"
print(corr, title = " Correlation:", ...)
}
as already pointed out by Ben. Instead of rewriting/replacing the entire function, we can also use a simple trick, replacing nlme:::print.correlation
(which is what is actually doing the printing of the correlation matrix) with our own print
method for objects of class correlation
. This can be done with:
assignInNamespace("print.correlation", function(x, title) return(), ns="nlme")
Now the correlation matrix will be omitted, but you get the remaining output.
Upvotes: 3
Reputation: 226192
Looking at nlme:::print.summary.lme
I don't see a way to suppress the correlation matrix printing (although you could create a hacked version of that function removing the if
clause beginning if (nrow(x$tTable)>1)
...)
Perhaps it would be useful to you to be able to print just the summary of the fixed-effect parameters ... ?
printCoefmat(summary(fm2)$tTable)
Upvotes: 4