weightsvglm(object, type = c("prior", "working"),
matrix.arg = TRUE, ignore.slot = FALSE,
deriv.arg = FALSE, ...)
"vglm"
.TRUE
then
object@weights
is ignored even if it has been assigned,
and the long calculation for object@weights
is repeated. This may give a slightly different answer because
of the final IRLS step TRUE
then
a list with components deriv
and weights
is returned. See below for more details.type="working"
and deriv=TRUE
then a list is returned
with the two components described below. Otherwise the prior or
working weights are returned depending on the value of type
.deriv.mu
in
vglm.fit()
, or equivalently, the matrix returned in the
"deriv"
slot of a weights
argument in
functions such as vglm
and vgam
. It may
refer to frequencies of the individual data or be weight matrices
specified beforehand.Working weights are used by the IRLS algorithm. They correspond to the second derivatives of the log-likelihood function with respect to the linear predictors. The working weights correspond to positive-definite weight matrices and are returned in matrix-band form, e.g., the first $M$ columns correspond to the diagonals, etc.
Chambers, J. M. and T. J. Hastie (eds) (1992) Statistical Models in S. Wadsworth & Brooks/Cole.
glm
,
vglmff-class
,
vglm
.data(pneumo)
pneumo = transform(pneumo, let=log(exposure.time))
(fit = vglm(cbind(normal, mild, severe) ~ let,
cumulative(parallel=TRUE, reverse=TRUE), pneumo))
fit@y # These are sample proportions
weights(fit, type="prior", matrix=FALSE) # Number of observations
# Look at the working residuals
n = nrow(model.matrix(fit, type="lm"))
M = ncol(predict(fit))
temp = weights(fit, type="working", deriv=TRUE)
wz = m2adefault(temp$weights, M=M) # In array format
wzinv = array(apply(wz, 3, solve), c(M,M,n))
wresid = matrix(NA, n, M) # working residuals
for(i in 1:n)
wresid[i,] = wzinv[,,i,drop=TRUE] %*% temp$deriv[i,]
max(abs(c(resid(fit, type="w")) - c(wresid))) # Should be 0
z = predict(fit) + wresid # Adjusted dependent vector
z
Run the code above in your browser using DataLab