The VGAM package provides a number of (parameter) link functions which are described in general here. Collectively, they offer the user considerable choice and flexibility for modelling data.
TypicalVGAMlink(theta, someParameter = 0, bvalue = NULL, inverse = FALSE,
deriv = 0, short = TRUE, tag = FALSE)
Numeric or character.
This is usually theta
is character then inverse
and
deriv
are ignored.
The name theta
should always be the name of the first argument.
Some parameter, e.g., an offset.
Boundary value, positive if given.
If 0 < theta
then
values of theta
which are less than or equal to 0 can be
replaced by bvalue
before computing the link function value.
Values of theta
which are greater than or equal to 1 can be
replaced by 1 minus bvalue
before computing the link function value.
The value bvalue = .Machine$double.eps
is sometimes a reasonable
value, or something slightly higher.
Logical. If TRUE
and deriv = 0
then
the inverse link value
theta
is really theta
is
really
Integer. Either 0, 1, or 2, specifying the order of the derivative. Some link functions handle values up to 3 or 4.
Logical.
These are used for labelling the blurb
slot of a
vglmff-class
object.
These arguments are used only if theta
is character,
and gives the formula for the link in character form.
If tag = TRUE
then the result is preceeded by a little
more information.
Returns one of: the link function value or its first or second derivative, the inverse link or its first or second derivative, or a character description of the link.
Here are the general details.
If inverse = FALSE
and deriv = 0
(default) then the
ordinary link
function
If inverse = TRUE
and deriv = 0
then the inverse
link function value is returned, hence theta
is really
If inverse = FALSE
and deriv = 1
then it is
inverse = FALSE
and deriv = 2
then it is
If inverse = TRUE
and deriv = 1
then it is
inverse = TRUE
and deriv = 2
then it is
It is only when deriv = 1
that
linkfun(theta, deriv = 1, inverse = TRUE)
and
linkfun(theta, deriv = 1, inverse = FALSE)
are reciprocals of each other.
In particular,
linkfun(theta, deriv = 2, inverse = TRUE)
and
linkfun(theta, deriv = 2, inverse = FALSE)
are not reciprocals of each other in general.
The output of link functions changed at VGAM 0.9-9
(date was around 2015-07).
Formerly, linkfun(theta, deriv = 1)
is now
linkfun(theta, deriv = 1, inverse = TRUE)
, or equivalently,
1 / linkfun(theta, deriv = 1, inverse = TRUE)
.
Also, formerly, linkfun(theta, deriv = 2)
was
1 / linkfun(theta, deriv = 2, inverse = TRUE)
.
This was a bug.
Altogether, these are big changes and the user should beware!
In VGAM 1.0-7
(January 2019)
all link function names were made to
end in the characters "link"
,
e.g.,
loglink
replaces loge
,
logitlink
replaces logit
.
For this most of them were renamed.
Upward compatability holds for older link function names,
however, users should adopt the new names immediately.
Almost all VGAM link functions have something similar to
the argument list as given above.
In this help file we have
The following is a brief enumeration of all VGAM link functions.
For parameters lying between 0 and 1 (e.g., probabilities):
logitlink
,
probitlink
,
clogloglink
,
cauchitlink
,
foldsqrtlink
,
logclink
,
gordlink
,
pordlink
,
nbordlink
.
For positive parameters (i.e., greater than 0):
loglink
,
negloglink
,
powerlink
.
For parameters greater than 1:
logloglink
,
loglogloglink
(greater than
For parameters between fisherzlink
,
rhobitlink
.
For parameters between extlogitlink
,
logofflink
(
For unrestricted parameters (i.e., any value):
identitylink
,
negidentitylink
,
reciprocallink
,
negreciprocallink
.
McCullagh, P. and Nelder, J. A. (1989). Generalized Linear Models, 2nd ed. London: Chapman & Hall.
TypicalVGAMfamilyFunction
,
linkfun
,
vglm
,
vgam
,
rrvglm
.
cqo
,
cao
.
# NOT RUN {
logitlink("a")
logitlink("a", short = FALSE)
logitlink("a", short = FALSE, tag = TRUE)
logofflink(1:5, offset = 1) # Same as log(1:5 + 1)
powerlink(1:5, power = 2) # Same as (1:5)^2
# }
# NOT RUN {
# This is old and no longer works:
logofflink(1:5, earg = list(offset = 1))
powerlink(1:5, earg = list(power = 2))
# }
# NOT RUN {
fit1 <- vgam(agaaus ~ altitude,
binomialff(link = "clogloglink"), hunua) # best
fit2 <- vgam(agaaus ~ altitude,
binomialff(link = clogloglink ), hunua) # okay
# }
# NOT RUN {
# This no longer works since "clog" is not a valid VGAM link function:
fit3 <- vgam(agaaus ~ altitude,
binomialff(link = "clog"), hunua) # not okay
# No matter what the link, the estimated var-cov matrix is the same
y <- rbeta(n = 1000, shape1 = exp(0), shape2 = exp(1))
fit1 <- vglm(y ~ 1, betaR(lshape1 = "identitylink",
lshape2 = "identitylink"),
trace = TRUE, crit = "coef")
fit2 <- vglm(y ~ 1, betaR(lshape1 = logofflink(offset = 1.1),
lshape2 = logofflink(offset = 1.1)), trace=TRUE)
vcov(fit1, untransform = TRUE)
vcov(fit1, untransform = TRUE) -
vcov(fit2, untransform = TRUE) # Should be all 0s
\dontrun{ # This is old:
fit1@misc$earg # Some 'special' parameters
fit2@misc$earg # Some 'special' parameters are here
}
par(mfrow = c(2, 2))
p <- seq(0.05, 0.95, len = 200) # A rather restricted range
x <- seq(-4, 4, len = 200)
plot(p, logitlink(p), type = "l", col = "blue")
plot(x, logitlink(x, inverse = TRUE), type = "l", col = "blue")
plot(p, logitlink(p, deriv=1), type="l", col="blue") # 1 / (p*(1-p))
plot(p, logitlink(p, deriv=2), type="l", col="blue") # (2*p-1)/(p*(1-p))^2
# }
Run the code above in your browser using DataLab