JonSulc / PolyMR

Polynomial Mendelian randomization for the inference of non-linear causal effects
GNU General Public License v3.0
13 stars 1 forks source link

Plotting of observations #1

Open lgarvert opened 2 months ago

lgarvert commented 2 months ago

Hello Jonathan, Thank you for developing this method. I have a question about how the observations are plotted in the figures. In the paper, "the red points show the mean outcome plotted against the median exposure..." (Figure 4). But in plot_polymr.R, the median of both, the exposure and the outcome ,is plotted, which causes the observations to no longer lie within the 95% confidence interval. Is this change intentional or is it a mistake in the script?

Best, Linda

JonSulc commented 2 months ago

Hi Linda,

The change from mean to median was intentional though it admittedly does not matter too much which is used. I believe the observations being plotted outside of the 95% confidence interval is a separate issue with the intercept not being properly displayed in either the observations or the causal function, an issue I am aware of but have not had time to address yet. I'll try to have a look at it and see if it can be patched easily.

Best, Jonathan

On Fri, Jul 26, 2024 at 6:49 PM Linda @.***> wrote:

Hello Jonathan, Thank you for developing this method. I have a question about how the observations are plotted in the figures. In the paper, "the red points show the mean outcome plotted against the median exposure..." (Figure 4). But in plot_polymr.R, the median of both, the exposure and the outcome ,is plotted, which causes the observations to no longer lie within the 95% confidence interval. Is this change intentional or is it a mistake in the script?

Best, Linda

— Reply to this email directly, view it on GitHub https://github.com/JonSulc/PolyMR/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANBBSZJU2T6KRDMUK3AOT3ZOJ4YZAVCNFSM6AAAAABLQ3EJZGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZTENRQGE2DIOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

JonSulc commented 2 months ago

Nevermind, I checked and it is behaving properly. The issue that I was referring to (which I thought I hadn't fixed yet) was that the bias estimated for the function was applied to the function itself but not the observations (or vice versa), but as far as I can tell, it's displaying properly.

I'm assuming you are referring to the spread of the binned observations around the estimated function, which can easily fall outside the 95% confidence interval. This is normal. The 95% confidence interval is not expected to contain 95% of the observations (in which case we would expect these binned observations to fall generally within the confidence interval). The spread of the observations is simply due to the variance and uncertainty, which can come from other external factors or noise. Essentially, if we have an outcome y which is associated with the exposure x, we can split y into x-dependent and independent parts: y = f(x) + e where e includes everything from external factors to measurement error. The function that is plotted is f(x) and the confidence interval refers to its estimation. The added e will generally cause most individual observations to fall outside of the confidence interval and will often shift the median outside of the confidence interval as well. The switch to use the median rather than the mean was partly to decrease this (since the median is less sensitive to outliers).

Let me know if this isn't what you were referring to or if you still have questions!

Best, Jonathan

On Mon, Jul 29, 2024 at 5:26 AM Jonathan Sulc @.***> wrote:

Hi Linda,

The change from mean to median was intentional though it admittedly does not matter too much which is used. I believe the observations being plotted outside of the 95% confidence interval is a separate issue with the intercept not being properly displayed in either the observations or the causal function, an issue I am aware of but have not had time to address yet. I'll try to have a look at it and see if it can be patched easily.

Best, Jonathan

On Fri, Jul 26, 2024 at 6:49 PM Linda @.***> wrote:

Hello Jonathan, Thank you for developing this method. I have a question about how the observations are plotted in the figures. In the paper, "the red points show the mean outcome plotted against the median exposure..." (Figure 4). But in plot_polymr.R, the median of both, the exposure and the outcome ,is plotted, which causes the observations to no longer lie within the 95% confidence interval. Is this change intentional or is it a mistake in the script?

Best, Linda

— Reply to this email directly, view it on GitHub https://github.com/JonSulc/PolyMR/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANBBSZJU2T6KRDMUK3AOT3ZOJ4YZAVCNFSM6AAAAABLQ3EJZGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZTENRQGE2DIOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>