# Marginal and Conditional R2 for Linear Mixed Models

Hello,

I'm investigating bacterial diversity and want wo know if the diversity is dependent on the pH. My data are structured as followed:

• I have a dataset of 17 different studies
• each study has values for diversity and for pH (the number of values differ between the studies)

Now I am searching for a way to answer the question "Is there a effect of the pH on the diversity throughout all studies"

The idea was to use the function lme and set study as random factor. Looking at the data they seem to rather fit a quadratic term than a linear regression, so I tried to calculate the model also with the quadratic term of the pH:

my_model<- lme( fixed = Bacterial_diversity ~ pH +
I(pH^2),
random = ~ pH |Study,
data= my_data)

The output (summary) is:

I have absolutely no idea how to interpret these results. When I use tab-model (my_model) I end up with two R^2 values. The marginal R^2 (0.025) and the conditional R^2 (0.974), the given p-values is 0.0012 (for the quadratic term of pH) and 0.0124 (for the pH).
Is the given p-value true for both of the R^2 values or are they calculated for the whole model? and how can I interpret the R^2 values.

Is even the model I used the right one or should I have used nlme instead of lme4 (I don't really understand the difference!).

If you have any ideas this would help a lot.
And if there are questions regarding the data, the code or anything else, please feel free to ask.

Thanks to everyone Since pH is highly statistically significant, wouldn't that establish that it has an effect?

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9121411,"math_prob":0.87330955,"size":1444,"snap":"2023-14-2023-23","text_gpt3_token_len":354,"char_repetition_ratio":0.115277775,"word_repetition_ratio":0.0,"special_character_ratio":0.25415513,"punctuation_ratio":0.083333336,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.980989,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-24T21:28:30Z\",\"WARC-Record-ID\":\"<urn:uuid:515e4a72-13c8-45b6-a1e8-16c49d427c42>\",\"Content-Length\":\"25738\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:38fb0f5a-3de9-464c-bd97-eb98f3a469ff>\",\"WARC-Concurrent-To\":\"<urn:uuid:910cdb2d-2192-4843-833d-3941c95ea936>\",\"WARC-IP-Address\":\"167.99.20.217\",\"WARC-Target-URI\":\"https://community.rstudio.com/t/marginal-and-conditional-r2-for-linear-mixed-models/152071\",\"WARC-Payload-Digest\":\"sha1:7W4M2HFURCRVGAK5BVA4QDXESKJ3ZQII\",\"WARC-Block-Digest\":\"sha1:YZX5ZCGTRKI2S2YTDPDBYUFMVB4AGSOW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296945289.9_warc_CC-MAIN-20230324211121-20230325001121-00107.warc.gz\"}"}