# Conversion between units of measurement

I have two different measuring instruments, A and B, both measure the same physical quantity but with different unit of measures: $u_A$ and $u_B$.

A is a reference instrument.

I measured a reference part $L$ $n$ times with A and I get the $n$ values $L_{Ai}$ ($i=1 \dots n$) expressed in term of the unit of measure $u_A$.

Then I measure the same reference part, $L$, $m$ times with B and I get the $m$ values $L_{Bj}$ ($j=1 \dots m$) expressed in term of the unit of measure $u_B$.

In the future I will make my measures with B but I will be interested in the measure expressed in term of the unit of measure $u_A$.

I assume I can convert $u_B$ into $u_A$ by means of just one multiplicative conversion factor $k$.

Now, I have three questions:

1. Is it possible to assess the validity of the above assumption starting from the values $L_{Ai}$ and $L_{Bj}$?

2. If the assumption is valid, how can I compute the conversion factor $k$ to convert the measure from $u_B$ to $u_A$, i.e. $L_A=k L_B$?

3. How to manage the case where I have more than one part, i.e. $L_1$, $L_2$, etc.

My first attempt is to assume the assumption as valid and then compute $k$ as $k=\frac{m\sum_{i=1}^n LA_i}{n\sum_{j=1}^m LB_i}$ but it is based more on "common sense" rather than on some proper statistical basis.

Can you give me some hints about the part of statistics that covers these kind of problem? Maybe linear regression?

• Your method (looking for "one multiplicative conversion factor") would not work between Fahrenheit and Celsius. – Henry Oct 22 '12 at 14:52
• @Henry Yes I know, it is for that reason that I asked the question number 1. – Alessandro Jacopson Oct 28 '12 at 12:27
• Are you telling us that you know the same physical quantitiy is measured in different units but you do not know how the units are converted? – cbeleites unhappy with SX Oct 28 '12 at 16:13
• @cbeleites Yes. – Alessandro Jacopson Oct 28 '12 at 19:37
• But do you know the units? – cbeleites unhappy with SX Oct 29 '12 at 12:35

Based on your comments, what you want to do is a calibration, which you also want to validate:

you have

• reference measurements of a temperature (thermometer A), and
• measurements of instrument B which is not a thermometer yet, as you do not get response of the physical quantity temperatures but of a physical quantity like e.g. electrons/s.
Camera readout is not the same physical quantity as a temperature.

So in fact your task is to find the conversion between electrons/s and temperature, i.e. to calibrate your camera output to temperatures.

I'm chemometrician, I do calibrations to relate instrument readout to chemical quantities. There are whole books written on the subject of how to obtain a good calibration model (your question 2) and then how to validate this method (your question 1).

So:

### Question 1: how to compute the parameter $k$?

This is called fitting the calibration model.

And this part actually starts with deciding what kind of model is appropriate. This is what your assumption (multiplicative) is.

In chemometrics, sometimes the terms soft and hard models are sometimes used to distinguish:

• hard models: deriving the ansatz for the model from first (global) principles,
e.g. describing camera readout as function of temperature (e.g. black body radiation, quantum efficiency of the camera at different wavelengths, ...) and then solving for temperature and simplifying as much as possible by merging as many parameters as possible into fewer parameters that need to be determined experimentally.
• soft models: modelling the calibration function by approximations that are independent of the exact physical connection.
E.g. you may assume that if your temperature range is narrow enough, you can approximate the unknown hard ansatz by a linear model. If that isn't enough, quadratic may be appropriate etc. Or, you may expect a sigmoid behaviour etc.

Recommendation 1: do a bit of thinking and decide roughly what type of relationship you expect.

Soft modelling is a valid and widely used option, but you should be able to give reasoning why multiplicative relationship is sensible compared to other families of functions like sigmoid or exponential or logarithmic.

### Question 3: What to do with more $L$s?

I'm not sure whether I understand correctly what the different $L$s are.

• if they are measurements of parts with other temperature, you are going to need them as Peter Flom and gung already said.
Usually, extrapolating outside the calibrated range (i.e. the temperature range spanned by your model fitting data) is not considered valid. You may argue for an exception if you validate (see below) the method for a wider range; but if you can get a wide range of validation data, there is no reason why you couldn't get training data for that range as well.

• if you refer to the camera having many pixels: it will depend on the properties of the camera whether you can reasonably assume that all pixels follow the same calibration or whether you need to calibrate each pixel.

### Question 1: How to know whether multiplicative relationship is appropriate? Part I

In chemometrics, multiplicative without intercept is not even done in situations where the hard model suggests multiplicative-only relationship (e.g. Beer-Lambert-law) as there are usually many things in the construction of instruments that lead to an intercept.
My experience suggests multiplicative relationship without an intercept term is hardly ever appropriate for camera readout.
E.g. all camera readout I've worked with so far had a bias or dark current which would be an intercept in the model.

Recommendation 2: if you decide for a multiplicative model without intercept, you should be able to give very good reasons why no intercept can possibly occur. This may be easier the other way round: try to invent situations that would lead to an intercept for the camera readout. If you can come up with an intercept, you should include one into the model.

The so called regression diagnostics for linear models will tell you if the intercept cannot be distinguished from zero. That would be evidence that allows you to fit a model without intercept. Likewise, you can fit a quadratic model and see whether the quadratic term can be distinguished from zero.

### Question 1: How to know whether multiplicative relationship is appropriate? Part II

While you can spot certain things going wrong within the set of measurements used for building the calibration model, "valid" means more than that. Usually, it means demonstrating that your calibration can be successfully applied to camera readout of completely unknown samples (possibly measured some time after the calibration was done). Again there is a whole body of literature to validation, and depending on what your exact field is, there are also norms that you should follow.

Briefly, for validation you need a second set of measurements that was not involved in any way in building the calibration. You then compare the reference instrument's output to the predictions of the calibration. Looking at the deviations, you can assess several aspects of correctness of your calibration:

• bias (i.e. your model has a systematic deviation)
• variance (random uncertainty)
• drift (i.e. $k$ changes over time; requires appropriate planning of measurements)

## Some Literature

• Thank you very much. Do you have any suggestions for a good online tutorial or a book? – Alessandro Jacopson Nov 4 '12 at 18:51
• @uvts_cvs: I added some links to literature. The latter 2 are journal papers that may be behind a pay-wall for you. Besides that I could recommend you some books in German language. – cbeleites unhappy with SX Nov 4 '12 at 19:27

If you make the less restrictive assumption that the two measurements are related by some linear equation, then: For question 1, you can assess the assumption using linear regression. If it is valid, the intercept should be 0 (or very close to 0, if there is measurement error).

For question 2, the coefficient will tell you the constant to use

I am not sure about question 3, but doing several multiple regressions ought to give very similar results, unless there is a lot of measurement error.

E.g. for Fahrenheit and Celsius:

set.seed(1919187321)
LAbase <- c(0, 10, 20)
LBbase <- LAbase*9/5 + 32

LA <- LAbase + rnorm(3)
LB <- LBbase + rnorm(3)

#regress
m1 <- lm(LB~LA)
summary(m1)


and, with this seed at least, the results are quite close.

Given that you will have more than three measurements with each instrument, you can assess the initial assumption by drawing a scatterplot of the two measurements and then using a smooth curve such as loess or splines. If the assumption is correct, the smooth curve will be very nearly straight.

• Thank you. Your code sample is meaningful because you use three different values for LAbase, my case is more like LAbase <- c(10, 10, 10) where L=10 and n=3 and in that case the computed model m1 is not meaningful to me. – Alessandro Jacopson Oct 28 '12 at 20:21
• If you get the same values all the time for LAbase, there is no way to do anything. – Peter Flom Oct 28 '12 at 21:10
1. Your assumption that the measures will only differ by a multiplicative constant strikes me as certainly false. The fact that this would not work for converting from Fahrenheit to Celsius demonstrates that.
2. (A.k.a. #3) You will need to assess more than one part. You will not have enough degrees of freedom to determine the conversion between the two measurements if you only use one part. Moreover, try to get parts where the true values of the measurements span as large a range as possible, and certainly span the range within which you will want to make the conversion in the future.
3. (A.k.a. #2) You can determine the conversion equation by means of a regression analysis. With multiple measures, you could use a multi-level model, but I suspect this is more than is necessary. If you make several measures of each part with each measurement instrument you can just use the averages, as you describe, to get a more robust measure. Then you can just use those two means as your $x$ and $y$ values for that part. The beta estimates from the regression equation will give you the shift required.

Note that these won't be the same values that you could get via other conversion strategies, however, because the procedure differs; for example to convert from Fahrenheit to Celsius, you can subtract 32 and divide by 1.8, but to use a regression equation, $\beta_0\approx18$ and $\beta_1\approx.6$. This doesn't matter, as long as you know which procedure you're using.

Another advantage of the regression approach, by the way, is the conversion between two measurement instruments won't necessarily be linear throughout the possible range, which a regression analysis may allow you to model.

If you have several measurements of the same quantity several times in the two units, there is, in general, no way to estimate the transformation from one unit to the other.

However, if you knew that that there is a multiplicative relationship between the two, and that the noise in the two sets if measurements is zero-mean normal (with equal variances or different but known variances), then you can estimate the multiplicative factor $k$ by maximum-likelihood.

If you make the above assumptions you can proceed as follows. Let $X_B$ be the actual value of the quantity you repeatedly measure in units of $B$. Then $L_{Ai} = k X_B + e_i$, $i = 1, \dots, n$, and $L_{Bj} = X_B + f_j$, $j = 1, \dots, m$.

$e_i$ and $f_j$ are normal i.i.d., normal random variables with mean 0 and variance $\sigma^2$. You can write the log-likelihood of the data as

$$L(data; k, X_B) = const - \frac{1}{\sigma^2}\sum_i (L_{Ai} - k X_B)^2 - \frac{1}{\sigma^2}\sum_i (L_{Bi} - X_B)^2$$

You should be able to maximize this quantity in terms of $k$ and $X_B$ to obtain your transformation (and an estimate of the quantity).

In fact, if you go through the algebra of setting the partial derivatives of the log-likelihood function with respect to $k$ and $X_B$ to zero, you should get the expression for $k$ you have in your question.

$X_B = \frac{\sum_j L_{Bj}}{m}$ and $k = \frac{ m \sum_i L_{Ai}}{n \sum_j L_{Bj}}$

The key document you need is the GUM (Guide to the Uncertainty in Measurement) - JCGM 100:2008 (GUM 1995 with minor corrections) Bureau International de Poids et Mesures /guides/gum which gives the full (international standard) details about how to assess the performance of one measure against a reference (your reference will already have an assessible uncertainty). The US NIST documents are based directly on this as well.

The GUM allows you to make your choice about assessment method, but then requires you provide an error term for any assumptions, such as the belief that the two instruments have no offset.

You will have both systematic terms, and random terms. The systematic terms are usually the greater error, and are commonly under assessed (look at the early 1900's estimates for the speed of light and their error bars - which didn't overlap!).

Because you only have one reference part, all you can do, so far, is assess the relative sizes of the two random errors of measurement (including local systematic variation such as temperature, operator, time of day..)

At the end you would be able to state an error and a coverage factor for your new readings over some range of validity.