[Rd] nlme package. Minor change in method print.VarCov (PR#10669)
agalecki at umich.edu
agalecki at umich.edu
Thu Jan 31 17:55:07 CET 2008
Hello,
I would like to propose to make a minor change in method print.VarCov
by inserting one line
stdevs <- FALSE # Inserted line
as shown later in this email.
By adding this line we would modify the output from
print(corrmtx) as shown in the illustration below. More specifically the
line with redundant information, which reads " Standard Deviations: 1 1 1 "
would be skipped from the output.
Otherwise, to omit line with SDs:1 1 1 from the output we need to use
more cumbersome syntax:
print(corrmtx, corr=TRUE, stdevs=FALSE).
Output from sessionInfo() included at the bottom of this email
Sincerely,
Andrzej Galecki
============ Illustration ========
> selected.rows <- seq(1,308, by=10)
> ovary <- Ovary[selected.rows,] # selected rows
> fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), ovary,
correlation = corAR1(form = ~ 1 | Mare))
> vmtx <- getVarCov(fm1) # Covariance matrix
> corrmtx <- cov2cor(vmtx) # Correlation matrix
> print(corrmtx, corr=TRUE)
Marginal correlation matrix
[,1] [,2] [,3]
[1,] 1.00000 0.39172 0.15345
[2,] 0.39172 1.00000 0.39172
[3,] 0.15345 0.39172 1.00000
Standard Deviations: 1 1 1
> print(corrmtx,corr=TRUE,stdevs=FALSE)
Marginal correlation matrix
[,1] [,2] [,3]
[1,] 1.00000 0.39172 0.15345
[2,] 0.39172 1.00000 0.39172
[3,] 0.15345 0.39172 1.00000
==========Part of the Source code with suggested change =======
> getS3method("print","VarCov")
function (x, corr = FALSE, stdevs = TRUE, digits = 5, ...)
{
pvc <- function(x, type, corr, stdevs, digits) {
cat(c("Random effects", "Conditional", "Marginal")[match(type,
c("random.effects", "conditional", "marginal"))],
" ", sep = "")
x <- as.matrix(x)
class(x) <- NULL
attr(x, "group.levels") <- NULL
if (corr) {
cat("correlation matrix\n")
sds <- sqrt(diag(x))
print(signif(t(x/sds)/sds, digits))
stdevs <- FALSE # Inserted line
}
else {
cat("variance covariance matrix\n")
print(signif(x, digits))
if (stdevs)
sds <- sqrt(diag(x))
}
=======================================================================
> sessionInfo()
R version 2.6.1 (2007-11-26)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] nlme_3.1-86
loaded via a namespace (and not attached):
[1] grid_2.6.1 lattice_0.17-2 tools_2.6.1
>
More information about the R-devel
mailing list