getBetaVcovDf-glm-method: Get beta, vcov, df and sigma from a generalized linear model

getBetaVcovDf,glm-methodR Documentation

Get beta, vcov, df and sigma from a generalized linear model

Description

This function returns a list containing the parameter estimates beta, the variance-covariance matrix vcov, the residual degrees of freedom df and the residual standard deviation sigma based on a general linear model fitted by the lm function from the stats package. This function will only rarely be called by the end-user. When calculating these values for protLM objects, we recommend using the function getbetaVcovDfList.

Usage

## S4 method for signature 'glm'
getBetaVcovDf(model, exp_unit = NULL, pars_between = NULL)

Arguments

model

A general linear model object of class lm.

exp_unit

The effect in the model that corresponds to the experimental unit. Only needed when one would like to calculate a more conservative way of estimating the degrees of freedom. The default way (exp_unit=NULL) estimates the degrees of freedom by substracting the total number of observations by the number of parameters. However, often, observations are not completely independent. A more conservative way (df_exp) is defining on which level the treatments were executed and substracting all degrees of freedom lost due to between-treatement effects (pars_between) from the number of treatments.

pars_between

Only used if exp_unit is not NULL. Character vector indicating all parameters in the model that are between-treatment effects in order to calculate a more conservative degrees of freedom (df_exp). If left to default (NULL), all parameters in the model will be asumed to be between-treatment effects (this is not adviced as the result will mostly be too conservative).

Value

A list containing (1) a named column matrix beta containing the parameter estimates, (2) a named square variance-covariance matrix, (3) a numeric value equal to the residual degrees of freedom, (4) a numeric value equal to the residual standard deviation of the model and (5) NULL if exp_unit is left to its default value NULL, else: a conservative estimate of the degrees of freedom based on the number of experimental units and the degrees of freedom lost due to between-treatment effects.

Examples

data(proteinsCPTAC, package="MSqRob")
lmmodel <- lm(formula="value ~ 1 + conc + instrlab + Sequence",data=getData(proteinsCPTAC[2]))
getBetaVcovDf(lmmodel)

statOmics/MSqRob documentation built on Dec. 8, 2022, 6 a.m.