walsGLMfit {WALS}R 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 Huynh (2024b) for more details. The latter is used in the original MATLAB code for WALS in the linear regression model, see eq. (12) of Magnus and De Luca (2016). The first form is required in eq. (9) of De Luca et al. (2018). 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 (Huynh 2024b) and De Luca et al. (2018).

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

De Luca G, Magnus JR, Peracchi F (2018). “Weighted-average least squares estimation of generalized linear models.” Journal of Econometrics, 204(1), 1–17. doi:10.1016/j.jeconom.2017.12.007.

Huynh K (2024b). “WALS: Weighted-Average Least Squares Model Averaging in R.” University of Basel. Mimeo.

Magnus JR, De Luca G (2016). “Weighted-average least squares (WALS): A survey.” Journal of Economic Surveys, 30(1), 117-148. doi:10.1111/joes.12094.

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()))



[Package WALS version 0.2.5 Index]