Skip to main content
added 2603 characters in body
Source Link

EDIT

I've made suggested edits and data str() looks like this:

> str(mod)
tibble [1,549 × 4] (S3: tbl_df/tbl/data.frame)
 $ A           : chr [1:1549] "Low" "Low" "Low" "Low" ...
 $ B           : chr [1:1549] "Low" "Low" "Low" "Low" ...
 $ Round       : Factor w/ 9 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 1 ...
 $ Mating_time : num [1:1549] 0 0 0 0 0 0 0 0 0 0 ...

Although I still get output in Anova (as for the response of the df =1):

> Anova(mod)
Analysis of Deviance Table (Type II tests)

Response: Mating_time
                        LR Chisq Df Pr(>Chisq)    
as.factor(Round       )   35.094  8  2.571e-05 ***
A                          3.749  2    0.15343    
B                          9.024  2    0.01097 *  
A : B                     10.424  4    0.03385 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

and post-hoc test (now with all 9 comparisons, still just post it for df question) :

> multcomp::cld(emmeans(mod, ~A*B), Letters = letters, reversed = T) # Post-Hoc test
   A           B        emmean  SE  df asymp.LCL asymp.UCL .group
 Low        Normal       -1.49 0.213 Inf     -1.91     -1.08  a    
 Normal     Metabolite   -1.87 0.218 Inf     -2.29     -1.44  ab   
 Metabolite Metabolite   -1.98 0.192 Inf     -2.35     -1.60  ab   
 Low        Metabolite   -1.99 0.217 Inf     -2.42     -1.57  ab   
 Normal     Low          -2.26 0.230 Inf     -2.71     -1.81  ab   
 Normal     Normal       -2.35 0.249 Inf     -2.84     -1.86  ab   
 Low        Low          -2.55 0.265 Inf     -3.07     -2.03   b   
 Metabolite Normal       -2.59 0.264 Inf     -3.10     -2.07   b   
 Metabolite Low          -2.62 0.236 Inf     -3.09     -2.16   b   

Results are averaged over the levels of: Round 
Results are given on the cloglog (not the response) scale. 
Confidence level used: 0.95 
Note: contrasts are still on the cloglog scale 
P value adjustment: tukey method for comparing a family of 9 estimates 
significance level used: alpha = 0.05 
NOTE: If two or more means share the same grouping symbol,
      then we cannot show them to be different.
      But we also did not show them to be the same. 

Related to the comment by EdM about the degrees of freedom: There's no change in degrees of freedom from the changes I've made for Round being a factor, I've also had Mating_time and Round as a factor but didn't change the output of the df.

EDIT

I've made suggested edits and data str() looks like this:

> str(mod)
tibble [1,549 × 4] (S3: tbl_df/tbl/data.frame)
 $ A           : chr [1:1549] "Low" "Low" "Low" "Low" ...
 $ B           : chr [1:1549] "Low" "Low" "Low" "Low" ...
 $ Round       : Factor w/ 9 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 1 ...
 $ Mating_time : num [1:1549] 0 0 0 0 0 0 0 0 0 0 ...

Although I still get output in Anova (as for the response of the df =1):

> Anova(mod)
Analysis of Deviance Table (Type II tests)

Response: Mating_time
                        LR Chisq Df Pr(>Chisq)    
as.factor(Round       )   35.094  8  2.571e-05 ***
A                          3.749  2    0.15343    
B                          9.024  2    0.01097 *  
A : B                     10.424  4    0.03385 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

and post-hoc test (now with all 9 comparisons, still just post it for df question) :

> multcomp::cld(emmeans(mod, ~A*B), Letters = letters, reversed = T) # Post-Hoc test
   A           B        emmean  SE  df asymp.LCL asymp.UCL .group
 Low        Normal       -1.49 0.213 Inf     -1.91     -1.08  a    
 Normal     Metabolite   -1.87 0.218 Inf     -2.29     -1.44  ab   
 Metabolite Metabolite   -1.98 0.192 Inf     -2.35     -1.60  ab   
 Low        Metabolite   -1.99 0.217 Inf     -2.42     -1.57  ab   
 Normal     Low          -2.26 0.230 Inf     -2.71     -1.81  ab   
 Normal     Normal       -2.35 0.249 Inf     -2.84     -1.86  ab   
 Low        Low          -2.55 0.265 Inf     -3.07     -2.03   b   
 Metabolite Normal       -2.59 0.264 Inf     -3.10     -2.07   b   
 Metabolite Low          -2.62 0.236 Inf     -3.09     -2.16   b   

Results are averaged over the levels of: Round 
Results are given on the cloglog (not the response) scale. 
Confidence level used: 0.95 
Note: contrasts are still on the cloglog scale 
P value adjustment: tukey method for comparing a family of 9 estimates 
significance level used: alpha = 0.05 
NOTE: If two or more means share the same grouping symbol,
      then we cannot show them to be different.
      But we also did not show them to be the same. 

Related to the comment by EdM about the degrees of freedom: There's no change in degrees of freedom from the changes I've made for Round being a factor, I've also had Mating_time and Round as a factor but didn't change the output of the df.

Added new script from the changes proposed by Lukas Lohse and EdM
Source Link

EDIT:

I've now edited the raw data table as suggested below and fixed the mistake with mating_time and round. The script looks like this:

mod<-glm(Mating_time ~ Round + A*B,data=dat, family = "binomial")

Anova(mod)

and the output is:

> Anova(mod)
Analysis of Deviance Table (Type II tests)

Response: Mating_time
                LR Chisq Df Pr(>Chisq)    
Round             35.005  8  2.668e-05 ***
A                  3.925  2    0.14048    
B                  8.912  2    0.01161 *  
A : B             10.314  4    0.03545 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I understand that "Round" is important in the model, but when running post-hoc test. If I'm simply interested in AB interaction, and not Round+AB, could I simply do emmeans as follows:

multcomp::cld(emmeans(mod, ~A|B), Letters = letters, reversed = T) # Post-Hoc test

If I run:

multcomp::cld(emmeans(mod, ~Mating_round+A|B), Letters = letters, reversed = T) # Post-Hoc test

I get a very messy table with the "Round" also incorporated. Although its important to fit it into the original model.

The output of:

   multcomp::cld(emmeans(mod, ~A|B), Letters = letters, reversed = T) # Post-Hoc test

looks the following:

> multcomp::cld(emmeans(mod, ~A|B), Letters = letters, reversed = T) # Post-Hoc test
F1_diet = Metabolite:
 F0_diet     emmean    SE    df   asymp.LCL asymp.UCL .group
 Normal       -1.77   0.239 Inf     -2.24     -1.30     a    
 Metabolite   -1.91   0.209 Inf     -2.32     -1.50     a    
 Low          -1.91   0.235 Inf     -2.37     -1.45     a    

F1_diet = Normal:
 F0_diet     emmean    SE    df asymp.LCL asymp.UCL  .group
 Low          -1.34   0.242 Inf     -1.82     -0.87     a    
 Normal       -2.29   0.265 Inf     -2.81     -1.77     b   
 Metabolite   -2.55   0.277 Inf     -3.09     -2.00     b   

F1_diet = Low:
 F0_diet     emmean    SE   df  asymp.LCL asymp.UCL .group
 Normal       -2.22   0.247 Inf     -2.70     -1.73     a    
 Low          -2.50   0.278 Inf     -3.05     -1.96     a    
 Metabolite   -2.58   0.247 Inf     -3.07     -2.10     a    

Results are averaged over the levels of: Round 
Results are given on the logit (not the response) scale. 
Confidence level used: 0.95 
Results are given on the log odds ratio (not the response) scale. 
P value adjustment: tukey method for comparing a family of 3 estimates 
significance level used: alpha = 0.05 
NOTE: If two or more means share the same grouping symbol,
      then we cannot show them to be different.
      But we also did not show them to be the same. 

The particular line "Results are averaged over the levels of: Round" in the emmeans output means that the rounds are covered in the post-hoc test right?

EDIT:

I've now edited the raw data table as suggested below and fixed the mistake with mating_time and round. The script looks like this:

mod<-glm(Mating_time ~ Round + A*B,data=dat, family = "binomial")

Anova(mod)

and the output is:

> Anova(mod)
Analysis of Deviance Table (Type II tests)

Response: Mating_time
                LR Chisq Df Pr(>Chisq)    
Round             35.005  8  2.668e-05 ***
A                  3.925  2    0.14048    
B                  8.912  2    0.01161 *  
A : B             10.314  4    0.03545 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I understand that "Round" is important in the model, but when running post-hoc test. If I'm simply interested in AB interaction, and not Round+AB, could I simply do emmeans as follows:

multcomp::cld(emmeans(mod, ~A|B), Letters = letters, reversed = T) # Post-Hoc test

If I run:

multcomp::cld(emmeans(mod, ~Mating_round+A|B), Letters = letters, reversed = T) # Post-Hoc test

I get a very messy table with the "Round" also incorporated. Although its important to fit it into the original model.

The output of:

   multcomp::cld(emmeans(mod, ~A|B), Letters = letters, reversed = T) # Post-Hoc test

looks the following:

> multcomp::cld(emmeans(mod, ~A|B), Letters = letters, reversed = T) # Post-Hoc test
F1_diet = Metabolite:
 F0_diet     emmean    SE    df   asymp.LCL asymp.UCL .group
 Normal       -1.77   0.239 Inf     -2.24     -1.30     a    
 Metabolite   -1.91   0.209 Inf     -2.32     -1.50     a    
 Low          -1.91   0.235 Inf     -2.37     -1.45     a    

F1_diet = Normal:
 F0_diet     emmean    SE    df asymp.LCL asymp.UCL  .group
 Low          -1.34   0.242 Inf     -1.82     -0.87     a    
 Normal       -2.29   0.265 Inf     -2.81     -1.77     b   
 Metabolite   -2.55   0.277 Inf     -3.09     -2.00     b   

F1_diet = Low:
 F0_diet     emmean    SE   df  asymp.LCL asymp.UCL .group
 Normal       -2.22   0.247 Inf     -2.70     -1.73     a    
 Low          -2.50   0.278 Inf     -3.05     -1.96     a    
 Metabolite   -2.58   0.247 Inf     -3.07     -2.10     a    

Results are averaged over the levels of: Round 
Results are given on the logit (not the response) scale. 
Confidence level used: 0.95 
Results are given on the log odds ratio (not the response) scale. 
P value adjustment: tukey method for comparing a family of 3 estimates 
significance level used: alpha = 0.05 
NOTE: If two or more means share the same grouping symbol,
      then we cannot show them to be different.
      But we also did not show them to be the same. 

The particular line "Results are averaged over the levels of: Round" in the emmeans output means that the rounds are covered in the post-hoc test right?

edited tags
Link
Source Link
Loading