| calc_weights | R Documentation |
Calculates the precision weights for each measurement.
calc_weights(data, gamma_reg_model)
data |
A |
gamma_reg_model |
a |
calc_weights takes as input a data frame and a glm object produced
by e.g., fit_gamma_regressions or fit_gamma_weights,
see Mean-Variance_Gamma_Regressions for details.
For all numeric columns, it predicts the standard deviation using the gamma
regression. It then squares and takes the reciprocal of each value to generate the
precision weights.
The same data.frame but with all quantitative values replaced by
their precision weights.
# Generate a design matrix for the data
design <- model.matrix(~ 0 + factor(rep(1:2, each = 3)))
# Set correct colnames, this is important for fit_gamma_weights
colnames(design) <- paste0("ng", c(50, 100))
# Normalize and log-transform the data
yeast <- psrn(yeast, "identifier")
# Fit the gamma regression model for the mean-variance trend
gamma_model <- fit_gamma_weights(yeast, design, "identifier")
# Generate the weights for the yeast data
calc_weights(yeast, gamma_model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.