If you look through the VGAM
source code, you'll find the following piece that throws the warning:
probs <-
if ( .reverse ) {
ccump <- cbind(1, eta2theta(eta, .link , earg = .earg ))
cbind(-tapplymat1(ccump, "diff"), ccump[, ncol(ccump)])
} else {
cump <- cbind(eta2theta(eta, .link , earg = .earg ), 1)
cbind(cump[, 1], tapplymat1(cump, "diff"))
}
okay1 <- all(is.finite(probs)) && all(0 < probs & probs < 1)
if (!okay1)
warning("It seems that the nonparallelism assumption has ",
"resulted in intersecting linear/additive ",
"predictors. Try propodds() or fitting a partial ",
"nonproportional odds model or choosing ",
"some other link function, etc.")
We can boil the guts of this down to a couple of different pieces:
library(VGAM)
#> Loading required package: stats4
#> Loading required package: splines
fit=vglm(cyl ~ wt, data=mtcars,
family=cumulative(parallel=F))
eta <- predict(fit, type="link")
cump <- cbind(VGAM:::eta2theta(eta, logitlink ), 1)
probs <- cbind(cump[, 1], tapplymat1(cump, "diff"))
Since cyl
has three values, eta
is an Nx2 matrix of predicted values on the link scale. cump
is the matrix of cumulative probabilities calculated in the usual way for ordered logit. probs
is the matrix of category probabilities calculated in the usual way for ordered logit - by subtracting the previous cumulative probability from the current one. Once these are calculated, a flag is generated to identify whether all probabilities are finite and in the theoretical bounds:
okay1 <- all(is.finite(probs)) && all(0 < probs & probs < 1)
#> [1] FALSE
In this case okay1
is FALSE
. We can see why below:
all(is.finite(probs))
#> [1] TRUE
all(0 < probs & probs < 1)
#> [1] FALSE
It's because some of the predicted probabilities are negative. We can see which ones below:
ind <- which(probs < 0 | probs > 1, arr.ind=TRUE)[,1]
ind
#> row
#> 16
probs[ind, ]
#> logitlink(P[Y<=2])
#> 1.253506e-04 -2.167395e-12 9.998746e-01
Notice here that the predicted probabilities for the second group are negative (though not much different from zero). The takeaway here is that even though you have specified parallel=FALSE
, the resulting model is incompatible with the underlying cumulative probability assumption. The warning is encouraging you to use a different model that doesn't calculate probabilities this way, like multinomial logit. For example:
fit2=vglm(cyl ~ wt, data=mtcars,
family=multinomial())
which doesn't throw a warning because the probabilities are calculated in a way that won't allow them to be outside [0,1], so long as the exponentiated predicted values on the link scale are finite.
Created on 2022-04-26 by the reprex package (v2.0.1)