statdivlab / corncob

Count Regression for Correlated Observations with the Beta-binomial
103 stars 22 forks source link

contrastsTest issue #130

Closed msmcfarlin closed 2 years ago

msmcfarlin commented 2 years ago

Hi @bryandmartin,

I am interested in pairwise contrasts, as mentioned in #126, and ran into an issue with contrastsTest. To give an example, if I have a test with...

soil_family <- tax_glom(soil_phylo, "Family")

da_analysis.small <- contrastsTest(formula = ~ DayAmdmt,
                             phi.formula = ~ DayAmdmt,
                             contrasts_DA = list("DayAmdmt21 - DayAmdmt11",
                                                 "DayAmdmt21 - DayAmdmt00"),
                             data = soil_family,
                             fdr_cutoff = 0.05)

Then I get an "NA" for all comparisons between "DayAmdmt21 - DayAmdmt00". Is this an error with how the DayAmdmt00 is specified in the contrasts_DA?

I am interested in this for pairwise contrasts, i.e. 1v2, 1v3, 2v3, etc.

Thanks! -Mike

bryandmartin commented 2 years ago

Hi @msmcfarlin ,

This is because contrastsTest looks at the coefficients from the model. In the model you are fitting, DayAmdmt00 is the baseline value of DayAmdmt, so there is no coefficient here. To include a baseline value, you can just treat it like a coefficient of 0. Hence, instead of DayAmdmt21 - DayAmdmt00, you can just use DayAmdmt21 to make this contrast.