squeezeThetas: Squeeze variances and other parameters

View source: R/squeezePars.R

squeezeThetasR Documentation

Squeeze variances and other parameters

Description

Squeeze a set of sample variances towards a common value using empirical Bayes moderation similar to the limma package. This can be done for residual variances, random effects or shrunken fixed effects. The resulting variances are called posterior variances.

Usage

squeezeThetas(thetas, df_thetas, vars, df_vars, squeezeVar = TRUE,
  min_df = 1, robust_var = TRUE, printProgress = FALSE, shiny = FALSE,
  message = NULL, ...)

Arguments

thetas

A numeric matrix wherein each column contains variances for a different parameter.

df_thetas

A numeric matrix wherein each column contains degrees of freedom corresponding to the thetas.

vars

A numeric vector containing residual variances.

df_vars

A numeric vector containing residual degrees of freedom.

squeezeVar

A logical indicating whether the residual variances as given by the argument vars should be squeezed towards a common value. Defaults to TRUE. If set to FALSE, vars will not be squeezed and the vars_post slot will contain the same values as the vars input argument.

min_df

A numeric value indicating the minimal degrees of freedom that will be taken into account for calculating the prior degrees of freedom and prior variance.

robust_var

A logical indicating wheter the estimation of the prior degrees of freedom and the prior variance (needed for shrinkage) should be robustified against outlier variances. Defaults to TRUE.

printProgress

A logical indicating whether the R should print a message before performing each preprocessing step. Defaults to FALSE.

shiny

A logical indicating whether this function is being used by a Shiny app. Setting this to TRUE only works when using this function in a Shiny app and allows for dynamic progress bars. Defaults to FALSE.

message

Only used when printProgress=TRUE and shiny=TRUE. A single-element character vector: the message to be displayed to the user during the squeezing of the variances and degrees of freedom, or NULL to hide the current message (if any).

...

Other arguments to be passed to the squeezeVarRob function internally.

Value

A named list with 4 slots. The first slot thetas_post contains a matrix with in each column the squeezed variances corresponding to the thetas input argument. The second slot df_thetas_post contains a matrix of similar structure to thetas_post but containing the posterior degrees of freedom corresponding to the df_thetas input argument. If squeezeVar=TRUE, the third slot vars_post contains a vector of posterior residual variances for each accession. If squeezeVar=FALSE, it contains the residual variances given in the vars input argument. If squeezeVar=TRUE, the fourth slot df_vars_post contains a vector of posterior residual degrees of freedom. If squeezeVar=FALSE, it contains the residual degrees of freedom given in the df_vars input argument.

References

....

Examples

....

ludgergoeminne/MSqRob documentation built on Jan. 11, 2023, 1:32 p.m.