earg = list(cutpoint = 2, k = 1)
nbolf("p", earg = earg, short = FALSE)
nbolf("p", earg = earg, tag = TRUE)
p = seq(0.02, 0.98, by = 0.01)
y = nbolf(p, earg = earg)
y. = nbolf(p, earg = earg, deriv = 1)
max(abs(nbolf(y, earg = earg, inv = TRUE) - p)) # Should be 0
par(mfrow = c(2, 1), las = 1)
plot(p, y, type = "l", col = "blue", main = "nbolf()")
abline(h = 0, v = 0.5, col = "red", lty = "dashed")
plot(p, y., type = "l", col = "blue",
main = "(Reciprocal of) first NBOLF derivative")
# Another example
nn = 1000
x2 = sort(runif(nn))
x3 = runif(nn)
mymu = exp( 3 + 1 * x2 - 2 * x3)
k = 4
y1 = rnbinom(nn, mu = mymu, size = k)
cutpoints = c(-Inf, 10, 20, Inf)
cuty = Cut(y1, breaks = cutpoints)
plot(x2, x3, col = cuty, pch = as.character(cuty))
table(cuty) / sum(table(cuty))
fit = vglm(cuty ~ x2 + x3, fam = cumulative(link = "nbolf",
reverse = TRUE, parallel = TRUE, intercept.apply = TRUE,
mv = TRUE, earg = list(cutpoint = cutpoints[2:3], k = k)),
trace = TRUE)
head(fit@y)
head(fitted(fit))
head(predict(fit))
coef(fit)
coef(fit, matrix = TRUE)
constraints(fit)
fit@misc$earg
Run the code above in your browser using DataLab