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:
> summary(my_model)
Linear mixed-effects model fit by REML
Data: my_data
AIC BIC logLik
471.7855 497.7353 -228.8928
Random effects:
Formula: ~pH | Paper
Structure: General positive-definite, Log-Cholesky parametrization
StdDev Corr
(Intercept) 4.4808759 (Intr)
pH 0.4783127 -0.88
Residual 0.4154606
Fixed effects: Bacterial_diversity ~ pH + I(pH^2)
Value Std.Error DF t-value p-value
(Intercept) 1.6641091 1.8078372 285 0.920497 0.3581
pH 1.1750097 0.4670426 285 2.515851 0.0124
I(pH^2) -0.1187954 0.0363455 285 -3.268508 0.0012
Correlation:
(Intr) pH
pH -0.895
I(pH^2) 0.763 -0.959
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-4.2091539 -0.4574020 0.1168270 0.6216446 2.0828655
Number of Observations: 304
Number of Groups: 17
I don't really know 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-value is 0.0012 (for the quadratic term of pH) and 0.0124 (for the pH).
Are the R^2 values calculated for the whole model? and how can I interpret the R^2 values? Can I say that my data are more likely to fit a quadratic term than a linear regression (due to the more significant p value of the pH^2)?
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!).
I just want to show the relation between the pH and the bacterial diversity with respect to the different studies
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.