golf {VGAM} | R Documentation |
Computes the gamma-ordinal transformation, including its inverse and the first two derivatives.
golf(theta, earg = list(lambda = 1), inverse = FALSE, deriv = 0, short = TRUE, tag = FALSE)
theta |
Numeric or character.
See below for further details.
|
earg |
Extra argument for passing in additional information.
This must be list with component lambda .
Here, lambda is the shape parameter
in gamma2 .
A component in the list called cutpoint is optional; if omitted
then cutpoint is ignored from the GOLF definition.
If given, the cutpoints should be non-negative integers.
If golf() is used as the link function in
cumulative then, if the cutpoints are known, then
one should choose
reverse=TRUE, parallel=TRUE, intercept.apply=TRUE .
If the cutpoints are unknown, then choose
reverse=TRUE, parallel=TRUE, intercept.apply=FALSE .
|
inverse |
Logical. If TRUE the inverse function is computed.
|
deriv |
Order of the derivative. Integer with value 0, 1 or 2.
|
short |
Used for labelling the blurb slot of a
vglmff-class object.
|
tag |
Used for labelling the linear/additive predictor in the
initialize slot of a vglmff-class object.
Contains a little more information if TRUE .
|
The gamma-ordinal link function (GOLF) can be applied to a parameter lying in the unit interval. Its purpose is to link cumulative probabilities associated with an ordinal response coming from an underlying 2-parameter gamma distribution.
The arguments short
and tag
are used only if
theta
is character.
See Links
for general information about VGAM
link functions.
See Yee (2007) for details.
Prediction may not work on vglm
or
vgam
etc. objects if this link function is used.
Numerical values of theta
too close to 0 or 1 or out of range
result in large positive or negative values, or maybe 0 depending on
the arguments.
Although measures have been taken to handle cases where
theta
is too close to 1 or 0,
numerical instabilities may still arise.
In terms of the threshold approach with cumulative probabilities for
an ordinal response this link function corresponds to the
gamma distribution (see gamma2
) that has been
recorded as an ordinal response using known cutpoints.
Thomas W. Yee
Yee, T. W. (2007) Ordinal ordination with normalizing link functions for count data, (in preparation).
Links
,
gamma2
,
polf
,
nbolf
,
cumulative
.
earg = list(lambda=1) golf("p", earg=earg, short=FALSE) golf("p", earg=earg, tag=TRUE) p = seq(0.02, 0.98, len=201) y = golf(p, earg=earg) y. = golf(p, earg=earg, deriv=1) max(abs(golf(y, earg=earg, inv=TRUE) - p)) # Should be 0 ## Not run: par(mfrow=c(2,1), las=1) plot(p, y, type="l", col="blue", main="golf()") abline(h=0, v=0.5, col="red", lty="dashed") plot(p, y., type="l", col="blue", main="(Reciprocal of) first GOLF derivative") ## End(Not run) # Another example nn = 1000 x2 = sort(runif(nn)) x3 = runif(nn) mymu = exp( 3 + 1 * x2 - 2 * x3) lambda = 4 y1 = rgamma(nn, shape=lambda, scale=mymu/lambda) cutpoints = c(-Inf, 10, 20, Inf) cuty = Cut(y1, breaks=cutpoints) ## Not run: par(mfrow=c(1,1), las=1) plot(x2, x3, col=cuty, pch=as.character(cuty)) ## End(Not run) table(cuty) / sum(table(cuty)) fit = vglm(cuty ~ x2 + x3, fam = cumulative(link="golf", reverse=TRUE, parallel=TRUE, intercept.apply=TRUE, mv=TRUE, earg=list(cutpoint=cutpoints[2:3], lambda=lambda)), trace=TRUE) fit@y[1:5,] fitted(fit)[1:5,] predict(fit)[1:5,] coef(fit) coef(fit, matrix=TRUE) constraints(fit) fit@misc$earg