fit_gamma_regression: Function for Fitting the Mean-Variance Gamma Regression...

View source: R/fit_gamma_regression.R

fit_gamma_regressionR Documentation

Function for Fitting the Mean-Variance Gamma Regression Models

Description

[Experimental]

fit_gamma_regression returns a glm object containing the gamma regression for the mean-variance trend.

Usage

fit_gamma_regression(data, formula = sd ~ mean, ...)

Arguments

data

a data.frame to generate the mean-variance trends for. It should contain columns with conditions named as the column names in design (presumably with some suffix).

formula

a formula describing the model

...

only for compatibility with other functions

Value

fit_gamma_regression returns a glm object

Examples

# Generate a design matrix for the data
design <- model.matrix(~ 0 + factor(rep(1:2, each = 3)))

# Set correct colnames, this is important for calculate_mean_sd_trends
colnames(design) <- paste0("ng", c(50, 100))

# Normalize and log-transform the data
yeast_norm <- psrn(yeast, "identifier") %>%
  # Add row means and variances
  calculate_mean_sd_trends(design)

# Fit gamma regression model for the mean-variance trends
gamma_model <- fit_gamma_regression(yeast_norm, sd ~ mean)

baldur documentation built on Sept. 18, 2023, 9:07 a.m.