Ordinal Regression with Adjacent Categories Probabilities
acat.RdFits an adjacent categories regression model to an ordered (preferably) factor response.
Usage
acat(link = "loglink", parallel = FALSE, reverse = FALSE,
zero = NULL, ynames = FALSE, Thresh = NULL, Trev = reverse,
Tref = if (Trev) "M" else 1, Intercept = NULL,
whitespace = FALSE)Arguments
- link
Link function applied to the ratios of the adjacent categories probabilities. See
Linksfor more choices.- parallel
A logical, or formula specifying which terms have equal/unequal coefficients.
- reverse
Logical. By default, the linear/additive predictors used are \(\eta_j = \log(P[Y=j+1]/P[Y=j])\) for \(j=1,\ldots,M\). If
reverseisTRUEthen \(\eta_j = \log(P[Y=j]/P[Y=j+1])\) will be used.- ynames
See
multinomialfor information.- zero
An integer-valued vector specifying which linear/additive predictors are modelled as intercepts only. The values must be from the set {1,2,...,\(M\)}. See
CommonVGAMffArgumentsfor more information.- Thresh, Trev, Tref, Intercept
See
cumulativefor information. These arguments apply to ordinal categorical regression models.- whitespace
See
CommonVGAMffArgumentsfor information.
Details
In this help file the response \(Y\) is assumed to be a factor with ordered values \(1,2,\ldots,M+1\), so that \(M\) is the number of linear/additive predictors \(\eta_j\). By default, the log link is used because the ratio of two probabilities is positive.
Internally, deriv3 is called to
perform symbolic differentiation and
consequently this family function will struggle if
\(M\) becomes too large.
If this occurs, try combining levels so that
\(M\) is effectively reduced.
One idea is to aggregate levels with the fewest observations
in them first.
Value
An object of class "vglmff"
(see vglmff-class).
The object is used by modelling functions
such as vglm,
rrvglm
and vgam.
References
Agresti, A. (2013).
Categorical Data Analysis,
3rd ed. Hoboken, NJ, USA: Wiley.
Tutz, G. (2012).
Regression for Categorical Data,
Cambridge: Cambridge University Press.
Yee, T. W. (2010).
The VGAM package for categorical data analysis.
Journal of Statistical Software,
32, 1–34.
doi:10.18637/jss.v032.i10
.
Note
The response should be either a matrix of counts
(with row sums that are
all positive), or an ordered factor. In both cases,
the y slot returned
by vglm/vgam/rrvglm is the
matrix of counts.
For a nominal (unordered) factor response,
the multinomial logit model
(multinomial) is more appropriate.
Here is an example of the usage of the parallel argument.
If there are covariates x1, x2 and x3, then
parallel = TRUE ~ x1 + x2 -1 and
parallel = FALSE ~ x3 are equivalent.
This would constrain the regression coefficients
for x1 and x2 to be equal; those of the
intercepts and x3 would be different.
Warning
No check is made to verify that the response is ordinal if the
response is a matrix;
see ordered.
Examples
pneumo <- transform(pneumo, let = log(exposure.time))
(fit <- vglm(cbind(normal, mild, severe) ~ let, acat, pneumo))
#>
#> Call:
#> vglm(formula = cbind(normal, mild, severe) ~ let, family = acat,
#> data = pneumo)
#>
#>
#> Coefficients:
#> (Intercept):1 (Intercept):2 let:1 let:2
#> -8.9360297 -3.0390622 2.1653729 0.9020936
#>
#> Degrees of Freedom: 16 Total; 12 Residual
#> Residual deviance: 5.347382
#> Log-likelihood: -25.25054
#>
#> This is an adjacent categories model with 3 levels
coef(fit, matrix = TRUE)
#> loglink(P[Y=2]/P[Y=1]) loglink(P[Y=3]/P[Y=2])
#> (Intercept) -8.936030 -3.0390622
#> let 2.165373 0.9020936
constraints(fit)
#> $`(Intercept)`
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
#> $let
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
model.matrix(fit)
#> (Intercept):1 (Intercept):2 let:1 let:2
#> 1:1 1 0 1.757858 0.000000
#> 1:2 0 1 0.000000 1.757858
#> 2:1 1 0 2.708050 0.000000
#> 2:2 0 1 0.000000 2.708050
#> 3:1 1 0 3.068053 0.000000
#> 3:2 0 1 0.000000 3.068053
#> 4:1 1 0 3.314186 0.000000
#> 4:2 0 1 0.000000 3.314186
#> 5:1 1 0 3.511545 0.000000
#> 5:2 0 1 0.000000 3.511545
#> 6:1 1 0 3.676301 0.000000
#> 6:2 0 1 0.000000 3.676301
#> 7:1 1 0 3.828641 0.000000
#> 7:2 0 1 0.000000 3.828641
#> 8:1 1 0 3.941582 0.000000
#> 8:2 0 1 0.000000 3.941582
#> attr(,"assign")
#> attr(,"assign")$`(Intercept)`
#> [1] 1 2
#>
#> attr(,"assign")$let
#> [1] 3 4
#>
#> attr(,"vassign")
#> attr(,"vassign")$`(Intercept):1`
#> [1] 1
#>
#> attr(,"vassign")$`(Intercept):2`
#> [1] 2
#>
#> attr(,"vassign")$`let:1`
#> [1] 3
#>
#> attr(,"vassign")$`let:2`
#> [1] 4
#>
#> attr(,"constraints")
#> attr(,"constraints")$`(Intercept)`
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
#> attr(,"constraints")$let
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
#> attr(,"orig.assign.lm")
#> [1] 0 1