CommonVGAMffArguments | R Documentation |
Here is a description of some common and
typical arguments found in many VGAM
family functions, e.g.,
zero
,
lsigma
,
isigma
,
gsigma
,
eq.mean
,
nsimEI
and
parallel
.
TypicalVGAMfamilyFunction(lsigma = "loglink",
isigma = NULL,
zero = NULL, gsigma = exp(-5:5),
eq.mean = FALSE,
parallel = TRUE,
imethod = 1,
vfl = FALSE, Form2 = NULL,
type.fitted = c("mean", "quantiles", "Qlink",
"pobs0", "pstr0", "onempstr0"),
percentiles = c(25, 50, 75),
probs.x = c(0.15, 0.85),
probs.y = c(0.25, 0.50, 0.75),
multiple.responses = FALSE, earg.link = FALSE,
ishrinkage = 0.95, nointercept = NULL,
whitespace = FALSE, bred = FALSE, lss = TRUE,
oim = FALSE, nsimEIM = 100, byrow.arg = FALSE,
link.list = list("(Default)" = "identitylink",
x2 = "loglink",
x3 = "logofflink",
x4 = "multilogitlink",
x5 = "multilogitlink"),
earg.list = list("(Default)" = list(),
x2 = list(),
x3 = list(offset = -1),
x4 = list(),
x5 = list()),
Thresh = NULL, nrfs = 1)
lsigma |
Character.
Link function applied to a parameter and not
necessarily a mean. See |
isigma |
Optional initial values can often be
inputted using an argument beginning with
|
zero |
An important argument, either an integer vector, or a vector of character strings. If an integer, then it specifies which
linear/additive predictor is modelled
as intercept-only. That is,
the regression coefficients are set to
zero for all covariates except for the
intercept. If Some VGAM family functions allow the
Suppose Note: The argument If the |
gsigma |
Grid-search initial values can be inputted
using an argument beginning with Some family functions have an argument
called |
eq.mean |
Logical.
Constrain all the means to be equal?
This type of argument is simpler than
|
parallel |
A logical, or a simple formula specifying
which terms have equal/unequal coefficients.
The formula must be simple, i.e., additive
with simple main effects terms. Interactions
and nesting etc. are not handled. To handle
complex formulas use the Here are some examples.
1. This argument is common in VGAM family
functions for categorical responses, e.g.,
|
nsimEIM |
Some VGAM family functions use
simulation to obtain an approximate expected
information matrix (EIM). For those that
do, the Some VGAM family functions provide
two algorithms for estimating the EIM.
If applicable, set |
imethod |
An integer with value VGAM family functions such
|
Form2 |
Formula.
Using applied to models with |
vfl |
A single logical.
This stands for
variance–variance factored loglinear
(VFL)
model.
If A good question is:
why is |
type.fitted |
Character.
Type of fitted value returned by
the The choice |
percentiles |
Numeric vector, with values between 0 and
100 (although it is not recommended that
exactly 0 or 100 be inputted). Used only
if |
probs.x , probs.y |
Numeric, with values in (0, 1).
The probabilites that define quantiles with
respect to some vector, usually an |
lss |
Logical.
This stands for the ordering: location,
scale and shape. Should the ordering
of the parameters be in this order?
Almost all VGAM family functions
have this order by default, but in order
to match the arguments of existing R
functions, one might need to set
|
Thresh |
Thresholds is another name for the
intercepts, e.g., for categorical models.
They may be constrained by functions such as
|
whitespace |
Logical.
Should white spaces ( |
oim |
Logical.
Should the observed information matrices
(OIMs) be used for the working weights?
In general, setting |
nrfs |
Numeric, a value in |
,
multiple.responses |
Logical.
Some VGAM family functions allow
a multivariate or vector response.
If so, then usually the response is a
matrix with columns corresponding to the
individual response variables. They are
all fitted simultaneously. Arguments such
as |
earg.link |
This argument should be generally ignored. |
byrow.arg |
Logical.
Some VGAM family functions that handle
multiple responses have arguments that allow
input to be fed in which affect all the
responses, e.g., |
ishrinkage |
Shrinkage factor |
nointercept |
An integer-valued vector specifying
which linear/additive predictors have no
intercepts. Any values must be from the
set {1,2,..., |
bred |
Logical.
Some VGAM family functions will allow
bias-reduction based on the work by Kosmidis
and Firth. Sometimes half-stepping is a good
idea; set |
link.list , earg.list |
Some VGAM family functions
(such as |
Full details will be given in documentation
yet to be written, at a later date!
A general recommendation is to set
trace = TRUE
whenever any model fitting
is done, since monitoring convergence is
usually very informative.
An object of class "vglmff"
(see
vglmff-class
). The object
is used by modelling functions such as
vglm
and vgam
.
The zero
argument is supplied for
convenience but conflicts can arise with other
arguments, e.g., the constraints
argument of vglm
and
vgam
. See Example 5 below
for an example. If not sure, use, e.g.,
constraints(fit)
and
coef(fit, matrix = TRUE)
to check the result of a fit fit
.
The arguments zero
and
nointercept
can be inputted with values
that fail. For example,
multinomial(zero = 2, nointercept = 1:3)
means the second linear/additive predictor is
identically zero, which will cause a failure.
Be careful about the use of other
potentially contradictory constraints, e.g.,
multinomial(zero = 2, parallel = TRUE ~ x3)
.
If in doubt, apply constraints()
to the fitted object to check.
VGAM family functions with the
nsimEIM
may have inaccurate working
weight matrices. If so, then the standard
errors of the regression coefficients
may be inaccurate. Thus output from
summary(fit)
, vcov(fit)
,
etc. may be misleading.
Changes relating to the lss
argument
have very important consequences and users
must beware. Good programming style is
to rely on the argument names and not on
the order.
T. W. Yee
Yee, T. W. (2015). Vector Generalized Linear and Additive Models: With an Implementation in R. New York, USA: Springer.
Kosmidis, I. and Firth, D. (2009). Bias reduction in exponential family nonlinear models. Biometrika, 96, 793–804.
Miranda-Soberanis, V. F. and Yee, T. W. (2019). New link functions for distribution–specific quantile regression based on vector generalized linear and additive models. Journal of Probability and Statistics, 5, 1–11.
Links
,
vglm
,
vgam
,
vglmff-class
,
UtilitiesVGAM
,
multilogitlink
,
multinomial
,
VGAMextra.
# Example 1
cumulative()
cumulative(link = "probitlink", reverse = TRUE, parallel = TRUE)
# Example 2
wdata <- data.frame(x2 = runif(nn <- 1000))
wdata <- transform(wdata,
y = rweibull(nn, shape = 2 + exp(1 + x2), scale = exp(-0.5)))
fit <- vglm(y ~ x2, weibullR(lshape = logofflink(offset = -2), zero = 2),
data = wdata)
coef(fit, mat = TRUE)
# Example 3; multivariate (multiple) response
## Not run:
ndata <- data.frame(x = runif(nn <- 500))
ndata <- transform(ndata,
y1 = rnbinom(nn, exp(1), mu = exp(3+x)), # k is size
y2 = rnbinom(nn, exp(0), mu = exp(2-x)))
fit <- vglm(cbind(y1, y2) ~ x, negbinomial(zero = -2), ndata)
coef(fit, matrix = TRUE)
## End(Not run)
# Example 4
## Not run:
# fit1 and fit2 are equivalent
fit1 <- vglm(ymatrix ~ x2 + x3 + x4 + x5,
cumulative(parallel = FALSE ~ 1 + x3 + x5), cdata)
fit2 <- vglm(ymatrix ~ x2 + x3 + x4 + x5,
cumulative(parallel = TRUE ~ x2 + x4), cdata)
## End(Not run)
# Example 5
udata <- data.frame(x2 = rnorm(nn <- 200))
udata <- transform(udata,
x1copy = 1, # Copy of the intercept
x3 = runif(nn),
y1 = rnorm(nn, 1 - 3*x2, sd = exp(1 + 0.2*x2)),
y2 = rnorm(nn, 1 - 3*x2, sd = exp(1)))
args(uninormal)
fit1 <- vglm(y1 ~ x2, uninormal, udata) # This is okay
fit2 <- vglm(y2 ~ x2, uninormal(zero = 2), udata) # This is okay
fit4 <- vglm(y2 ~ x2 + x1copy + x3,
uninormal(zero = NULL, vfl = TRUE,
Form2 = ~ x1copy + x3 - 1), udata)
coef(fit4, matrix = TRUE) # VFL model
# This creates potential conflict
clist <- list("(Intercept)" = diag(2), "x2" = diag(2))
fit3 <- vglm(y2 ~ x2, uninormal(zero = 2), data = udata,
constraints = clist) # Conflict!
coef(fit3, matrix = TRUE) # Shows that clist[["x2"]] was overwritten,
constraints(fit3) # i.e., 'zero' seems to override the 'constraints' arg
# Example 6 ('whitespace' argument)
pneumo <- transform(pneumo, let = log(exposure.time))
fit1 <- vglm(cbind(normal, mild, severe) ~ let,
sratio(whitespace = FALSE, parallel = TRUE), pneumo)
fit2 <- vglm(cbind(normal, mild, severe) ~ let,
sratio(whitespace = TRUE, parallel = TRUE), pneumo)
head(predict(fit1), 2) # No white spaces
head(predict(fit2), 2) # Uses white spaces
# Example 7 ('zero' argument with character input)
set.seed(123); n <- 1000
ldata <- data.frame(x2 = runif(n))
ldata <- transform(ldata, y1 = rlogis(n, loc = 5*x2, scale = exp(2)))
ldata <- transform(ldata, y2 = rlogis(n, loc = 5*x2, scale = exp(1*x2)))
ldata <- transform(ldata, w1 = runif(n))
ldata <- transform(ldata, w2 = runif(n))
fit7 <- vglm(cbind(y1, y2) ~ x2,
# logistic(zero = "location1"), # location1 is intercept-only
# logistic(zero = "location2"),
# logistic(zero = "location*"), # Not okay... all is unmatched
# logistic(zero = "scale1"),
# logistic(zero = "scale2"),
# logistic(zero = "scale"), # Both scale parameters are matched
logistic(zero = c("location", "scale2")), # All but scale1
# logistic(zero = c("LOCAT", "scale2")), # Only scale2 is matched
# logistic(zero = c("LOCAT")), # Nothing is matched
# trace = TRUE,
# weights = cbind(w1, w2),
weights = w1,
data = ldata)
coef(fit7, matrix = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.