Closed friendly closed 9 years ago
This error occurs in ch11\nmes-multiv.Rnw
. A couple observations:
1) On line 105, you use cutfac()
, which is a vcdExtra
function, but vcdExtra
has not been loaded yet. You do load vcdExtra
on line 123. Should you put it earlier?
2) Regarding the error itself, I just walked through the file and did not get any error?
> car::linearHypothesis(nmes2.nbin, lh)
Linear hypothesis test
Hypothesis:
hospital:1 - hospital:2 = 0
hospital:2 - hospital:3 = 0
hospital:3 - hospital:4 = 0
Model 1: restricted model
Model 2: cbind(visits, nvisits, ovisits, novisits) ~ .
Res.Df Df Chisq Pr(>Chisq)
1 35215
2 35212 3 26.416 7.802e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
I'm not sure why you did?
Hmmm, that's the correct answer, but here is a MWE that gives me the same error:
data("NMES1988", package="AER")
nmes2 <- NMES1988[, c(1:4, 6:8, 13, 15, 18)]
str(nmes2)
# vector generalized additive model
library(VGAM)
nmes2.nbin <- vglm(cbind(visits, nvisits, ovisits, novisits) ~ ., data = nmes2,
family = negbinomial)
summary(nmes2.nbin)
# one term
lh <- paste("hospital:", 1:3, " = ", "hospital:", 2:4, sep="")
lh
car::linearHypothesis(nmes2.nbin, lh)
Interesting - that MWE doesn't give me an error either!
I just noticed that I have version 2.0-25 of car
loaded - not 2.1-0
. Maybe this has something to do with the update?
EDIT: Confirmed. I updated car
and now get the error.
That's very helpful. I suspected a change in VGAM, but wrote to both John Fox and Thomas Yee describing this problem. My current session, R 3.2.1, has
other attached packages:
[1] car_2.1-0 VGAM_0.9-8 countreg_0.1-3 MASS_7.3-43 myutil_1.4-1
I am running the same version of VGAM as you; the error only appeared when I specifically updated car. Hopefully John can shed some more light on this soon!
Testing different versions of a package can be a pain. I only recently learned of devtools:dev_mode()
that can be helpful for this, but my older version of car
has disappeared.
Could just install the older version from the CRAN archive source files via the usual R CMD INSTALL
way (https://cran.r-project.org/src/contrib/Archive/car/).
These version-based issues are probably going to become more and more annoying from here on in, so it might be a good idea to set up a packrat
project for more stable control over which package versions are being used. https://cran.r-project.org/web/packages/packrat/index.html and https://rstudio.github.io/packrat/walkthrough.html
John Fox wrote: I still don't quite understand the source of the problem but I have a kludgy solution: If I define
df.residual.vglm <- function(object, ...) object@df.residual
vcov.vglm <- function(object, ...) vcovvlm(object, ...)
coef.vglm <- function(object, ...) coefvlm(object, ...)
either globally or in the car package (in the latter case importing vcovvlm and coefvlm from VGAM but not exporting any of the .vglm S3 methods) linearHypothesis() works (again)
Very kludgy, but it works for me, so I'll try adding a hidden chunk to make this work in Ch 11.
John Fox reports that: I've checked the current situation, and it's as follows. Briefly, all problems seem solved:
For the time being, I'll keep the hidden <<fox-kludge>>
chunk so that David and others who compile the book won't get stung by this bug, but make a note in this issue that we should all install the devel versions until they both make their way to CRAN.
The devel versions are:
install.packages("car", repos="http://R-Forge.R-project.org")
My most recent commit now includes packages/
, with the current versions of car
, countreg
and VGAM
in source and Windows binary form.
This now works with the current (devel) versions of car
and VGAM
installed from packages/
.
I'll close this issue.
A quick check for R errors in the text finds the following on p. 498, at the very end of \S 11.7