Skip to contents

Verify that linkSet object is in expected format. Throws an error if object does not fit requirements.

Check if an error matches the error raised by \code{glm.nb} due to an inflated theta estimate.

This happens when the variance of the negative binomial does not exceed the mean (i.e. there is no overdispersion). In such cases, the Poisson distribution may be a suitable alternative.

Check if chicane model can be fit on a given dataset.

glm.nb does not work when all responses are constant, or there are only two unique values and a covariate is a perfect predictor.

Perform multiple testing correction on p-values from interaction test. By default, multiple testing correction is applied per bait. To change this to a global multiple testing correction, set bait.level = FALSE.

Split a data frame into a prespecified number of bins, using split and cut. Unlike the default R functions, this does not fail when asked to split the data into a single bin.

Verify that interaction.data object is in expected format. Throws an error if object does not fit requirements.

Fit GLM according to a specified distribution. This needs to be done separately from glm in order to include negative binomial and truncated distributions as options.

Check that the model fit contains the same number of rows as the data used to fit it,

and throw an error if not

Check if a warning object is an iteration limit reached warning from glm.nb

Check if a warning matches the square root warning raised by \code{glm.nb} due to an inflated theta estimate.

This happens when the variance of the negative binomial does not exceed the mean (i.e. there is no overdispersion). In such cases, the Poisson distribution may be a suitable alternative.

Usage

.verify.linkSet(linkSet)

.is.glm.nb.theta.error(e)

.check.model.numerical.fit(interaction.data)

multiple.testing.correct(interaction.data, bait.level = TRUE)

.smart.split(dat, bins)

.verify.interaction.data(interaction.data)

fit.glm(
  formula,
  data,
  distribution = c("negative-binomial", "poisson", "truncated-poisson",
    "truncated-negative-binomial"),
  start = NULL,
  init.theta = NULL,
  maxit = 100,
  epsilon = 1e-08,
  trace = FALSE
)

.model.rows.sanity.check(model.data, model)

.is.glm.nb.maxiter.warning(w)

.is.glm.nb.theta.warning(w)

Arguments

linkSet

Object to be verified.

e

Error object

interaction.data

Object to be verified.

bait.level

Logical indicating whether multiple testing correction should be performed per bait.

dat

Data frame or data table to be split

bins

Number of bins to split data into

formula

Formula specifying model of interest

data

Data frame containing variables specified in formula

distribution

Name of distribution of the counts. Options are 'negative-binomial', 'poisson', 'truncated-poisson', and 'truncated-negative-binomial'

start

Starting values for model coefficients

init.theta

Initial value of theta if fitting the negative binomial distribution

maxit

Maximum number of IWLS iterations for fitting the model (passed to glm.control)

epsilon

Positive convergence tolerance for Poisson and negative binomial models. Passed to glm.control

trace

Logical indicating if output should be produced for each of model fitting procedure. Passed to glm.control or gamlss.control

model.data

Data used to fit model

model

Resulting negative binomial model object

w

Warning object

Value

None

Boolean indicating if error matches

boolean indicating if model can be fit

Original data table with new column

q.value

FDR-corrected p-value

List with bins elements. Each element corresponds to one portion of the data

None

List with elements

model

model object

expected.values

vector of expected values for each element in original data

p.values

vector of p-values for test of significantly higher response than expected

None

Logical indicating if warning matches iteration limit reached warning

Boolean indicating if warning matches