is.buggy.RdChecks to see if a fitted object suffers from some known bug.
is.buggy(object, ...)
is.buggy.vlm(object, each.term = FALSE, ...)A fitted VGAM object, e.g., from
vgam.
Logical. If TRUE then a logical is returned for each term.
Unused for now.
It is known that vgam with s terms
do not correctly handle constraint matrices (cmat, say)
when crossprod(cmat) is not diagonal.
This function detects whether this is so or not.
Note that probably all VGAM family functions have defaults
where all crossprod(cmat)s are diagonal, therefore do
not suffer from this bug. It is more likely to occur if the
user inputs constraint matrices using the constraints
argument (and setting zero = NULL if necessary).
Second-generation VGAMs based on sm.ps are a
modern alternative to using s. It does not
suffer from this bug. However, G2-VGAMs require a reasonably
large sample size in order to work more reliably.
The default is a single logical (TRUE if any term is
TRUE),
otherwise a vector of such with each element corresponding to
a term. If the value is TRUE then I suggest replacing
the VGAM by a similar model fitted by vglm and
using regression splines, e.g., bs,
ns.
When the bug is fixed this function may be withdrawn, otherwise
always return FALSEs!
fit1 <- vgam(cbind(agaaus, kniexc) ~ s(altitude, df = c(3, 4)),
binomialff(multiple.responses = TRUE), data = hunua)
is.buggy(fit1) # Okay
#> [1] FALSE
is.buggy(fit1, each.term = TRUE) # No terms are buggy
#> (Intercept) s(altitude, df = c(3, 4))
#> FALSE FALSE
fit2 <-
vgam(cbind(agaaus, kniexc) ~ s(altitude, df = c(3, 4)),
binomialff(multiple.responses = TRUE), data = hunua,
constraints =
list("(Intercept)" = diag(2),
"s(altitude, df = c(3, 4))" = matrix(c(1, 1, 0, 1), 2, 2)))
is.buggy(fit2) # TRUE
#> [1] TRUE
is.buggy(fit2, each.term = TRUE)
#> (Intercept) s(altitude, df = c(3, 4))
#> FALSE TRUE
constraints(fit2)
#> $`(Intercept)`
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
#> $`s(altitude, df = c(3, 4))`
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 1 1
#>
# fit2b is an approximate alternative to fit2:
fit2b <-
vglm(cbind(agaaus, kniexc) ~ bs(altitude, df=3) + bs(altitude, df=4),
binomialff(multiple.responses = TRUE), data = hunua,
constraints =
list("(Intercept)" = diag(2),
"bs(altitude, df = 3)" = rbind(1, 1),
"bs(altitude, df = 4)" = rbind(0, 1)))
is.buggy(fit2b) # Okay
#> [1] FALSE
is.buggy(fit2b, each.term = TRUE)
#> (Intercept) bs(altitude, df = 3)1 bs(altitude, df = 3)2
#> FALSE FALSE FALSE
#> bs(altitude, df = 3)3 bs(altitude, df = 4)1 bs(altitude, df = 4)2
#> FALSE FALSE FALSE
#> bs(altitude, df = 4)3 bs(altitude, df = 4)4
#> FALSE FALSE
constraints(fit2b)
#> $`(Intercept)`
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
#>
#> $`bs(altitude, df = 3)1`
#> [,1]
#> [1,] 1
#> [2,] 1
#>
#> $`bs(altitude, df = 3)2`
#> [,1]
#> [1,] 1
#> [2,] 1
#>
#> $`bs(altitude, df = 3)3`
#> [,1]
#> [1,] 1
#> [2,] 1
#>
#> $`bs(altitude, df = 4)1`
#> [,1]
#> [1,] 0
#> [2,] 1
#>
#> $`bs(altitude, df = 4)2`
#> [,1]
#> [1,] 0
#> [2,] 1
#>
#> $`bs(altitude, df = 4)3`
#> [,1]
#> [1,] 0
#> [2,] 1
#>
#> $`bs(altitude, df = 4)4`
#> [,1]
#> [1,] 0
#> [2,] 1
#>