简体   繁体   中英

How do I perform a TukeyHSD like test on a GLM in R?

I'm trying to analyse a glm I created in R and what I'd like to do is get a pairwise comparison of which of my factors are significantly difference from eachother similar to the TukeyHSD test for Anovas. However I have been told that TukeyHSD does not work for GLM's. After doing some research I've found a couple of options and I'm not sure which one is correct or applicable those are the glht or contrast commands.

Here is the code for the GLM.

glm.mod <- glm(as.numeric(Ostra..Avg.body.size) ~ as.factor(Macrophytes)*as.factor(Leaves)*as.factor(MacrophyteintLeaves) = 'gaussian', data = main)

The body size variable is what I expect to change based on my factors of Macrophytes (which is the presence/absence of species of macrophyte with the options Without for none, C or E for different species). and the leaves have three options of without, q1 , q2 )

Here is an example of what my data looks like (with made up values)

Macrophyte  Leaves  Animals CODE    Ostra. Avg body size
Without     Q1        N       1     11000
E           Q2        Y         2   11853
C           without     N     3     13422
Without     Q1          Y     4     13838

How would I get an output that shows me if there is an effect for example

without Macrophytes Q1 Leaf - without Macrophytes Q2 leaf (Then a value denoting if they have are significantly different from each other such as ap value).

Any help would be greatly appreciated and thanks in advance.If there is any important info I have missed please tell me.

具有一个数字响应变量和一个(或几个)分类预测变量,我通常将使用以下函数对每个主要效应(例如,仅大型植物;仅叶片)和相互作用效应进行显着性的成对比较:

TukeyHDS(aov(as.numeric(Ostra..Avg.body.size) ~ as.factor(Macrophytes)*as.factor(Leaves)*as.factor(MacrophyteintLeaves)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM