correlationMatrixDiff: Plot a matrix that shows the difference between two...

Description Usage Arguments Value Examples

View source: R/correlationMatrixDiff.R

Description

This function plots a matrix that shows the difference between two correlation coefficient matrices computed by correlationMatrix. This is useful for assessing how well model data reproduces correlations that are evident in reference data. The difference is computed as the absolute value of the first correlation matrix minus the absolute value of the second correlation matrix.

Usage

1
2
3
correlationMatrixDiff(cm.one, cm.two, myRows = NA, myColumns = NA,
  inputDir, outputDir = FALSE, ofileName = "correlationMatrixDiff.pdf",
  plot.width = 8, plot.height = 6.8, plot.margin = c(10, 10, 1, 4))

Arguments

cm.one

An R objective that gives a correlation matrix computed by correlationMatrix.

cm.two

An R objective that gives another correlation matrix computed by correlationMatrix.

myRows

Optional: the user can highlight relations between variables by specifying variable names along the rows and columns of a matrix. Those relations are then highlighted by plotting a polygon around the corresponding grid cells and by plotting the corresponding value.

myColumns

Optional: Same as myRows but for variable names listed along the columns of the matrix.

inputDir

A string that gives the location of NetCDF files produced by scores.grid.time, e.g. '/home/project/study'.

outputDir

A string that gives the output directory, e.g. '/home/project/study'. The output will only be written if the user specifies an output directory.

ofileName

A string that gives the output file name, e.g. 'myOutput.pdf'

plot.width

A number that gives the plot width, e.g. 8

plot.height

A number that gives the plot height, e.g. 6.8

plot.margin

An R object that gives the plot margin, e.g. c(10, 10, 1, 4)

Value

A Figure of a matrix that shows the difference between two correlation coefficient matrices.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
library(amber)
library(classInt)
library(doParallel)
library(foreach)
library(Hmisc)
library(latex2exp)
library(ncdf4)
library(parallel)
library(raster)
library(rgdal)
library(rgeos)
library(scico)
library(sp)
library(stats)
library(utils)
library(viridis)
library(xtable)

inputDir <- paste(system.file('extdata', package = 'amber'), 'zonalMeanStats', sep = '/')
cm.one <- correlationMatrix(metric = 'bias', inputDir = inputDir)
cm.two <- correlationMatrix(metric = 'bias', inputDir = inputDir)

correlationMatrixDiff(cm.one, cm.two, inputDir = inputDir)

# You can specify certain relationships to highlight them in your correlation matrix
myRows <- c('LAI.AVHRR', 'LAI.AVHRR')
myColumns <- c('ALBS.CERES', 'GPP.FluxCom')

correlationMatrixDiff(cm.one, cm.two, inputDir = inputDir, myRows = myRows, myColumns = myColumns)

amber documentation built on Aug. 28, 2020, 5:08 p.m.