walsGLMfitIterate {WALS}R Documentation

Iteratively fitting walsGLM, internal function for walsGLM.formula and walsGLM.matrix.

Description

Wrapper around walsGLMfit that allows iteratively (re-)fitting walsGLM models.

Usage

walsGLMfitIterate(
  y,
  X1,
  X2,
  family,
  na.action = NULL,
  weights = NULL,
  offset = NULL,
  prior = weibull(),
  controlInitGLM = controlGLM(),
  keepY = TRUE,
  keepX = FALSE,
  iterate = FALSE,
  tol = 1e-06,
  maxIt = 50,
  nIt = NULL,
  verbose = FALSE,
  ...
)

Arguments

y

Response as vector.

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.

family

Object of class "familyWALS".

na.action

Not implemented yet.

weights

Not implemented yet.

offset

Not implemented yet.

prior

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

controlInitGLM

Controls estimation of starting values for one-step ML, see controlGLM.

keepY

If TRUE, then output keeps response.

keepX

If TRUE, then output keeps the design matrices.

iterate

if TRUE then the WALS algorithm is iterated using the previous estimates as starting values.

tol

Only used if iterate = TRUE and nIt = NULL. If the Euclidean distance between the previous and current coefficient vector divided by the square root of the length of the vector falls below tol, then the algorithm stops. See below for more details.

maxIt

Only used if iterate = TRUE and nIt = NULL. Aborts iterative fitting when number of iterations exceed maxIt.

nIt

Only used if iterate = TRUE. If this is specified, then tol is ignored and the algorithm iterates nIt times.

verbose

If verbose = TRUE, then it prints the iteration process (only relevant if iterate = TRUE).

...

Arguments to be passed to the workhorse function walsGLMfit.

Details

The parameter tol is used to control the convergence of the iterative fitting algorithm. Let i be the current iteration step for the coefficient vector \beta_{i} = (\beta_{i,1}, \ldots, \beta_{i,k})', k > 0. If

\frac{||\beta_{i} - \beta_{i-1}||_{2}}{\sqrt{k}} = \sqrt{\frac{\sum_{j = 1}^{k} (\beta_{i,j} - \beta_{i-1,j})^{2}}{k}} < \texttt{tol},

then the fitting process is assumed to have converged and stops.

Value

A list containing all elements returned from walsGLMfit and additionally the following elements:

y

If keepY = TRUE, contains the response vector.

x

list. If keepX = TRUE, then it is a list with elements x1 and x2 containing the design matrices of the focus and auxiliary regressors, respectively.

initialFit

List containing information (e.g. convergence) on the estimation of the starting values for walsGLMfit. See glm.fit for more information.

weights

returns the argument weights.

offset

returns the argument offset.

converged

Logical. Only relevant if iterate = TRUE. Equals TRUE if iterative fitting converged, else FALSE. Is NULL if iterate = FALSE.

it

Number of iterations run in the iterative fitting algorithm. NULL if iterate = FALSE.

deviance

Deviance of the fitted regression model.

residuals

Raw residuals, i.e. response - fitted mean.

See Also

walsGLM, walsGLMfit.

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

str(walsGLMfitIterate(y, X1, X2, family = binomialWALS(), prior = weibull(),
                      iterate = TRUE))


[Package WALS version 0.2.4 Index]