Skip to content

Use of offset() in formulas to specify fixed coefficients #83

@mikemc

Description

@mikemc

Background: R fitting functions like lm() and nnet::multinom()) support wrapping a term in offset() to indicate that the term should have a fixed coefficient of 1. I would like to use such an offset in corncob in order to implement the "frequency-based" decontamination method of Davis et al 2018.

I have DNA concentrations in a variable called dna_conc in a phyloseq object. If I run

mod <- bbdml(
  formula = ASV1 ~ 1 + offset(-log(dna_conc)),
  phi.formula = ~ 1 + log(dna_conc),
  data = physeq
)
mod_null <- bbdml(
  formula = ASV1 ~ 1,
  phi.formula = ~ 1 + log(dna_conc),
  data = physeq
)

corncob does not complain about the offset terms, but the fitted models are identical in mod and mod_null, which makes me think the offset term is being silently dropped before model fitting. Is that correct, and is there an alternate way to fit a model with a fixed coefficient?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions