genostats / Ravages

5 stars 3 forks source link

Formula for control group genotypic frequency in vignette #4

Closed sahirbhatnagar closed 1 year ago

sahirbhatnagar commented 1 year ago

I think there is a missing denominator in this formula in the vignette: https://github.com/genostats/Ravages/blob/38c8081ffc2c8975ba9a6695ed20181b49ae34b7/vignettes/Ravages_Simulations_vignette.Rmd#L38

It should be $$P(Geno | Y=1)=\frac{P(Geno) - \sum{_{c=2}^{c=C} P(Geno | Y=c) P(Y=c)}}{P(Y=1)}$$

This would be consistent with the code in the function p.tem.GRR: https://github.com/genostats/Ravages/blob/38c8081ffc2c8975ba9a6695ed20181b49ae34b7/R/genotypic.freq.r#L95-L96

Ozvan commented 1 year ago

There is no mistake in the formula from the vignette. This formula comes from the law of total probabilities where: $$P(Geno) = \sum{_{c=1}^{c=C} P(Geno | Y=c) P(Y=c)}$$ P(Geno | Y=1) is then derived from this.

sahirbhatnagar commented 1 year ago

Thanks for you response. I agree with your formula for total probability, but then I don't see how you do not have a denominator in the vignette formula. Here is the derivation for 2 groups (control = 1, case = 2). $$P(Aa) = P(Aa|Y=1) P(Y=1) + P(Aa|Y=2)P(Y=2)$$

$$P(Aa|Y=1) = \frac{P(Aa) - P(Aa|Y=2)P(Y=2)}{P(Y=1)}$$

Ozvan commented 1 year ago

Yes sorry you are right, I was mistaken with another formula. I will change the vignette accordingly, thanks !