<p>You're actually not correct about the functional form of the logit. It's nonlinear, but you've written a linear function.</p>
<p>That matters here because once you understand the functional form of logistic regression, you can write it in a way that relates it to your specific generative model for your data. That can tell you what features you ought to use if your model assumptions are correct. You can find the details in PRML section 4.2 (<a href="https://www.microsoft.com/en-us/research/uploads/prod/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf" rel="nofollow noreferrer">pdf</a>). The essence is:</p>
<ul>
<li>If your class labels are generated from a mixture of two classes with prior probabilities <span class="math-container">$\pi_1$</span> and <span class="math-container">$\pi_2$</span></li>
<li>If your covariates are generated from exponential-family distributions with densities proportional to <span class="math-container">$\exp(\beta_1^T\Phi(x))$</span> and <span class="math-container">$\exp(\beta_2^T\Phi(x))$</span></li>
</ul>
<p>then the posterior probability that an observation <span class="math-container">$x$</span> is in class 1 is</p>
<p><span class="math-container">$$\frac{\pi_1\exp(\beta_1^T\Phi(x)) }{\pi_1\exp(\beta_1^T\Phi(x)) + \pi_2\exp(\beta_2^T\Phi(x))$}$$</span>. If you plug in known class labels and mangle this for a while with algebra, you end up with a logistic regression using features <span class="math-container">$\Phi(x)$</span>. The intercept term of the logistic regression turns into a function of <span class="math-container">$\pi_1/\pi_2$</span>.</p>
<p>If your data are Gaussian, then <span class="math-container">$\Phi(x)$</span> would generally include <span class="math-container">$x$</span> and <span class="math-container">$x^2$</span> and all the cross-terms if <span class="math-container">$x$</span> is multivariate. If there are special assumptions about equal covariance between classes, then the squared terms and cross terms may not be needed.</p>

CC BY-SA 4.0
2022-02-07T22:37:46.463Z
2022-02-07T22:37:46.463Z
eric_kernfeld
<p>I have a training set of RT-qPCR gene expression data (not run in triplicate) for a batch of samples with two phenotypes <span class="math-container">$A$</span> and <span class="math-container">$B$</span> on which I've trained a &quot;logistic regression classifier&quot;.</p>
<p>I also have another smaller set of samples which have been run twice as technical replicates on the RT-qPCR machine in order to study the effect of qPCR noise on my classifier.</p>
<p>I have a particular cut-off probability <span class="math-container">$P$</span> for my logistic regression model, such that we must be at least <span class="math-container">$P$</span> confident to classify a test sample as <span class="math-container">$A$</span> (similarly for <span class="math-container">$B$</span>), otherwise no classification is returned.</p>
<p>I would like to incorporate the effect of RT-qPCR noise into my logistic classifier in order to return a more accurate classification probability for a particular test sample.</p>
<p>My model for the RT-qPCR noise for a particular sample <span class="math-container">$i$</span> is given by</p>
<p><span class="math-container">$$X_i\sim N(\mu_i, \sigma^2I).$$</span></p>
<p>The logit is then given by</p>
<p><span class="math-container">$$t_i = \beta_0 + \beta^TX_i,$$</span></p>
<p>with distribution</p>
<p><span class="math-container">$$t_i\sim N(\beta_0+\beta^T\mu_i, \sigma_t^2),$$</span></p>
<p>where <span class="math-container">$\sigma_t^2=\|\beta\|_2^2\sigma^2$</span>.</p>
<p>Since <span class="math-container">$\mu_i$</span> is a nuisance parameter, we eliminate it by taking the difference of the two replicates for a particular sample</p>
<p><span class="math-container">$$Z_i=t_i^{(1)} - t_i^{(2)} \sim N(0, 2\sigma_t^2).$$</span></p>
<p>We can then form the MLE of <span class="math-container">$\sigma_t^2$</span> by computing</p>
<p><span class="math-container">$$\hat{\sigma}_t^2=\frac{1}{2N}\sum_{i=1}^NZ_i^2.$$</span></p>
<p>Therefore, for a particular test sample <span class="math-container">$x_i$</span>, we compute the expected value of the logit-normal distribution with location <span class="math-container">$t_i$</span> and squared scale <span class="math-container">$\hat{\sigma}_t^2$</span></p>
<p><span class="math-container">$$p_i=\int_0^1x\frac{1}{\sqrt{2\pi\hat{\sigma}_t^2}}\frac{1}{x(1-x)}e^{-\frac{(\text{logit}(x)-t_i)^2}{2\hat{\sigma}_t^2}}dx.$$</span></p>
<p>The resulting <span class="math-container">$p_i$</span> is then our corrected probability of phenotype <span class="math-container">$A$</span>.</p>
<p><em>Is this a sensible way to achieve my stated goal?</em></p>
<p>Here is an example plot of the necessary correction when the squared scale is <span class="math-container">$\sigma^2=2$</span>,</p>
<p><a href="https://i.sstatic.net/EWPBKm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/EWPBKm.png" alt="enter image description here" /></a></p>
<ul>
<li><p>The black line corresponds to a qPCR assay with no noise.</p>
</li>
<li><p>The violet line indicates the corrected probability.</p>
</li>
</ul>
<p>For example, if the regression model says that a sample has a 75% chance of being phenotype <span class="math-container">$A$</span>, then in the corrected model, this actually corresponds to only having about a 65% chance of being phenotype <span class="math-container">$A$</span>.</p>

<gene><r><pcr><noise><gene-expression>
Correcting for noise in RT-qPCR gene expression data
# Correcting for noise in RT-qPCR gene expression data

(Asked by: username_0 on 2018-07-02)

I have a training set of RT-qPCR gene expression data (not run in triplicate) for a batch of samples with two phenotypes $A$ and $B$ on which I've trained a "logistic regression classifier".

I also have another smaller set of samples which have been run twice as technical replicates on the RT-qPCR machine in order to study the effect of qPCR noise on my classifier.

I have a particular cut-off probability $P$ for my logistic regression model, such that we must be at least $P$ confident to classify a test sample as $A$ (similarly for $B$), otherwise no classification is returned.

I would like to incorporate the effect of RT-qPCR noise into my logistic classifier in order to return a more accurate classification probability for a particular test sample.

My model for the RT-qPCR noise for a particular sample $i$ is given by

$$X\_i\sim N(\mu\_i, \sigma^2I).$$

The logit is then given by

$$t\_i = \beta\_0 + \beta^TX\_i,$$

with distribution

$$t\_i\sim N(\beta\_0+\beta^T\mu\_i, \sigma\_t^2),$$

where $\sigma\_t^2=\|\beta\|\_2^2\sigma^2$.

Since $\mu\_i$ is a nuisance parameter, we eliminate it by taking the difference of the two replicates for a particular sample

$$Z\_i=t\_i^{(1)} - t\_i^{(2)} \sim N(0, 2\sigma\_t^2).$$

We can then form the MLE of $\sigma\_t^2$ by computing

$$\hat{\sigma}\_t^2=\frac{1}{2N}\sum\_{i=1}^NZ\_i^2.$$

Therefore, for a particular test sample $x\_i$, we compute the expected value of the logit-normal distribution with location $t\_i$ and squared scale $\hat{\sigma}\_t^2$

$$p\_i=\int\_0^1x\frac{1}{\sqrt{2\pi\hat{\sigma}\_t^2}}\frac{1}{x(1-x)}e^{-\frac{(\text{logit}(x)-t\_i)^2}{2\hat{\sigma}\_t^2}}dx.$$

The resulting $p\_i$ is then our corrected probability of phenotype $A$.

*Is this a sensible way to achieve my stated goal?*

Here is an example plot of the necessary correction when the squared scale is $\sigma^2=2$,

[![enter image description here](https://i.sstatic.net/EWPBKm.png)](https://i.sstatic.net/EWPBKm.png)

* The black line corresponds to a qPCR assay with no noise.
* The violet line indicates the corrected probability.

For example, if the regression model says that a sample has a 75% chance of being phenotype $A$, then in the corrected model, this actually corresponds to only having about a 65% chance of being phenotype $A$.

**Tags:** gene, r, pcr, noise, gene-expression

---

## 1 answers

### Answer by username_1 on 2022-02-07. Score: 1

You're actually not correct about the functional form of the logit. It's nonlinear, but you've written a linear function.

That matters here because once you understand the functional form of logistic regression, you can write it in a way that relates it to your specific generative model for your data. That can tell you what features you ought to use if your model assumptions are correct. You can find the details in PRML section 4.2 ([pdf](https://www.microsoft.com/en-us/research/uploads/prod/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf)). The essence is:

* If your class labels are generated from a mixture of two classes with prior probabilities $\pi\_1$ and $\pi\_2$
* If your covariates are generated from exponential-family distributions with densities proportional to $\exp(\beta\_1^T\Phi(x))$ and $\exp(\beta\_2^T\Phi(x))$

then the posterior probability that an observation $x$ is in class 1 is

$$\frac{\pi\_1\exp(\beta\_1^T\Phi(x)) }{\pi\_1\exp(\beta\_1^T\Phi(x)) + \pi\_2\exp(\beta\_2^T\Phi(x))$}$$. If you plug in known class labels and mangle this for a while with algebra, you end up with a logistic regression using features $\Phi(x)$. The intercept term of the logistic regression turns into a function of $\pi\_1/\pi\_2$.

If your data are Gaussian, then $\Phi(x)$ would generally include $x$ and $x^2$ and all the cross-terms if $x$ is multivariate. If there are special assumptions about equal covariance between classes, then the squared terms and cross terms may not be needed.


---

