ThisIsLorenzo / PFAS_Trophic_Magnification

0 stars 0 forks source link

Slope values not matching #4

Open ThisIsLorenzo opened 1 month ago

ThisIsLorenzo commented 1 month ago

https://github.com/ThisIsLorenzo/PFAS_Trophic_Magnification/blob/5cbb386e143dab834b8d4d3e96e67ff671f41682/R/code.Rmd#L532

Hi @itchyshin , I have a question for you.

I have been extracting raw data from regression plots and running linear models to calculate slope and SE values. However, I noticed that my calculated slope values sometimes do not match those from the studies. For example, Liu et al. (2008) provide slope values but not SE. That's why I have been running linea models, to find the SE. Let's take PFBA as an example:

Untfffitled

However, they provide the regression plot. So I extracted the raw PFBA concentrations and TL values for each data point: image Concentrations in the plot are not log-transformed so I extracted them as they are in the original scale and then log-transformed them using Euler's number as base because that's the formula that the study used. From this:

Untfffitled

to this:

Untitldsvdfed

And then I run the linear model (I could not assign weights because SE or SD are nor provided - the plot is a scatter plot): Liu_2018_lm_model_PFBA <- lm(log_PFBA_mean ~ TL_mean, data = Liu_2018) And got the regression results:

summary(Liu_2018_lm_model_PFBA) Estimate: 1.0686 Std. Error: 0.4084

This slope result does not match with what they provide (see figure 1 in this issue). Their slope is 0.249 and our slope is 1.0686 ± 0.4084.

I do not understand why results differ so much. Do you have any idea?

itchyshin commented 1 month ago

@ThisIsLorenzo - I am not sure but didn't they run the analysis without log? (TL levels do not need to be log transformed too? - I am not sure - remind me of how people model trophic magnification again?) log(conc) ~ TL? or log(conc) ~ log(TL)?

ThisIsLorenzo commented 1 month ago

ln[PFAS] = TL(slope) + intercept or log[PFAS] = TL(slope) + intercept

This is from the study I took as an example: image So the slope they report is calculated using the natural log of [PFAS]. However, the plot showing the regression has [PFAS] on the original scale. For this reason I log transformed (natural log) the extracted raw data before regressing them.

ThisIsLorenzo commented 1 month ago

I also get a different slope value if I use natural log-transformed or log10-transformed [PFAS], which I do not understand it does not make sense. Anyway, neither of these results match with what the study reports.

itchyshin commented 1 month ago

Did you try without logging? the authors made mistakes?

ThisIsLorenzo commented 1 month ago

I also get a different slope value if I use natural log-transformed or log10-transformed [PFAS], which I do not understand it does not make sense.

The following is another example. The point estimate and the SE change if we regress log[PFAS] or ln[PFAS]: image

I think I was wrong. The slopes calculated using ln[PFAS] and log[PFAS] are NOT COMPARABLE! However, the TMF are comparable: image This changes everything because we need to use TMF values and not TMS values. I don't know why I was so convinced about using the slope....it was a silly mistake. I'll tell you about this in our next meeting @itchyshin

itchyshin commented 1 month ago

@ThisIsLorenzo All good - We should expect different values when we use log10 or loge - I thought we discussed this - but t values stay the same (so TMF too - I thought I showed this exact calculation in R during one of the meetings? - but often it is hard to know what people are saying till you find it out yourself) We can discuss the other slope issues at our meeting next time

itchyshin commented 1 month ago

Also, this is where the delta method is important as you need to turn slope SE into exp and 10^ conversions - and this is where I was talking about the delta method intially

ThisIsLorenzo commented 1 month ago

@ThisIsLorenzo All good - We should expect different values when we use log10 or loge - I thought we discussed this - but t values stay the same (so TMF too - I thought I showed this exact calculation in R during one of the meetings? - but often it is hard to know what people are saying till you find it out yourself) We can discuss the other slope issues at our meeting next time

All good - the important is that now it is clear to me. Yes, we can talk about the other issues at our next meeting

ThisIsLorenzo commented 1 month ago

https://github.com/ThisIsLorenzo/PFAS_Trophic_Magnification/blob/5cbb386e143dab834b8d4d3e96e67ff671f41682/R/code.Rmd#L532

Hi @itchyshin , I have a question for you.

I have been extracting raw data from regression plots and running linear models to calculate slope and SE values. However, I noticed that my calculated slope values sometimes do not match those from the studies. For example, Liu et al. (2008) provide slope values but not SE. That's why I have been running linea models, to find the SE. Let's take PFBA as an example: Untfffitled

However, they provide the regression plot. So I extracted the raw PFBA concentrations and TL values for each data point: image Concentrations in the plot are not log-transformed so I extracted them as they are in the original scale and then log-transformed them using Euler's number as base because that's the formula that the study used. From this: Untfffitled to this: Untitldsvdfed

And then I run the linear model (I could not assign weights because SE or SD are nor provided - the plot is a scatter plot): Liu_2018_lm_model_PFBA <- lm(log_PFBA_mean ~ TL_mean, data = Liu_2018) And got the regression results:

summary(Liu_2018_lm_model_PFBA) Estimate: 1.0686 Std. Error: 0.4084

This slope result does not match with what they provide (see figure 1 in this issue). Their slope is 0.249 and our slope is 1.0686 ± 0.4084.

I do not understand why results differ so much. Do you have any idea?

Going back to the original problem in this issue (slopes not matching), I have just compare all calculated slopes with the provided slopes. Most of them match (not perfectly but that's normal). I will double check those that do not match to try to understand why they do not.