walsGLMfit: Fitter function for Weighted Average Least Squares estimation...

View source: R/walsGLM.R

walsGLMfitR Documentation

Fitter function for Weighted Average Least Squares estimation of GLMs

Description

Workhorse function behind walsGLM and used internally in walsGLMfitIterate.

Usage

walsGLMfit(
  X1,
  X2,
  y,
  betaStart1,
  betaStart2,
  family,
  prior = weibull(),
  postmult = TRUE,
  ...
)

Arguments

X1

Design matrix for focus regressors. Usually includes a constant (column full of 1s) and can be generated using model.matrix.

X2

Design matrix for auxiliary regressors. Usually does not include a constant column and can also be generated using model.matrix.

y

Response as vector.

betaStart1

Starting values for coefficients of focus regressors X1.

betaStart2

Starting values for coefficients of auxiliary regressors X2.

family

Object of class "familyWALS".

prior

Object of class "familyPrior". For example weibull or laplace.

postmult

If TRUE (default), then it computes

\bar{Z}_{2} = \bar{X}_{2} \bar{\Delta}_{2} \bar{T} \bar{\Lambda}^{-1/2} \bar{T}^{\top},

where \bar{T} contains the eigenvectors and \bar{\Lambda} the eigenvalues from the eigenvalue decomposition

\bar{\Xi} = \bar{T} \bar{\Lambda} \bar{T}^{\top},

instead of

\bar{Z}_{2} = \bar{X}_{2} \bar{\Delta}_{2} \bar{T} \bar{\Lambda}^{-1/2}.

See \insertCitehuynhwals;textualWALS for more details. The latter is used in the original MATLAB code for WALS in the linear regression model, see eq. (12) of \insertCitemagnus2016wals;textualWALS. The first form is required in eq. (9) of \insertCitedeluca2018glm;textualWALS. Thus, it is not recommended to set postmult = FALSE.

...

Further arguments passed to walsFit.

Details

Uses walsFit under the hood after transforming the regressors X1 and X2 and the response y. For more details, see \insertCitehuynhwalsWALS and \insertCitedeluca2018glm;textualWALS.

Value

A list containing all elements returned by walsFit, except for residuals, and additionally (some fields are replaced)

condition

Condition number of the matrix \bar{\Xi} = \bar{\Delta}_{2} \bar{X}_{2}^{\top} \bar{M}_{1} \bar{X}_{2} \bar{\Delta}_{2}.

family

Object of class "familyWALS". The family used.

betaStart

Starting values of the regression coefficients for the one-step ML estimators.

fitted.link

Linear link fitted to the data.

fitted.values

Estimated conditional mean for the data. Lives on the scale of the response.

References

\insertAllCited

See Also

walsGLM, walsGLMfitIterate, walsFit.

Examples

data("HMDA", package = "AER")
X <- model.matrix(deny ~ pirat + hirat + lvrat + chist + mhist + phist + selfemp + afam,
                  data = HMDA)
X1 <- X[,c("(Intercept)", "pirat", "hirat", "lvrat", "chist2", "chist3",
        "chist4", "chist5", "chist6", "mhist2", "mhist3", "mhist4", "phistyes")]
X2 <- X[,c("selfempyes", "afamyes")]
y <- HMDA$deny

# starting values from glm.fit()
betaStart <- glm.fit(X, y, family = binomialWALS())$coefficients
k1 <- ncol(X1)
k2 <- ncol(X2)

str(walsGLMfit(X1, X2, y,
               betaStart1 = betaStart[1:k1],
               betaStart2 = betaStart[(k1 + 1):(k1 + k2)],
               family = binomialWALS(), prior = weibull()))



WALS documentation built on June 22, 2024, 9:42 a.m.

Related to walsGLMfit in WALS...