estimate_gamma_hyperparameters {baldur}R Documentation

Estimate Gamma hyperparameters for sigma



Estimates the hyperparameters for the Bayesian data and decision model. estimate_gamma_hyperparameters is a wrapper that adds new columns to the data (one for alpha and one for betas). Note that for lgmr objects, the estimate_beta function assumes that the data is ordered as when the model was fitted. If this is not the case, theta's will be incorrectly matched with peptides—resulting in wrong estimates of beta parameters. On the other hand, estimate_gamma_hyperparameters will temporarily sort the data as when fitted and the sort it back as it was input to the function.


estimate_gamma_hyperparameters(reg, data, ...)

## S3 method for class 'glm'
estimate_gamma_hyperparameters(reg, data, ...)

## S3 method for class 'lgmr'
estimate_gamma_hyperparameters(reg, data, id_col, ...)

estimate_beta(reg, mean, ...)

## S3 method for class 'glm'
estimate_beta(reg, mean, alpha, ...)

## S3 method for class 'lgmr'
estimate_beta(reg, mean, m, s, ...)



A glm Gamma regression or a lgmr object


A tibble or data.frame to add gamma priors to


Currently not in use


A character for the name of the column containing the name of the features in data (e.g., peptides, proteins, etc.)


The mean value of the peptide


The alpha parameter of the peptide


The mean of the means


The sd of the means


estimate_gamma_hyperparameters returns a tibble or data.frame with the alpha,beta hyperparameters estimates as new columns.

estimate_beta returns estimates of the beta parameter(s)


# Setup model matrix
design <- model.matrix(~ 0 + factor(rep(1:2, each = 3)))
colnames(design) <- paste0("ng", c(50, 100))

# Normalize data
yeast_norm <- yeast %>%
    psrn("identifier") %>%
    # Get mean-variance trends

# Fit gamma regression (could also have been a lgmr model)
gam_reg <- fit_gamma_regression(yeast_norm, sd ~ mean)

# Estimate priors
gam_reg %>%

# Can also explicitly estimate the beta parameters
# Note this is order sensitive.
estimate_beta(gam_reg, yeast_norm$mean, 1/summary(gam_reg)$dispersion)

[Package baldur version 0.0.3 Index]