Skip to content

Fix fixed-effect covariance for taxon-specific observed designs - #341

Open
xec-cm wants to merge 1 commit into
FrederickHuangLin:bugfixfrom
xec-cm:fix-reference-invariant-variance
Open

xec-cm wants to merge 1 commit into
FrederickHuangLin:bugfixfrom
xec-cm:fix-reference-invariant-variance

Conversation

@xec-cm

@xec-cm xec-cm commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

This fixes the fixed-effect covariance calculation for taxa with missing observations. In ANCOM-BC2, the default pseudo = 0 treats zero counts as missing on the log scale, so this can also affect count tables without any NAs in the original data.

Previously, missing contributions were replaced with 0.1, and the covariance used the full design rather than the observations actually fitted for each taxon. The fix uses those observations consistently and keeps NA uncertainty for non-estimable coefficients. The shared helper affects both ANCOM-BC and ANCOM-BC2; mixed-model code is unchanged.

I checked the covariance against sandwich::vcovHC(type = "HC0") and verified consistency under reference reversal and covariate rescaling. All existing tests pass after updating two expected values.

Related to #338 and #339.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant