plot.uncert {metRology}R Documentation

Plot method for 'uncert' objects

Description

Plots for uncertainty budgets produced by uncert calls.

Usage

## S3 method for class 'uncert'
plot(x, which = c(1,2,4,5), main = paste(deparse(substitute(x))), 
    ask = prod(par("mfcol")) < length(which) && dev.interactive(), 
    caption = list("Variance and covariance contributions", 
    expression(sqrt(group("|", "Variance and covariance contributions", "|"))), 
    expression("Contribution " * u[i](y) == c[i] * u[i]), 
    "Combined contribution", "Correlation (x,y)", 
    "Covariances (x,y)"), cex.caption = 1, ...)

Arguments

x

An object of class uncert produced by a call to uncert().

which

Integer in 1:6; the particular variant(s) of plot required. A vector is permitted, in which case plots are produced in ascending order.

main

Main title for the plot

ask

logical; if 'TRUE', the user is _ask_ed before each plot, see 'par("ask=")'

caption

A list of captions for all the different plots.

cex.caption

Text size for captions. Note that if the number of figures per page is over 2, captions are further scaled by 0.8

...

Further parameters passed to plot() (mostly barplot).

Details

For uncert objects created with methods other than MC, the plot types are:

which=1

A barplot of all non-zero contributions to the combined uncertainty. These are derived from the covariance matrix and the coefficients c_i. For terms on the diagonal of the covariance matrix, these are (c_i*u_i)^2; for off-diagonal terms (the correlation terms), 2*(c_i*u_i)*(c_j*u_j)*r_ij. The threshold for deciding an off-diagonal term is nonzero is that its magnitude is greater than 2*.Machine$double.eps. Note that off-diagonal contributions may be negative.

which=2

As for which=1 except that the square root of the absolute value is plotted. For the 'diagonal' terms, these are just eqnu_i(y) in the nomenclature used by the GUM.

which=3

A barplot of u_i(y)^2, without the correlation terms.

which=4

A barplot of the sum of all (co)variance contributions associated with each x_i, that is,

contrib(i)=(c_{i}u_{i})^2+\sum\nolimits _{j\neq{}i} 2(c_{i}u_{i})(c_{j}u_{j})r_{i,j}

.

which=5

A barplot of the theoretical correlations cov(x_i,y)/u(x_i)u_y.

which=6

A barplot of the theoretical covariances cov(x_i,y).

Values of which outside this range are silently ignored.

For the X-Y correlation and covariance plots, the covariances are calculated from the covariance matrix V (supplied to uncert() as cov or calculated as outer(u,u,"*")*cor) and sensitivity coefficients c_i as cov(x_i,y) = \sum\nolimits _{j} V_{j,i}c_j . In fact the calculation used is simpler: cov.xy <- V %*% ci. The correlations are calculated in turn from these using cov(x_i,y)/u(x_i)u_y.

Perhaps the most informative plots are for which=1, which=2, which=4 and which=5. The first of these includes all nonzero signed contributions, making the negative contributions visible; the second (which=2) makes direct comparison of magnitudes easier. The combined contribution plot is the effect on the total variance of removing all terms associated with a particular variable; it shows how much u_y^2 would reduce if the uncertainty for x_i were reduced to zero. Note that in some cases with negative correlation the combined uncertainty can increase, on dropping a variable, shown by a negative reduction in the plot. (which=5) is among the most direct indications of the relative importance of individual parameters.

Objects created with the MC method are passed to plot.uncertMC.

Value

Invisibly returns the default return value for the last plot produced.

Author(s)

S. L. R. Ellison, s.ellison@lgc.co.uk

References

None.

See Also

uncert, barplot, plot.uncertMC.

Examples

  
  #An example with negative correlation
  x <- list(a=1, b=3, c=2, d=11)
  u <- lapply(x, function(x) x/10)
  u.cor<-diag(1,4)
  u.cor[3,4]<-u.cor[4,3]<- -0.5
  u.form.c<-uncert(~a+b*2+c*3+d/2, x, u, method="NUM", cor=u.cor)
  
  par(mfrow=c(3,2))
  plot(u.form.c, which=1:6, las=1, horiz=TRUE)  #Note use of barplot parameters


[Package metRology version 0.9-28-1 Index]