5
$\begingroup$

I recently asked the following over at the Chemistry StackExchange (https://chemistry.stackexchange.com/q/140291/37658) and folks there suggested it might be better asked here. So, here goes:

I have a data set comprising the peak areas of an analyte (response variable) measured in spiked calibration samples at 'known' and different concentrations levels (predictor variable). For each concentration level I have 5 replicates. My goal is to generate a calibration curve (via regression) from this data and then, for each concentration level, determine the precision of the 'estimated concentration' expressed as percent coefficient of variation (%CV).

If a linear relationship existed between the measured peak areas and 'known' concentrations, then for each concentration level I would simply calculate %CV as the standard deviation of the estimated concentration at a given 'known' concentration level and divide by the mean of the same estimated concentrations, before multiplying by 100. For my data set, however, I observe an inadequate linear (i.e. straight line) fit between measured peak areas and 'known' concentrations. Furthermore, there is heteroscedacity of the residuals when fitting a linear model.

To address the above, I've performed a log10 transformation of BOTH peak area and 'known' concentration. An adequate linear fit is observed. I would now like to calculate the precision (coefficient of variation, %CV) of the estimated peak area based on this model.

According to the article cited below, the %CV for log-transformed data would be calculated as:

$$ \%CV(\text{estimated concentration}) = 100\% * \sqrt{10^{ln(10){\theta}^2_{\text{log}} −1}} $$

Where (if I understood correctly): ${\theta}^2_{\text{log}}$ is the variance of the log-transformed data.

So, I would specifically like to know (or to receive help understanding): is the formula proposed by Canchola, et al. appropriate in the case where BOTH the response (i.e. peak area) and predictor (i.e. 'known' concentration) variables have been transformed?

In my mind, seeing as I would consider the variable of the estimated concentration on the log10-transformed scale, the formula outlined by Canchola, et al. should be fine.

Finally: if I had only log10-transformed the peak areas and then estimated the concentration (i.e. log-linear relationship), would I need to use the Canchola, et al. equation?

Referenced article: Jesse A. Canchola, Shaowu Tang, Pari Hemyari, Ellen Paxinos, Ed Marins, "Correct use of percent coefficient of variation (%CV ) formula for log-transformed data," MOJ Proteomics & Bioinformatics 2017, 6(4), 316-317 (DOI: 10.15406/mojpb.2017.06.00200).

EDIT

I thought a minimum working example would be useful to confirm my understanding. Prepared in R. Do CV_X and CV_Y represent what I describe and are they correctly calculated?

#sample 1000 random values from log-normal distribution
set.seed(1)
X = rlnorm(1000, meanlog = 3, sdlog = 0.8)

# ln-transform X
ln_X = log(X, base = exp(1))

#plot raw and ln-transformed data
hist(X, breaks = 20)

Histogram of raw X values, i.e. log-normally distributed data

hist(ln_X, breaks = 20)

Histogram of ln-transformed X values, hence normally distributed

#calculate variance of ln-transformed values
lambda = var(ln_X)
lambda_squared = lambda^2

#calculate %CV for ln-transformed data (i.e. Y)
sigma_squared = var(ln_X)
ln10 = log(10, base = exp(1)) # ln(10)
CV_Y = sqrt( (10^(ln10 * sigma_squared)) - 1) * 100
#CV_Y (i.e. %CV of ln-transformed data) = 607.25%

#calculate %CV on original X scale
CV_X = sqrt( (exp(1)^lambda_squared) - 1) * 100
#CV_X (i.e. %CV of original data) = 77.44%
$\endgroup$
4
  • $\begingroup$ I have to look into that formula. But in any case the transformation of the x-axis has no effect on the variance of the predicted values. The observations, the peak areas, and their variance, don't care about how you scale the x-axis. This change of the scale on the x-axis can be seen as stretching and reshaping the graph in the horizontal direction, which has no effect on the (conditional) distribution of the points in the vertical direction. For instance the conditional distribution of the peaks is the same conditional on x=10 as log(x)=1. $\endgroup$ Commented Sep 16, 2020 at 21:19
  • $\begingroup$ It is different however when you make some advanced (general) analysis where you do not just consider an error in the $y$ (dependent) but also in the $x$ (independent) value. $\endgroup$ Commented Sep 16, 2020 at 21:20
  • $\begingroup$ Sidenote: just applying logscale to fix a linear relationship and because the graph looks prettier is a bit rough method to fix an observation that is not what you expected. This is common in the experimental sciences, transform the variables/observations untill you get a straight line (but not having any theory supporting the reliability of the method). This practice is not so great because it is a bit cherry picking. It would be better if you have some good ab-initio reasoning behind the transformation. $\endgroup$ Commented Sep 16, 2020 at 21:25
  • $\begingroup$ It's obviously more comfortable to work with linear relationships, but that was just a secondary advantage here. My main motivation was to ensure that the residuals of regression were more homoscedatic. Excellent point though and I totally agree :) $\endgroup$
    – MRJ
    Commented Sep 19, 2020 at 10:17

1 Answer 1

4
$\begingroup$

It is a simple transformation from normal to log-normal.

What the article explains is how to express the CV of a lognormal distributed variable, based on the mean and variance of the underlying normal distributed variable.

That is if $X$ is lognormal distributed then $Y = \ln(X) \sim N(\mu,\lambda^2)$ is normal distributed.

Based on your observations of mean and variance of this normal distributed variable $Y$ ($\mu_Y$ and $\sigma_Y^2$) you can derive the mean, variance, and CV of the lognormal distributed variable $X$.

Namely

$$\begin{array}{} &&\mu_X& =& e^{\mu_Y +\frac{\sigma_Y^2}{2}}\\ &&\sigma_X^2& =& (e^{\sigma_Y^2}-1)e^{2\mu_Y+\sigma_Y}\\ CV(X)&=&\frac{\sigma_X}{\mu_X}& =& \frac{\sqrt{(e^{\sigma_Y^2}-1)e^{2\mu_Y+\sigma_Y}}}{e^{\mu_Y +\frac{\sigma_Y^2}{2}}} &=&\sqrt{e^{\sigma_Y^2}-1} \\ \end{array}$$


I took the above values (for the $\mu_X$ and $\sigma_X$) by copy-pasting from the article on wikipedia.

The reference is making a more thorough derivation based on the moment generating functions $$E[X^t] = E[e^{tY}] = e^{\mu t + \frac{\lambda^2 t^2}{2}}$$

However, note that the equation (3) is a bit confusing. Where the article writes:

$$CV(Y) = \frac{SD(Y)}{E(Y)} = \frac{\sqrt{E(e^{2Y})-\left[E(e^{Y}) \right]^2}}{E(e^Y)} = \frac{\sqrt{e^{2\mu + 2{\lambda^2}}-e^{2\mu + {\lambda^2}}}}{e^{\mu + \frac{\lambda^2}{2}}} = \sqrt{e^{\lambda^2}-1}$$

It should be instead:

$$\overbrace{CV(X) = \frac{SD(X)}{E(X)}}^{\text{parameter $X$ and not $Y$}}= \frac{\sqrt{E(e^{2Y})-\left[E(e^{Y}) \right]^2}}{E(e^Y)} = \frac{\sqrt{e^{2\mu + 2{\lambda^2}}-e^{2\mu + {\lambda^2}}}}{e^{\mu + \frac{\lambda^2}{2}}} = \sqrt{e^{\lambda^2}-1}$$


Does the transformation of the independent variable matter?

You can apply this formula to your data. You have a mean and variance for your log values (which you probably assume are normally distributed) and transform these back which means you will have a mean and variance for a log-normal distributed variable.

It is immaterial that you have transformed the independent variables as well. The distribution of the dependent variable is a conditional distribution (ie. conditional on the independent variable). It doesn't matter in what way you express the independent variable on which you condition, the shape of the conditional distribution does not change.

You can see these conditional distributions as vertical slices, which do not change when you alter the x-axis. This intuitive idea of slices is shown in the images below. Two times it is drawn with a different x-scale (log versus linear). But note that the conditional distributions (highlighted for three cases) are not affected.

This change of the scale on the x-axis can be seen as stretching and reshaping the graph in the horizontal direction, which has no effect on the (conditional) distribution of the points in the vertical direction.

(related is my answer on this question: I know the 95% confidence interval for ln(x), do I also know the 95% confidence interval of x?)

X linear scale

x linear

X log scale

x log scale

Unless you make some advanced general analysis where you do not just consider an error in the y (dependent) but also in the x (independent) value, like Deming regression, then the analysis might be influenced.


for each concentration level, determine the precision of the 'estimated concentration' expressed as percent coefficient of variation (%CV).

An interesting sidenote is that the formula $CV(X)=\sqrt{e^{\sigma_Y^2}-1} $ implies that a homogeneous variance for the log transformed variable (ie. $\sigma_Y$ constant) means a constant CV for the non-transformed variable.


Example computation

#sample 1000 random values from log-normal distribution
set.seed(1)
X = rlnorm(1000, meanlog = 3, sdlog = 0.8)
Y = log(X, base = exp(1))


#calculate %CV of X from log-transformed data (i.e. Y)
CV_X_fromY = (exp(var(Y)) - 1)^0.5*100
CV_X_fromY

#calculate %CV of X with original X data on X scale
CV_X = var(X)^0.5/mean(X)*100
CV_X

this gives the output

[1] 99.23253
[1] 100.3127

which is close. (The discrepancy is because equality is true for the continuous distribution, the pdf, and not for some sample taken from it. The larger the sample size the closer will be the two numbers)

So in this example you compute the CV of X not from the statistics (mean and variance) of X, but from the statistics of your transformed variable Y, which you used in the regression.

$\endgroup$
8
  • $\begingroup$ Dear Sextus Empiricus, thank you for such an excellent and thorough answer! It has really helped me to understand what was happening. I also very much appreciate your efforts in generating demonstrative figures to explain the insignificance of transforming the response variable. Please could you clarify whether your updated equation (3) is correct? From my understanding of your description and of the cited article, shouldn't CV(X) = SD(ln(x)) / mean(ln(x) = SD(Y)/mean(Y)? I agree though that the equation provides a way of calculating the CV for variable X, from ln(X) = Y. $\endgroup$
    – MRJ
    Commented Sep 19, 2020 at 10:11
  • $\begingroup$ @MRJ the coefficient of variation is defined as $$CV(X) = \frac{SD(X)}{MEAN(X)}$$ which becomes in terms of raw moments $$CV(X) = \frac{\sqrt{E(X^2)-E(X)^2}}{E(X)}$$ $\endgroup$ Commented Sep 19, 2020 at 10:47
  • $\begingroup$ The rest of the article is correct, so I it is just a typo in that equation 3. $\endgroup$ Commented Sep 19, 2020 at 10:54
  • 1
    $\begingroup$ "explain the insignificance of transforming the response variable" It is the insignificance of transforming the independent variable. $\endgroup$ Commented Sep 19, 2020 at 11:02
  • 1
    $\begingroup$ @MRJ that's right, now it is correct $\endgroup$ Commented Sep 23, 2020 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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