ordpoisson(cutpoints, countdata = FALSE, NOS = NULL,
Levels = NULL, init.mu = NULL, parallel = FALSE,
zero = NULL, link = "loge", earg = list())
Inf
values may be included.
See below for further details.1
,
2
, ..., L
, say, where L
is the number of
levels. Such input can bcountdata = TRUE
.
Usually NOS = 1
.NOS
if necessary.
The number of levels for each response random variate.
This argument should agree with cutpoints
.
This argument must be specified when countdata = TRUE
NOS
if necessary.
Use this argument if the default initial values fail (the
default is to compute an initial value internally).poissonff
."vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
and vgam
.fit
is the fitted object, have a look at fit@extra
and
fit@y
to check.
If NOS=1
then
the argument cutpoints
is a vector $(K_1,K_2,\ldots,K_L)$
where the last value (Inf
) is optional. If NOS>1
then
the vector should have NOS-1
Inf
values separating
the cutpoints. For example, if there are NOS=3
responses, then
something like
ordpoisson(cut = c(0, 5, 10, Inf, 20, 30, Inf, 0, 10, 40, Inf))
is valid.
poissonff
,
polf
,
ordered
.set.seed(123) # Example 1
x2 = runif(n <- 1000); x3 = runif(n)
mymu = exp(3 - 1 * x2 + 2 * x3)
y1 = rpois(n, lambda = mymu)
cutpts = c(-Inf, 20, 30, Inf)
fcutpts = cutpts[is.finite(cutpts)] # finite cutpoints
ystar = cut(y1, breaks = cutpts, labels = FALSE)
plot(x2, x3, col = ystar, pch = as.character(ystar))
table(ystar) / sum(table(ystar))
fit = vglm(ystar ~ x2 + x3, fam = ordpoisson(cutpoi = fcutpts))
head(fit@y) # This can be input if countdata = TRUE
head(fitted(fit))
head(predict(fit))
coef(fit, matrix = TRUE)
fit@extra
# Example 2: multivariate and there are no obsns between some cutpoints
cutpts2 = c(-Inf, 0, 9, 10, 20, 70, 200, 201, Inf)
fcutpts2 = cutpts2[is.finite(cutpts2)] # finite cutpoints
y2 = rpois(n, lambda = mymu) # Same model as y1
ystar2 = cut(y2, breaks = cutpts2, labels = FALSE)
table(ystar2) / sum(table(ystar2))
fit = vglm(cbind(ystar,ystar2) ~ x2 + x3, fam =
ordpoisson(cutpoi = c(fcutpts,Inf,fcutpts2,Inf),
Levels = c(length(fcutpts)+1,length(fcutpts2)+1),
parallel = TRUE), trace = TRUE)
coef(fit, matrix = TRUE)
fit@extra
constraints(fit)
summary(fit@y) # Some columns have all zeros
Run the code above in your browser using DataLab