microeco
microeco copied to clipboard
Two-Way ANOVA and Linear MIX Model
Hi again Chi,
I have a question and maybe a suggestion.
- I've seen that for beta diversity is possible to do the following:
trans_beta$cal_manova(cal_manova_set = "Treatment + Week")
using two variables in the PERMANOVA: Treatment and Week. What is the difference between doing that and doing two independent PERMANOVAs? trans_beta$cal_manova(cal_manova_set = "Treatment") trans_beta$cal_manova(cal_manova_set = "Week")
- I also think it would be interesting for alpha diversity and maybe also for relative abundance comparison to add the Linear Mix Model comparison for significant differences (library(lme4)) when we are comparing more than one variable (for example Treatment and Week) and maybe also the Two-Way ANOVA.
Thank you so much in advance :D
Alberto
Hi Alberto,
Good suggestion! Do you mean some operations in alpha diversity like this:
data(dataset)
t1 <- trans_alpha$new(dataset = dataset)
t1$cal_diff(method = "anova", anova_set = "Group + Type")
t1$res_diff
If the function finds the anova_set parameter input, it will run like this two-way. I will also add this in relative abundance comparison part, i.e. trans_diff class. There is anova in it, but two-way is not supported in the current version as the format has some issues. I will fix it. Thanks very much for your great suggestion!
Best, Chi
But if I type it like this:
data(dataset) t1 <- trans_alpha$new(dataset = dataset) t1$cal_diff(method = "anova", anova_set = "Group + Type") t1$res_diff
is a two-way ANOVA?
Regards,
Alberto
Yes. The bottomed function will run something like this
div_table <- t1$data_alpha[t1$data_alpha$Measure == "Shannon", ]
test <- aov(Value ~ Group + Type, div_table)
anova(test)
Best, Chi
Hi Chi,
what I was looking for was: t1 <- trans_alpha$new(dataset = dataset) t1$cal_diff(method = "anova", anova_set = "Group * Type") t1$res_diff
Because with the "*" I can also check whether there are interactions between both variables, in case it helps anybody.
However, first I checked if my alpha diversity output data were parametric (normality and homoscedasticity) and they are not, so it would be nice to include any non-parametric alternative to the two-way ANOVA, like the Two Way Friedman's Analysis of Variance by Ranks and the Linear Mix Model for two factors.
Regards,
Alberto
Hi Alberto,
Could you please give me a toy example and steps of Friedman's Analysis of Variance using a small dataset of yours? The example dataset I implement in the package is not good to show the usage. I also want to see whether the way you need is same with what I understand. After making sure the contents, I will add the method in the trans_alpha class. Thanks.
Best, Chi
Hi Chi,
I do not have an example with my data because I've never tried since it's the first time I work with two independent variables on non-parametric data but I found this nice example on the internet:
https://www.statisticshowto.com/friedmans-test/
Best,
Alberto
I got it! I will think about how to better implement those models in next two days. Thanks.
Best, Chi
Hi Alberto,
The Scheirer Ray Hare test has been implemented in trans_alpha and trans_diff as the nonparametric test used for a two-way factorial experiment similar with two-way anova. Now the parameter anova_set in trans_alpha$cal_diff has been replaced with formula to generalize the method implementation. Please check the updated package in github. Thanks for your suggestion!
Best, Chi
Thank you Chi!
So if now I want to use the Scheirer Ray Hare test to know the effect of Group and Type in the dependent variable (Chao1 for example) what should I write:
t4 <- trans_alpha$new(dataset = dataset) t4$cal_diff("?")
Alberto
You need update the package from github. Then please check the document of trans_alpha class with ?trans_alpha
. Then click trans_alpha$cal_diff()
. You can find the scheirerRayHare
option in the method
parameter. Here is my example.
rm(list = ls())
library(microeco)
data(dataset)
t1 <- trans_alpha$new(dataset = dataset)
# I use formula now instead of previous anova_set
t1$cal_diff(method = "scheirerRayHare", formula = "Group*Type")
View(t1$res_diff)
Please also remember to install rcompanion
package, which is the dependency.
Chi
Thank you Chi. But the moment the comand doesn't work, it gives me "Non-valid argument" but probably is because I have to update microeco or something like that... I guess.
Regards,
Alberto