I have an experiment that relies on measuring temperature as a function of a given condition. I change the condition, allow the temperature to stabilize as much as possible, then take 3 measurements in a row, which are all slightly different, as the values tend to oscillate.

For example, I might have a set of readings that looks like this:

X          Temperature
10.1        80.3
10.8        82.1
10.3        78.9
20.4        100.2
20.0        101.1
20.2        101.0
30.1        139.1
30.0        140.2
30.0        138.2

Which I will combine to look like this:

uniqueX    Xmean       Xstd      Tmean      Tstd  
_______    ______    ________    ______    _______

10           10.2         0.1    80.433     1.6042
20           20.2         0.2    100.77    0.49329
30         30.033    0.057735    139.17     1.0017

% Matlab code for computation
xNom = round(X);
[uniqueX,~,subs] = unique(xNom);
Tmean = accumarray(subs, T, [], @mean);
Tstd  = accumarray(subs, T, [], @std);
Xmean = accumarray(subs, X, [], @mean);
Xstd  = accumarray(subs, X, [], @std);
tb = table(uniqueX, Xmean, Xstd, Tmean, Tstd);

I'm wondering: what is the best way to plot such data, i.e. when three data points like this are combined to represent one point, what is the best value to use for the error bars on a plot of T vs X, for example in this case?


I think full disclosure is almost always best, especially for your data. I see nothing wrong with plotting all $n = 9$ points. It will be immediately clear that the clusters of three show your remarkably successful attempt to replicate measurements under three (slightly unstable) conditions.

I suppose you want to show the relationship between X and Temperature, which seems quadratic rather than linear. In general, you will get a better fit if you don't try to combine data into three 'pseudo-points'. Below is Minitab 17 output for a quadratic regression of Temperature on X. The dotted lines express the likely error in determining the height of the parabola at each value of X. (Although 'error bars' are inexplicably popular, it is my experience that most of the 'error bars' experimenters use are unsupported by sound statistical theory, questionable as to purpose, and misleading in practice; it is better to use 'confidence bands' as in the Minitab plot.)

enter image description here

  • $\begingroup$ Hi @BruceET, many thanks for that. The reason I'm doing a combination of 3 points is party because I actually have a lot more data than I showed here (many other series) and partly because I'm trying to replicate something done in a paper. Full disclosure will be too illegible, unfortunately, for this case. I do like the idea of doing confidence bands, as the data doesn't vary much and error bars look more cluttered than anything. Not sure how the values for your confidence bands are calculated, do you mind explaining? Is that a value of stddev? $\endgroup$ – teepee Jun 6 '17 at 17:59
  • $\begingroup$ OK, if you need to plot data, then it is OK to show averages (of X's and Temps) on the graph. But you should use all of the original observations to get any regression lines or curves. The formula for confidence bands of a linear plot are shown in most elementary statistics books (I think you want bands for estimates rather then predictions.) For quadratic regression, the formulas are a bit messier, and usually done by software. Linear case, look for something like: $\hat y_i \pm t^*s_{y|x}\sqrt{\frac{1}{n} + \frac{(x_i -\bar x)^2}{(n-1)s_x^2}}.$ $\endgroup$ – BruceET Jun 6 '17 at 18:11
  • $\begingroup$ For a simple intro that seems mathematically correct, maybe look at these notes from Duke U. The Wikipedia article is pretty, but not really informative. $\endgroup$ – BruceET Jun 6 '17 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.