4

I am using two different methods to measure velocities, which can be positive, negative or zero. Method A accurately measures low velocities and no velocity, but not highly positive or highly negative velocities. Method B measures big velocities accurately but not low velocities.

How can I combine these methods to get accurate values in all ranges? The combination should weight method A more heavily when its values are low, and weight method B more heavily when its values are high. If the method A value is 0, its weight would be 100% and the method B value wouldn’t be used at all. If the method B value is very high, its weight would be near 100% and the method A value wouldn't be used at all.

What is the best way to combine these methods?

At the moment I transform both method A and method B values to finite scales with the logistic function or some other sigmoid function that is continuous, differentiable, and has asymptotes at 0 and 1, So values that were negative infinity transform to 0, values that were 0 transform to 0.5, and values that were positive infinity transform to 1. Now, with both method A and method B values on the same finite scale, I can apply the weights: method A would have a weight of 100% if its transformed value is 0.5 and a weight of 0% if its transformed value is either 0 or 1, and method B would have a weight of 100% if its transformed value is either 0 or 1 and a weight of 0% if its transformed value is 0.5.

Which sigmoid function is most appropriate and how quickly should it approach the asymptotes? Is there a way to determine these things using the data?

I also asked this same question here.

Matt F.
  • 4,726
  • 2
    Are you able to make any assumptions about a) how the accuracy of each method changes as a function of velocity (e.g. is it a step function, or some kind of curve?), and b) what form does the inaccuracy take (e.g. Gaussian random noise added to measurements with a standard deviation that depends on the velocity? occasional huge outliers?). – Eoin Jul 17 '23 at 13:43
  • @DavidMoore, ah, so for instance at velocity v, method 1 is within ± e1 and method 2 is within ± e2, and you're hoping that by combining the two estimates the potential errors can partially cancel each other to produce a smaller error. So, as a crude example, '5±1' and '7±3' might produce something like '5.5'. ¶ A practical analogy might be using two accurate weigh scales, one in pounds and one in ½ kilograms, to calculate weight estimates that are more precise than either scale. E.g. 15 pounds and 7 kg would give ranges 6.59–7.05 and 6.75–7.25, producing 6.75–7.05, which is 6.9±.15 kg. – Ray Butterworth Jul 17 '23 at 13:57
  • @Eoin - I believe that method 1 is more accurate for low velocities than method 2 is for high velocities, and I believe the best way to model accuracy changes as a function of velocity would be some sort of continuous, differentiable function (like the logistic function, the hyperbolic tangent, the arctangent function, the Gudermannian function, or the error function; I don't think a step function would be appropriate). – David Moore Jul 17 '23 at 14:15
  • @Eoin - the inaccuracy would be different for each method - method 1's inaccuracy increases with the magnitude of the velocity, and method 2's inaccuracy decreases with the magnitude of the velocity - but I'm not really sure how they should be modeled. I guess I would assume the residuals are normally distributed, at least until I think of something more appropriate. – David Moore Jul 17 '23 at 14:16
  • @RayButterworth - yes - that is more along the lines of what I'm trying to do – David Moore Jul 17 '23 at 14:18
  • 1
    Can you measure the same true velocity several times with both measurement methods (for calibration)? – Ute Jul 18 '23 at 01:18
  • Are these time series measurements (e.g., the velocities are autocorrelated), or is each velocity to be measured independent (possibly from the same distribution)? – jblood94 Jul 20 '23 at 11:46
  • @Ute - yes, with good accuracy, although I have not done it yet; I was hoping for a general, theoretical answer which I could apply to any scenario where I have both of these measurements – David Moore Jul 20 '23 at 12:28
  • @jblood94 - yes - these are time-series measurements, although the time scale may vary quite a bit – David Moore Jul 20 '23 at 12:29
  • What exactly do you mean by accuracy? are measurements using A at high velocities biased (systematically wrong), or do they just produce more variation? (and similarly for method B) (sorry, I accidentially posted this as an "answer" -(shouldn't have used my phone to write on cv) – Ute Jul 23 '23 at 11:41
  • 1
    @Ute – method A measurements are much more variable at high velocities but not necessarily systematically wrong. I’m not sure if the same can be said for method B at low velocities; I think, for low velocities, method B would be more likely to be systematically wrong. I’m sorry for the late response. – David Moore Jul 24 '23 at 07:01
  • No worries - - Well, then my (unfinished) answer is only for minimizing the variance. You would need to have information about bias, too, to also reduce that. That is more difficult to get, you would need to calibrate with known velocities, essentially. Btw, how many measurements do you have at hand? – Ute Jul 24 '23 at 07:48
  • If a calibration curve is known, then it can also be used to eliminate bias. Possibly the issue is that the noise is not Gaussian and inverse variance weighting may give less optimal results? – Sextus Empiricus Jul 24 '23 at 09:17
  • 1
    Maybe relevant! https://stats.stackexchange.com/questions/495811/are-there-better-approaches-than-the-weighted-mean/495845#495845 – kjetil b halvorsen Jul 24 '23 at 13:30
  • @kjetilbhalvorsen very interesting link, indeed! I should have seen this before trying to derive everything from scratch... – Ute Jul 24 '23 at 15:06
  • Hi David Moore, I came to the conclusion that restricting the optimal weight function to a particular class of (sigmoid) functions is perhaps not the best approach, see the two illustrations in my answer. Could you do with a lookup function that does not have a parametric form? In any case, I would just try to establish a table of measurement value -> weight say. The link that @kjetilbhalvorsen provided looks also very relevant (too bad I did not know it beforehand). – Ute Jul 24 '23 at 15:18
  • @Ute - I suppose I will have to perform several calibrations at some point. I have several Mb of velocity data from many different conditions but I at no point have I measured true velocities. What do you mean by a lookup function? – David Moore Jul 24 '23 at 15:38
  • @SextusEmpiricus - I believe that the noise is Gaussian for method A but not exactly Gaussian for method B, but I'm not totally sure; it sounds like I need to perform some calibration studies. Hopefully I will have more information in the future. – David Moore Jul 24 '23 at 15:46
  • Sorry for being unclear -by "lookup function" I meant a smooth function that you fitted from the (velocity, variance) data, without assuming a strict parametric form. // Do you need this weight primarily to analyse existing data, or to have a quick way to calculate the best guess for the current flow velocity on a daily basis? // If you have further important covariables (temperature, time and day of course, anything that has a big influence on flow), then chances are not too bad that you can retrieve an OK fit from your huge database – Ute Jul 24 '23 at 15:46
  • @Ute - thanks. I do have covariates as well; I will have to do some further testing (including calibrations) and think more about these answers. I'm analyzing existing data. I appreciate your help. – David Moore Jul 24 '23 at 15:49

2 Answers2

1

Summary (tl;dr)

This answer assumes that measurement errors for the same measurement using methods A and B are independent. It also assumes that both measurement methods are unbiased, but the results extend to the case where only one of them is unbiased, and then hold for the mean squared error (MSE).

  • given we knew the variances, it would be easy to find the optimal weight as a function of the true value and the ratio of variances for methods A and B.
  • we have neither the true value nor the ratio of variances, but estimates or guesses for both. Therefore, weights will in reality deviate from the optimal values.
  • using wrong weights may yield worse estimates than using the arithmetic mean, but being "slightly off" still improves the precision of estimates. Therefore, using weights that come from some estimation should be OK.
  • the time series nature of the data scan be exploited to estimate variances and to calibrate the weight function (the sigmoid in OP).

Optimal choice of weights when "everything is known"

The generic question:
"how should I weight the outcomes of measurement A and B on the same quantity with independent measurement errors?"
has a well known solution:

  • if we can assume that both measurement methods are unbiased, then the optimal weight is given by inverse variance weighting.
  • this result carries over to the case where measurement A, say, is unbiased, and B is biased. In that case, replace "variance" by "mean squared error" (can be shown by the analogous calculations as for retrieving the result for unbiased estimators).

This requires however that the variances of the two methods are known. Let $\sigma^2_A(x)$ and and $\sigma^2_B (x)$ be the variances of measurement $A$ and $B$ when $x$ is the true value, and denote the ratio of variances as $\rho(x)=\frac{\sigma^2_A(x)}{\sigma^2_B(x)}.$ Then optimal weights $w_A(x)$ and $w_B(x)$ are $$ \begin{aligned} w_A(x) &= \frac{\sigma^2_B(x)}{\sigma^2_A(x)+ \sigma^2_B(x)} = \frac{1}{1+\rho(x)}, \\ \quad w_B(x) &= \frac{\sigma^2_A(x)}{\sigma^2_A(x)+ \sigma^2_B(x)}=\frac{\rho(x)}{1+\rho(x)}. \end{aligned} $$

How much do we gain using weighted averages?

The variance of a weighted average of $A$ and $B$, using a given weights $w_A =w$ and $w_B = 1- w$ , where $w\in[0,1]$, is $$ \begin{aligned} \sigma^2_{\text{weight}}(w) &:= \mathrm{Var} ( w A + (1- w) B) \\&= w^2 \sigma_A ^2 + (1- w)^2 \sigma_B^2 \\& = (w^2\rho +(1-w)^2)\sigma^2_B. \end{aligned} $$ For the variance $\sigma^2_{\text{avg}}$ of the arithmetic mean of $A$ and $B$, where $w=1/2$, we get $$ \sigma^2_{\text{avg}} := \sigma^2_{\text{weight}}(1/2)=\frac{\rho+1}{4}\sigma^2_B, $$ and the variance $\sigma^2_{opt}$ when using optimal weights $w^*_A$ and $w^*_B$ would give $$ \sigma^2_{\text{opt}} := \sigma^2_{\text{weight}}(w^*_A)=\frac{\rho}{1+\rho}\sigma^2_B, $$ so the relative efficiency of using optimal weights would be $$ \text{eff.}(w^*,0.5):=\frac{\sigma^2_{\text{weight}}(1/2)}{\sigma^2_{\text{weight}}(w^*_A)}=\frac{\sigma^2_\text{avg}}{\sigma^2_\text{opt}} = \frac{(1+\rho)^2}{4\rho}. $$

relative efficiency vs variance ratio

For moderate values of $\rho = \sigma^2_A/\sigma^2_B$, the relative efficiency is still quite close to 1. For example, with $\rho = 4$, we get $\text{eff.}(w^*, 0.5) = 25/16$. This is the same result as we would obtain for $\rho = 1/4$.

Using suboptimal weights

Since we do not know the true variances, we have to resort to estimated optimal weights, or to using predefined functions that may be fitted from data, as suggested in the original post. This bears the risk that the weighted average has lower efficiency than the arithmetic average, in particular when both measurement methods A and B have the same variance (whence $\rho=1$).

However, the as soon as B has higher variance than A, there is still gain in efficiency even when using a weight that deviates from the optimal one. In the figure below shows relative efficiency compared to the arithmetic average as a function of percentual deviation from the optimal weight, for ratios $\rho = 1, 2, 5$ and $10$.

Example

We can see that the method appears very forgiving already for $\rho = 5$, (which would correspond to $\rho = 1/5$ by changing the roles of A and B). In that case, the weight for the better method, B, would be $5/6$, and the weight for the less accurate method, A, would be $1/6$. The relative efficiency with optimal weight is $\text{eff.}(w^*_A,0.5) = 1.8$. If we use only method B, i.e., weight $w=0$ for A, the efficiency would drop down to $\sigma^2_{\text{avg}}/\sigma^2_{\text{weight}}(0) = 1.5$. Efficiency vs weight deviation

Examples, and relation to sigmoid functions approach

When we have a model for the variances as a function of the true value $x$, then it is easy to derive the weights, by calculating $\rho(x)$ and propping that into the expression for the weights $w_A(x)$ and $w_B(x)$.

In the present case, we know that $\sigma_A^2(x)$ is small for small $|x|$ and large for large $|x|$, and $\sigma_B^2(x)$ is small for large $|x|$ and large for small $|x|$. The following figure illustrates the optimal weight function as a result of variance functions in two examples. The left part shows $\sigma^2_A$ (red), and $\sigma^2_B$ (blue). The right part shows $w_A^*$ (black) and the corresponding sigmoid function $f$ (green), where $$ f(x) = \frac{1}{2}\begin{cases} 1 - w(x),&x>0\\ w(x),&x<0\end{cases} . $$

linear variance function t-distr. shaped variance function

The shape of the optimal sigmoid function depends strongly on the underlying variance functions, in a complicated way. I would therefore recommend to model the variance functions, rather than the corresponding sigmoid.

May we calculate weights from the data?

In practice, the true $x$ is unknown, and weights are calculated from the actual measurements $x_A$ and $x_B$ are measurements. So the original suggestion boils down to calculating the weighted mean $$ \bar x_w = \frac{w_A(x_A)x_A + w_B(x_B)x_B}{w_A(x_A)+w_B(x_B)}. $$

Using the data instead of the true value to find the weight may strictly spoken introduce a bias, since the weights are now random and depend on the data, and $\bar{X}_w$ is nonlinear in $A$ and $B$.

We can show (by a symmetry argument), that $\bar{X}_w$ is unaffected by bias, when

  • the measurement errors have a symmetric distribution,
  • measurements are unbiased, and
  • the weight functions are symmetric around zero.

When these conditions are grossly not met, you can investigate whether or not this bias is important and outweighs the improved precision by a simulation study that tries to mimic the original data.

Estimating the variance function from time series data

The scientific context of this question are measurements of sap flow velocities. Such data are time series with a distinct diurnal pattern. Restricted to a period with similar conditions (same tree, same weather, ...), it would be justified to model them as a periodic (aka seasonal) time series with time-varying variance.

You should then be able to express both the true value $x(t)$ (hopefully the mean of unbiased measurement) and the variance $\sigma^2(t)$ for A and B separately as a function of time $t$. Thus, you obtain data $\big(\hat x(t), \hat \sigma^2(t)\big)$ for many time points $t$. From these data, a relation $x\to \sigma^2$ can be established, where variances from different times with same mean $x(t)$ are averaged:

  • by regression, if you assume a parametric model for the variance functions $\sigma^2_A(x), \sigma^2_B(x)$, or
  • constructing a look-up table, preferably using some kind of smoothing (kernel or splines), see Nonparametric regression.
Ute
  • 2,580
  • 1
  • 8
  • 22
1

Typically, one could use inverse variance weighing and combine the average of measurement values with a weighing function like $w_i = 1/\sigma_i^2$. The problem here is that the variance seems to be a function of the unknown speed.

As alternative you could use an iteratively re-weighted least squares approach where you estimate the variance $\sigma_i^2$ based on an initial estimate (e.g. based on equal weights) and iteratively re-compute a new estimate of the velocity based on estimates of the variances and weights computed with the previous estimate of the velocity.

A requirement for this approach is an estimate of the (relative) dependency of the variance on velocity. If there are some unknown parameters in this dependency then potentially you can use a machine learning approach and optimize the parameters based on cross validation (for which you still need some standard to determine the performance).

  • @DavidMoore I have been assuming that your question is an issue with accuracy that is purely due to a difference in precision/variance, and not about a more general concept of accuracy which may also include bias. https://en.wikipedia.org/wiki/Accuracy_and_precision Could you clarify which it is. – Sextus Empiricus Jul 23 '23 at 21:54
  • My understanding is that method A is accurate but not precise for velocities that are large in magnitude and that method B is precise but not accurate for low velocities. As I implied before, method A is both accurate and precise for low velocities, and method B is both precise and accurate (or at least relatively accurate) for velocities that are large in magnitude. I realize now that the answer to this question may depend on these things, so I'm sorry I didn't specify them before! – David Moore Jul 24 '23 at 15:36
  • @DavidMoore what are the definitions of accuracy that you are using? – Sextus Empiricus Jul 24 '23 at 16:08
  • Accurate values are centered on the true value and precise values have low variability, right? – David Moore Jul 25 '23 at 12:12