ThisIsLorenzo / Maternal_PFAS_transfer_WildBirds

https://thisislorenzo.github.io/Maternal_PFAS_transfer_WildBirds/
0 stars 0 forks source link

Life stage as predictor in full model and model selection #2

Open ThisIsLorenzo opened 2 months ago

ThisIsLorenzo commented 2 months ago

https://github.com/ThisIsLorenzo/Maternal_PFAS_transfer_WildBirds/blob/73df5d6f0e1cf0ab8c5ea7b2cdc516a9c0566be1/R/Code_SN.Rmd#L1632C2-L1632C4

The life stage of progeny (life_stage_P) is a variable with two levels: egg and chick. We hypothesized it could explain variation in lnRR because of the dilution of PFAS in chicks. For this reason, we included it in the full model. The output of the full model with or without the life stage of progeny does not change because it does not appear in any case. It probably disappear because one level becomes intercept and the second level is dropped with the NAs. However, when we run model selection, it appears again. This is the model selection table with life stage of p: image This is the model selection table without life stage of p: image This is the sum of weight including life stage of p: image This is the sum of weight not including the life stage of p: image

The question is:

  1. Should we include the life stage of p in the full model and thus in the model selection?

Also, we want to test the statistical significance of the carboxylate group in the functional group variable. We cannot simply take the result from the full model because that result is not marginalised. So we want a marginalised result. To do so, we can run mod_result() function over the full model.

However, I do not know how to do it.

@itchyshin HELP

itchyshin commented 2 months ago

OK - I reran without p and get slightly different results.

Screenshot 2024-04-29 at 5 47 46 PM

This is probably what we want to present. Also, I can get marginalized functional group results. I do not think we should talk about what is different from 0, but we should only concentrate on what is different from what, and none of these are different from each other (and that was the case in the univariable model - we should discuss this point). the model selection suggests functional group is not that important, and you can see why from the orchard plot

Screenshot 2024-04-29 at 5 50 54 PM Screenshot 2024-04-29 at 5 50 59 PM

ThisIsLorenzo commented 2 months ago

Ohhh...I see. complete.cases() identifies complete cases in 'dat', meaning rows where there are no missing values across all variables. life_stage_P is one-level variable once NAs are dropped and you double-checked this using function complete.cases() (very useful in this case). image Then you changed the VCV matrix: VCV_lnRR2 <- impute_covariance_matrix(data_p$var_lnRR, cluster = data_p$measurement_ID_A, r = 0.5) and rerun the full model with the new VCV (tes0 or test1?) For model selection, you suggested using ML (not the default REML) to estimate the model. mod.candidate <- dredge(full_model1, evaluate = TRUE, rank = "AICc", trace = 2) I think I kind of understand what you did but it would be very useful to discuss about it @itchyshin

ThisIsLorenzo commented 2 months ago

The model selection table is indeed changed now. image As well as the sum of weights: image This change partially affects our results. So, the part that is the least clear to me is the VCV change so we might want to discuss it. From my understanding, the results that change from the manuscript are both the full model and model selection results.

ThisIsLorenzo commented 2 months ago

However, I still cannot run the mod_results() function, as I get the same error as before. image The results of the full model are slightly different now. image and the manuscript needs to be adapted to this.

itchyshin commented 2 months ago

@ThisIsLorenzo - do you want to update your R, Rstudio etc? (or is it the latest one)

ThisIsLorenzo commented 2 months ago

RStudio is up to date. R is version 4.3.1. I've also installed version 4.4.0 updated packages and and dependencies but when I try to run the code I get an error straight away: image I tried to Google it, but nothing came out. The code runs well if I move back to version 4.3.1. I tried restarting PC but the error persists.