AVERAGE: help and advice

AVERAGE: help and advice


Consult the reference manual for further details and worked examples.
W.G.Bardsley, University of Manchester, U.K.
Areas, averages and thresholds

This program can be used to calculate the area under a curve, or the average function value over a range, by the trapezoidal method (e.g. for AUC and bioavailability), or the fraction of the range above a threshold (e.g. proportion of treatment time with plasma levels above a critical drug concentration).

Suppose a function f(x) is well defined and can be integrated over a range x1 =< x =< x2. Then the area over this range can be defined as an integral, namely

     Area = integral of f(x) between x1 and x2.
If a model equation f(x) is not available or cannot be fitted then the area under the curve can be estimated by the trapezoidal rule when values are given for x and y. This is equivalent to using the lines joining up adjacent (x,y) pairs as an approximation to y = f(x). The average value of f(x) between x1 and x2 can be defined as
     Average = Area/(x2 - x1),
which can then be calculated from the area-estimate.

Sometimes it is required to estimate the fraction of the range of x where f(x) lies above or below a given threshold, and this program also calculates such parameters. To simplify the calculation and to avoid any ambiguities, it is supposed that y_values are all nonnegative, and that x_values are in nondecreasing order but not necessarily equally spaced. A linear interpolation is used if the limit values of x1 or x2 do not correspond to any actual x_values in the current data set.

Alternative ways to run this program

At the start of each run you will be asked if you want to re-set Begin = Xmin, End = Xmax. If you accept, the program will automatically initialise (x1,x2) for the calculation of areas and average values to the extreme values set by the range of the current data as each new data set is entered. That is

     x1 = Xmin
     x2 = Xmax.
However, you can temporarily alter limits interactively for any current data set. This mode of program operation should be selected when the average and/or area is required over the complete range for each data set. If you do not select this option, you set the range by choosing (x1,x2) values for limits which will remain fixed until you change them. This ensures that areas and averages use the same range for all the data sets, but note that x1 and x2 are always adjusted temporarily if necessary to lie in the range (X-min,X-max). Similarly, you can select the option to set the y-theshold equal to the smallest y-value for each individual data set, or you can set a default value interactively. Initial defaults are set by the first data set entered.

Formatting data

Use a baseline for measurement so that all y-values are positive, then prepare a data file as a matrix with a column of x in nondecreasing order, and a corresponding column of y values, e.g. using program MAKMAT. Alternatively you can prepare a curve fitting file using the program MAKFIL, and then edit this if required using EDITFL, or you can transfer data from a spreadsheet by using the clipboard or a macro.

Important points to remember

  1. All y-values must be positive for the methods used by this program to make sense
  2. The y-values can be single observations or means but, if replicates are supplied, the program will calculate means from the replicates interactively.
  3. Calculated areas, etc. always refer to the mean y-values
  4. All x-values must be in nondecreasing order
  5. Be very careful if you want to adjust the limits and/or the threshold. Usually the default would be to set these automatically as each new data set is read in.
  6. The program will calculate trapezoidal area under the x,y points between X-start and X-stop and the fraction of the range above and below the Y-critical level. This is if an average temperature is needed, or time above a threshold.
  7. The program will never extrapolate outside the range set by the data.
  8. For publication quality graphs with multiple data sets, error bars, replicates, etc. save ASCII files for SIMPLOT, or transfer to SIMPLOT interactively.
  9. Practise using the test files average.tf1, or compare.tf1
Summary of definitions
     Xmin    Smallest x_value in the current data set
     Xmax    Largest  x_value in the current data set
     Ymin    Smallest y_value in the current data set
     Ymax    Largest  y_value in the current data set
     x1      lower critical x_value (>= Xmin and < x2)
     x2      upper critical x_value (<= Xmax and > x1)
     Xstart  maximum of x1 and Xmin (but =< Xmax)
     Xstop   minimum of x2 and Xmax (but >= Xmin)
     Above   X_length above threshold (also as % of total X_range)
     Below   X_length below threshold (also as % of total X_range)
     Ytest   Threshold y_critical_value
     Yarea   Area under y points between Xstart and Xstop
     Ymean   (Yarea)/(Xstop - Xstart)