fit_glm: Function that fits generalized linear models

View source: R/fit_model.R

fit_glmR Documentation

Function that fits generalized linear models

Description

Function that fits generalized linear models

Usage

fit_glm(x, y, family, weights, offset, fast = TRUE)

Arguments

x

a matrix of predictors with nobs observations.

y

a vector for the outcome variable.

family

a family function e.g. stats::gaussian().

weights

a numeric vector of length nobs of 'prior weights' to be used in the fitting process. see stats::glm() for details.

offset

a numeric vector of length nobs of of a priori known component to be included in the linear predictor during fitting.

fast

a logical which determines how the model is fitted. The default TRUE uses fast fitting routines (i.e. stats::glm.fit()), while FALSE uses the normal fitting routines (stats::glm()) (used for the final output of mfp2). The difference is mainly due to the fact that normal fitting routines have to handle data.frames, which is a lot slower than using the model matrix and outcome vectors directly.

Value

A list with the following components:

  • logl: the log likelihood of the fitted model.

  • coefficients: regression coefficients.

  • df: number of parameters (degrees of freedom).

  • sse: residual sum of squares.

  • fit: the fitted model object.


mfp2 documentation built on Nov. 15, 2023, 1:06 a.m.