Last data update: 2014.03.03

R: Plots covariance matrices
plotsubspaceR Documentation

Plots covariance matrices

Description

Represents covariance matrices as 3-d ellipsoids using the rgl package. Covariance matrices of dimension greater than 3 are plotted on the subspace defined by the first three eigenvectors.

Usage

  plotsubspace(CA, CB=NULL, corr = FALSE, shadeCA = TRUE, 
      shadeCB = TRUE, axes.lab = FALSE, ...)

Arguments

CA

Matrix

CB

Optional second matrix

corr

If TRUE the covariance matrices are transformed into correlation matrices

shadeCA

If TRUE the ellipsoid is solid, if FALSE the ellipsoid is wireframe

shadeCB

If TRUE the ellipsoid is solid, if FALSE the ellipsoid is wireframe

axes.lab

If TRUE the axes are labelled with the eigenvectors

...

further arguments to be passed

Details

The matrix CA is always red, and the matrix CB if given is always blue. The subspace is defined by the first three eigenvectors of CA, and the percentage of variance for each matrix along these three dimensions is given in the plot title.

Author(s)

Jarrod Hadfield j.hadfield@ed.ac.uk with code taken from the rgl package

See Also

rgl

Examples

 if(requireNamespace("rgl")!=FALSE){
   G1<-rIW(diag(4),10)
   G2<-G1*1.2
 #  plotsubspace(G1, G2, shadeCB=FALSE)
 # commented out because of problems with rgl 
 } 

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MCMCglmm)
Loading required package: Matrix
Loading required package: coda
Loading required package: ape
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MCMCglmm/plotsubspace.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotsubspace
> ### Title: Plots covariance matrices
> ### Aliases: plotsubspace
> ### Keywords: hplot
> 
> ### ** Examples
> 
>  if(requireNamespace("rgl")!=FALSE){
+    G1<-rIW(diag(4),10)
+    G2<-G1*1.2
+  #  plotsubspace(G1, G2, shadeCB=FALSE)
+  # commented out because of problems with rgl 
+  } 
Loading required namespace: rgl
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>