
Last chance! 50% off unlimited learning
Sale ends in
vglm
is used to fit vector generalized linear models (VGLMs).
This is a very large class of models that includes
generalized linear models (GLMs) as a special case.vglm(formula, family, data = list(), weights = NULL, subset = NULL,
na.action = na.fail, etastart = NULL, mustart = NULL,
coefstart = NULL, control = vglm.control(...), offset = NULL,
method = "vglm.fit", model = FALSE, x.arg = TRUE, y.arg = TRUE,
contrasts = NULL, constraints = NULL, extra = list(),
form2 = NULL, qr.arg = FALSE, smart = TRUE, ...)
"vglmff"
(see vglmff-class
)
describing what statistical model is to be fitted. This is called a
``
environment(formula)
, typically the environment
from which vglm
is called.weights
is a matrix,
then it must be in matrix-band form, whereby the
first $M$ columns of the matrix are the diagonals,
followed by the upNA
s.
The default is set by the na.action
setting
of options
, and is na.fail
if that is uetastart
and the output of predict(fit)
should be comparablemustart
and the output of fitted(fit)
should be comparable.
Some family fucoef(fit)
.vglm.control
for details.vglm.fit()
uses iteratively
reweighted least squares (IRLS).model
slot.x
and y
slots.
Note the model matrix is the LM model matrix; to get the VGLM
model matrixcontrasts.arg
of model.matrix.default
."lm"
-type and "vlm"
-type.
Txij
is used (see vglm.control
) then
form2
needs to have all terms in the model.
Also, some qr
, which
returns the QR decomposition of the VLM model matrix,
is returned on the object.smartpred
) will be used.vglm.control
."vglm"
, which has the
following slots. Some of these may not be assigned to save
space, and will be recreated if necessary later.extra
at the end of fitting."vglmff"
).plotvgam
, the plotting parameters
may be put here.weights
argument).
Also see weightsvglm
.terms
object used.vglm-class
.
Most users will find vglm
similar in flavour to
glm
.
The function vglm.fit
actually does the work.
Yee, T. W. and Wild, C. J. (1996) Vector generalized additive models. Journal of the Royal Statistical Society, Series B, Methodological, 58, 481--493.
Yee, T. W. (2008)
The VGAM
Package.
R News, 8, 28--39.
Documentation accompanying the
vglm.control
,
vglm-class
,
vglmff-class
,
smartpred
,
vglm.fit
,
fill
,
rrvglm
,
vgam
.
Methods functions include
coef.vlm
,
predictvglm
,
summary.vglm
,
AIC.vglm
,
lrtest_vglm
,
etc.# Example 1. See help(glm)
print(d.AD <- data.frame(treatment = gl(3, 3),
outcome = gl(3, 1, 9),
counts = c(18,17,15,20,10,20,25,13,12)))
vglm.D93 = vglm(counts ~ outcome + treatment, family = poissonff,
data = d.AD, trace = TRUE)
summary(vglm.D93)
# Example 2. Multinomial logit model
pneumo = transform(pneumo, let = log(exposure.time))
vglm(cbind(normal, mild, severe) ~ let, multinomial, pneumo)
# Example 3. Proportional odds model
fit3 = vglm(cbind(normal,mild,severe) ~ let, propodds, pneumo, trace = TRUE)
coef(fit3, matrix = TRUE)
constraints(fit3)
model.matrix(fit3, type = "lm") # LM model matrix
model.matrix(fit3) # Larger VGLM (or VLM) model matrix
# Example 4. Bivariate logistic model
fit4 = vglm(cbind(nBnW, nBW, BnW, BW) ~ age, binom2.or, coalminers)
coef(fit4, matrix = TRUE)
depvar(fit4) # Response are proportions
weights(fit4, type = "prior")
# Example 5. The use of the xij argument (simple case).
# The constraint matrix for 'op' has one column.
nn = 1000
eyesdat = round(data.frame(lop = runif(nn),
rop = runif(nn),
op = runif(nn)), dig = 2)
eyesdat = transform(eyesdat, eta1 = -1+2*lop,
eta2 = -1+2*lop)
eyesdat = transform(eyesdat,
leye = rbinom(nn, size = 1, prob = logit(eta1, inv = TRUE)),
reye = rbinom(nn, size = 1, prob = logit(eta2, inv = TRUE)))
head(eyesdat)
fit5 = vglm(cbind(leye,reye) ~ op,
binom2.or(exchangeable = TRUE, zero = 3),
data = eyesdat, trace = TRUE,
xij = list(op ~ lop + rop + fill(lop)),
form2 = ~ op + lop + rop + fill(lop))
coef(fit5)
coef(fit5, matrix = TRUE)
constraints(fit5)
Run the code above in your browser using DataLab