wle (version 0.9-91)

wle.glm: Robust Fitting Generalized Linear Models using Weighted Likelihood

Description

wle.glm is used to robustly fit generalized linear models, specified by giving a symbolic description of the linear predictor and a description of the error distribution.

Usage

wle.glm(formula, family = binomial, data, weights, subset, 
     na.action, start = NULL, etastart, mustart, offset, 
     control = list(glm = glm.control(...), wle = wle.glm.control()), 
     model = TRUE, method = "wle.glm.fit", x = FALSE, y = TRUE, 
     contrasts = NULL, dist.method = "euclidean", ...)

wle.glm.fit(x, y, weights = NULL, wle.weights = rep(1, NROW(y)), start = NULL, etastart = NULL, mustart = NULL, offset = rep(0, NROW(y)), family = gaussian(), control = list(glm=glm.control(), wle=wle.glm.control()), dist.method='euclidean', intercept = TRUE, dispersion = NULL)

## S3 method for class 'wle.glm': weights(object, type = c("prior", "working", "wle"), root="all", ...)

Arguments

formula
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under Details
family
a description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See
data
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables
weights
an optional vector of prior weights to be used in the fitting process. Should be NULL or a numeric vector.
subset
an optional vector specifying a subset of observations to be used in the fitting process.
na.action
a function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options, and is
start
starting values for the parameters in the linear predictor.
etastart
starting values for the linear predictor.
mustart
starting values for the vector of means.
offset
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to the number of cases. One or more
control
a list with two components of parameters for controlling the fitting process. The first component (glm) is set using the function glm.control while the second component (
model
a logical value indicating whether model frame should be included as a component of the returned value.
method
the method to be used in fitting the model. The default method "wle.glm.fit" uses iteratively reweighted least squares (IWLS). The only current alternative is "model.frame" which returns the model frame and does no fi
x, y
For wle.glm: logical values indicating whether the response vector and model matrix used in the fitting process should be returned as components of the returned value.

For wle.glm.fit: x is a design

contrasts
an optional list. See the contrasts.arg of model.matrix.default.
dist.method
distance method passed to dist to measure the distance between predictor rows.
intercept
logical. Should an intercept be included in the null model?
dispersion
numeric or NULL. If provided used as starting value.
object
an object inheriting from class "wle.glm".
type
character, partial matching allowed. Type of weights to extract from the fitted model object.
root
character ("all") or a number. For which solutions the weights are reported.
wle.weights
For wle.glm.fit these are weights used in the iterative algorithm evaluated at each step by wle.glm.weights.
...
For wle.glm: arguments to be passed by default to glm.control: see argument control. For weights: further arguments passed to or from other method

Value

  • wle.glm returns an object of class inheriting from "wle.glm".

    The function summary (i.e., summary.wle.glm) can be used to obtain or print a summary of the results and the function anova (i.e., anova.wle.glm.root) to produce an analysis of variance table.

    The generic accessor functions coefficients, effects, fitted.values and residuals can be used to extract various useful features of the value returned by wle.glm.

    weights extracts a vector of weights, one for each case/root in the fit (after subsetting and na.action).

    An object of class "wle.glm" is a (variable length) list containing at least the following components:

    root1 which is a list with the following components:

  • coefficientsa named vector of coefficients
  • residualsthe working residuals, that is the residuals in the final iteration of the IWLS fit. Since cases with zero weights are omitted, their working residuals are NA.
  • fitted.valuesthe fitted mean values, obtained by transforming the linear predictors by the inverse of the link function.
  • rankthe numeric rank of the fitted linear model.
  • familythe family object used.
  • linear.predictorsthe linear fit on link scale.
  • devianceup to a constant, minus twice the maximized log-likelihood. Where sensible, the constant is chosen so that a saturated model has deviance zero.
  • aicAkaike's An Information Criterion, minus twice the maximized log-likelihood plus twice the number of coefficients (so assuming that the dispersion is known).
  • null.devianceThe deviance for the null model, comparable with deviance. The null model will include the offset, and an intercept if there is one in the model. Note that this will be incorrect if the link function depends on the data other than through the fitted mean: specify a zero offset to force a correct calculation.
  • iterthe number of iterations of IWLS used.
  • weightsthe working weights, that is the weights in the final iteration of the IWLS fit.
  • prior.weightsthe weights initially supplied, a vector of 1s if none were.
  • df.residualthe residual degrees of freedom.
  • df.nullthe residual degrees of freedom for the null model.
  • yif requested (the default) the y vector used. (It is a vector even for a binomial model.)
  • xif requested, the model matrix.
  • modelif requested (the default), the model frame.
  • convergedlogical. Was the IWLS algorithm judged to have converged?
  • boundarylogical. Is the fitted value on the boundary of the attainable values?
  • wle.weightsfinal (robust) weights based on the WLE approach.
  • wle.asymptoticlogicals. If TRUE asymptotic weight based on Anscombe residual is used for the corresponding observation.
  • In addition, non-empty fits will have components qr, R, qraux, pivot and effects relating to the final weighted linear fit.

    and the following components:

  • familythe family object used.
  • callthe matched call.
  • formulathe formula supplied.
  • termsthe terms object used.
  • datathe data argument.
  • offsetthe offset vector used.
  • controlthe value of the control argument used.
  • methodthe name of the fitter function used, currently always "wle.glm.fit".
  • contrasts(where relevant) the contrasts used.
  • xlevels(where relevant) a record of the levels of the factors used in fitting.
  • tot.solthe number of solutions found.
  • not.convthe number of starting points that does not converge after the max.iter (defined using wle.glm.control) iterations are reached.
  • na.action(where relevant) information returned by model.frame on the special handling of NAs.
  • Objects of class "wle.glm" are normally of class "wle.glm". If a binomial wle.glm model was specified by giving a two-column response, the weights returned by prior.weights are the total numbers of cases (factored by the supplied case weights) and the component y of the result is the proportion of successes.

    In case of multiple roots (i.e. tot.sol > 1) then objects of the same form as root1 are reported with names root2, root3 and so on until tot.sol.

concept

  • regression
  • logistic
  • log-linear
  • loglinear

Warnings

Since in a model selection procedure and/or on an ANOVA table the weights of the WLE procedure must be that of the FULL model (and not that of the actual model) statistics on degrees of freedom, deviance and AIC are valid only if this is the FULL model.

Details

A typical predictor has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response. For binomial and quasibinomial families the response can also be specified as a factor (when the first level denotes failure and all others success) or as a two-column matrix with the columns giving the numbers of successes and failures. A terms specification of the form first + second indicates all the terms in first together with all the terms in second with any duplicates removed.

A specification of the form first:second indicates the the set of terms obtained by taking the interactions of all terms in first with all terms in second. The specification first*second indicates the cross of first and second. This is the same as first + second + first:second.

The terms in the formula will be re-ordered so that main effects come first, followed by the interactions, all second-order, all third-order and so on: to avoid this pass a terms object as the formula.

Non-NULL weights can be used to indicate that different observations have different dispersions (with the values in weights being inversely proportional to the dispersions); or equivalently, when the elements of weights are positive integers $w_i$, that each response $y_i$ is the mean of $w_i$ unit-weight observations. In case of binomial GLM prior weights CAN NOT be used to give the number of trials when the response is the proportion of successes; in this situation please submit the response variable as two columns (first column successes, second column unsuccesses). They would rarely be used for a Poisson GLM.

wle.glm.fit is the workhorse function: it is not normally called directly but can be more efficient where the response vector and design matrix have already been calculated. However, this function needs starting values and does not look for possible multiple roots in the system of equations.

If more than one of etastart, start and mustart is specified, the first in the list will be used. It is often advisable to supply starting values for a quasi family, and also for families with unusual links such as gaussian("log").

All of weights, subset, offset, etastart and mustart are evaluated in the same way as variables in formula, that is first in data and then in the environment of formula.

For the background to warning messages about fitted probabilities numerically 0 or 1 occurred for binomial GLMs, see Venables & Ripley (2002, pp. 197--8).

Multiple roots may occur if the asymptotic weights are used or in the case of continuous models. The function implements the bootstrap root serach approach described in Markatou, Basu and Lindsay (1998) in order to find these roots.

References

Agostinelli, C. (1998) Inferenza statistica robusta basata sulla funzione di verosimiglianza pesata: alcuni sviluppi, Ph.D Thesis, Department of Statistics, University of Padova.

Agostinelli, C. and Markatou, M., (1998) A one-step robust estimator for regression based on the weighted likelihood reweighting scheme, Statistics & Probability Letters, Vol. 37, n. 4, 341-350.

Agostinelli, C. and Markatou, M. (2001) Test of hypotheses based on the Weighted Likelihood Methodology, Statistica Sinica, vol. 11, n. 2, 499-514.

Agostinelli, C. and Al-quallaf, F. (2009) Robust inference in Generalized Linear Models. Manuscript in preparation.

Dobson, A. J. (1990) An Introduction to Generalized Linear Models. London: Chapman and Hall.

Hastie, T. J. and Pregibon, D. (1992) Generalized linear models. Chapter 6 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.

Markatou, M., Basu, A. and Lindsay, B.G. (1998) Weighted likelihood estimating equations with a bootstrap root search. Journal of the American Statistical Association, 93:740-750.

McCullagh P. and Nelder, J. A. (1989) Generalized Linear Models. London: Chapman and Hall.

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. New York: Springer.

See Also

anova.wle.glm.root, summary.wle.glm, etc. for wle.glm methods, and the generic functions anova, summary, effects, fitted.values, and residuals.

wle.lm for robust non-generalized linear models for general linear models.

Examples

Run this code
## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
wle.glm.D93 <- wle.glm(counts ~ outcome + treatment, family=poisson(), x=TRUE, y=TRUE)
wle.glm.D93
anova(extractRoot(wle.glm.D93))
summary(wle.glm.D93)

## Support for gaussian family not provided yet!
## an example with offsets from Venables & Ripley (2002, p.189)
utils::data(anorexia, package="MASS")

anorex.2 <- wle.glm(Postwt ~ Prewt + Treat + offset(Prewt),
                family = gaussian, data = anorexia)
anorex.2
summary(anorex.2)

# Gamma family is not yet implemented!
# A Gamma example, from McCullagh & Nelder (1989, pp. 300-2)
clotting <- data.frame(
    u = c(5,10,15,20,30,40,60,80,100),
    lot1 = c(118,58,42,35,27,25,21,19,18),
    lot2 = c(69,35,26,21,18,16,13,12,12))
wlot1 <- wle.glm(lot1 ~ log(u), data=clotting, family=Gamma,
control=list(glm=glm.control(), wle=wle.glm.control(use.asymptotic=1)))
wlot2 <- wle.glm(lot2 ~ log(u), data=clotting, family=Gamma,
control=list(glm=glm.control(), wle=wle.glm.control(use.asymptotic=1)))
wlot1
wlot2
summary(wlot1)
summary(wlot2)

Run the code above in your browser using DataLab