简体   繁体   English

如何在R中的GLM上执行类似TukeyHSD的测试?

[英]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. 我正在尝试分析我在R中创建的glm,我想要做的是成对比较我的哪些因素与Anovas的TukeyHSD测试类似,彼此之间有显着差异。 However I have been told that TukeyHSD does not work for GLM's. 但是,有人告诉我TukeyHSD不适用于GLM。 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. 经过研究后,我发现了两个选项,但我不确定哪个是正确的或适用的是glht或对比度命令。

Here is the code for the GLM. 这是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). 我希望根据我的大型植物的因素(即是否存在大型植物的种类,可以选择不适用,不适用C或E的选项)来更改体型变量。 and the leaves have three options of without, q1 , q2 ) 并且叶子具有不带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). 没有大型植物Q1叶子-没有大型植物Q2叶子(然后是一个值,表示它们彼此之间是否存在显着差异,例如ap值)。

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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