Skip to content

Commit

Permalink
version 3.1-2
Browse files Browse the repository at this point in the history
  • Loading branch information
john-d-fox authored and cran-robot committed Mar 30, 2023
1 parent 74fdaae commit d67a2f5
Show file tree
Hide file tree
Showing 16 changed files with 591 additions and 524 deletions.
15 changes: 9 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: car
Version: 3.1-1
Date: 2022-10-18
Version: 3.1-2
Date: 2023-03-25
Title: Companion to Applied Regression
Authors@R: c(person("John", "Fox", role = c("aut", "cre"), email = "[email protected]"),
person("Sanford", "Weisberg", role = "aut", email = "[email protected]"),
Expand Down Expand Up @@ -34,7 +34,7 @@ Imports: abind, MASS, mgcv, nnet, pbkrtest (>= 0.4-4), quantreg,
grDevices, utils, stats, graphics, lme4 (>= 1.1-27.1), nlme,
scales
Suggests: alr4, boot, coxme, effects, knitr, leaps, lmtest, Matrix,
MatrixModels, mvtnorm, rgl (>= 0.93.960), rio, sandwich,
MatrixModels, mvtnorm, rgl (>= 0.111.3), rio, sandwich,
SparseM, survival, survey
ByteCompile: yes
LazyLoad: yes
Expand All @@ -46,8 +46,6 @@ URL: https://r-forge.r-project.org/projects/car/,
https://CRAN.R-project.org/package=car,
https://socialsciences.mcmaster.ca/jfox/Books/Companion/index.html
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2022-10-18 19:06:59 UTC; johnfox
Author: John Fox [aut, cre],
Sanford Weisberg [aut],
Brad Price [aut],
Expand Down Expand Up @@ -77,4 +75,9 @@ Author: John Fox [aut, cre],
R-Core [ctb]
Maintainer: John Fox <[email protected]>
Repository: CRAN
Date/Publication: 2022-10-19 22:15:05 UTC
Repository/R-Forge/Project: car
Repository/R-Forge/Revision: 742
Repository/R-Forge/DateTimeStamp: 2023-03-25 21:15:09
Date/Publication: 2023-03-30 10:40:02 UTC
NeedsCompilation: no
Packaged: 2023-03-25 21:36:48 UTC; rforge
30 changes: 15 additions & 15 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
4de43bc0e9c3d451047844db99ae4492 *DESCRIPTION
4cce36a1a6008fcf977d3c6e16b55beb *DESCRIPTION
ab79e532a13c66fda227a7e88d86b2cc *NAMESPACE
1d34236aa24dfa06a171060a3b61e831 *NEWS
6586405c05ed19b45645957a210739a3 *NEWS
33fc2a976152118c303875d20dc97dc7 *R/Anova.R
3effd70a639a7336269f94a285d12807 *R/Boot.R
923a00fbf64c35abc42805ed43f4e974 *R/Boxplot.R
Expand All @@ -18,29 +18,29 @@ fa16056c5661a65fee6bdde242203df1 *R/avPlots.R
2da153aefab121e4b8c7f060187b49b0 *R/bcnPower.R
02ca2cad443a9b66dd49da2754e11d27 *R/boxCox.R
e999330432693c1369b1fb5e2ed7b116 *R/boxCoxVariable.R
7fb89c48255162874ea89411299a9955 *R/boxTidwell.R
9e7e873b105e6a817d913c7646263fa8 *R/boxTidwell.R
6f22e1a5ed891f0503b7207aa7cd66cb *R/brief.R
b420d3bdc47fb62ea2f33c1829533467 *R/car-defunct.R
ebcac6f262a26c74e59229ee1e30e7bc *R/car-deprecated.R
c6347c4eeef0dadeeb5c88ad9608dcf9 *R/carHexsticker.R
46a7d8f865abcfc4b78145e87d40ea25 *R/carWeb.R
3ed6b97ba60b4749edf08d428b022c71 *R/ceresPlots.R
320f846a1788e0b8ce19294a3d7238c1 *R/compareCoefs.R
2b6a9163fa192866fd2caa71b841228e *R/crPlot3d.R
bc4ff0d4ae34c7c0e5975d2672ef61c2 *R/crPlot3d.R
7550dc327b2fd42741f8b021599a6670 *R/crPlots.R
76ceb735f9775bcbaa0c218cf5fe0c31 *R/deltaMethod.R
5d4c4d78b963e1f598648246498f0d49 *R/densityPlot.R
cb88c6ed6b7df0507502578ba8faa887 *R/dfbetaPlots.R
a89ec78a4487110c5315c4d204517067 *R/durbinWatsonTest.R
1120fe3ce8db9681a01f1b771e11681d *R/hccm.R
e6efd6b31111d221ac5bfb388abf82ec *R/hccm.R
de1c06572c573c84d37a9e77b14b5ff2 *R/infIndexPlot.R
b2e49aeed279384dce3552ca8e73d7ea *R/influence-mixed-models.R
7754412cdc643bba6abb4618201c809d *R/influencePlot.R
8c40677332f61a2d70c95a9f96ec0253 *R/invResPlot.R
3cba0d8358049f1ecb54e7486ca8a889 *R/invTranPlot.R
07425429472a206c91e9a5f04553387a *R/leveneTest.R
82b62b0c7a152340d6ba2c042bc0ae0e *R/leveragePlots.R
8ba8ff9b4acb2ccf39b0b6037470a2cd *R/linearHypothesis.R
006d04a41a92488f990fe670527e357b *R/linearHypothesis.R
19223950b37d451f884a90c17812acc9 *R/logit.R
afdf9ac6fc5284816b8e686cc7339fc5 *R/marginalModelPlot.R
73d8f74a5019b754e13958b09b5fcd9f *R/mcPlots.R
Expand All @@ -54,8 +54,8 @@ edd2795ac4e2c188985a05adc0013e55 *R/powerTransformlmer.R
5cff5736345ed39803538314884e98cf *R/qqPlot.R
2b83ebb69b3fce0f752c4a6f80b5f23c *R/recode.R
2ffa28985dcab22f222c5687fed744a6 *R/regLine.R
754f41a48da5b5bcf5f5557acc34f2de *R/residualPlots.R
ac62f851567d6dfebd9a8e8b779bc6e7 *R/scatter3d.R
1fc031603f12a650ab5193631d4cbc81 *R/residualPlots.R
61b6f14b61374001fac9270dfaf62b6e *R/scatter3d.R
c7a3bb289e877e0449b84aa6b779c40f *R/scatterplot.R
57e68c519e455f66477253f6cf64f955 *R/scatterplotMatrix.R
2a39ba86fd900c0cc33a89f079f3bf91 *R/scatterplotSmoothers.R
Expand All @@ -70,11 +70,11 @@ e4ef1e9b4f2a34bcf71b7b72ecf6f01c *R/symbox.R
510fb482d599708b15d24f2389fc5f10 *R/vif.R
317b9f576ec59708c8945d1f8126c5fa *R/wcrossprod.R
d90296231464288e04124e8f1d864302 *R/which.names.R
f44f9d17f3bb733d89bbf63f82127643 *build/vignette.rds
e2082206594825292948475ea3960d0a *inst/CITATION
6562ecd41c431bc2058c32d122dcd205 *build/vignette.rds
edcd1ae9b4c637cf3fa19c394718fe5a *inst/CITATION
7621f84dece1418b1687ca3516d1bdf8 *inst/doc/embedding.R
984ec51291df672146d63264a1d3b428 *inst/doc/embedding.Rnw
7c849a22b546ec2c434128b19f4bb99a *inst/doc/embedding.pdf
29066ee521e727c67d4f2dca9c2f6097 *inst/doc/embedding.pdf
b6b5c8008a809152b9308aba25757693 *inst/misc/car-hex.pdf
37c2d8ee74207a549851e70344a4821e *man/Anova.Rd
379318432c40f0f6ae63bfa5d4827146 *man/Boot.Rd
Expand Down Expand Up @@ -107,7 +107,7 @@ b61ed466a568592d71fcbc43114ea5e5 *man/crPlots.Rd
a96436d9a0ec006374d431e9aa294b52 *man/densityPlot.Rd
3e5c68e5f118aa2a0abae358afd1bca5 *man/dfbetaPlots.Rd
90958fada247ed72d05247db2a5f7a24 *man/durbinWatsonTest.Rd
47fd0867ef19239e81e9fb3aaa7a4328 *man/hccm.Rd
a350c13d5e2e4ac206a9dbdeb9959369 *man/hccm.Rd
37ea5af56353b7db504b4327b347daf3 *man/hist.boot.Rd
9c03608405b5c26070c02c4cc1842a96 *man/infIndexPlot.Rd
bf8ee5ab1199f6fbb1de71e7b0e979c2 *man/influence-mixed-models.Rd
Expand All @@ -116,7 +116,7 @@ eca15590f3162495bef3432ffb08e631 *man/invResPlot.Rd
3f76990cbc8e9035c1cefd424cd1598a *man/invTranPlot.Rd
0b5bf989bf429ac840eeda6941b3eb30 *man/leveneTest.Rd
ccc93db837fab1926b25f3f9aca649e1 *man/leveragePlots.Rd
2e2392b15c254dc0d060a3b39e7f7f61 *man/linearHypothesis.Rd
a323297a0abd6ba7aa53c9b1e1be3772 *man/linearHypothesis.Rd
395cb504354ffb14de629bd7c9f5a49a *man/logit.Rd
20a6a2d1f94c5f734f0214f4b0f1ca46 *man/marginalModelPlot.Rd
c9c73b6960298f894e22d287445d6913 *man/mcPlots.Rd
Expand All @@ -129,8 +129,8 @@ c6eee7952bc60c84165353880dedb140 *man/powerTransform.Rd
e280dd002ab6d30f3d899bc352cdddcd *man/qqPlot.Rd
c44b1f80b6da4dc7a0405adbc9b95447 *man/recode.Rd
4a473fa630d2c75e4f2e84af1a6a7083 *man/regLine.Rd
72ce0e0d91029df6d790a4e6ea9fb0c8 *man/residualPlots.Rd
5461820747f444633ce8c18faaa1466c *man/scatter3d.Rd
579bf57ba115497e6ca5a4ea12d5366d *man/residualPlots.Rd
1101a151967d9d367bb869df756229b3 *man/scatter3d.Rd
ced81e87472eec1626d7f4bfb95c3157 *man/scatterplot.Rd
e178488836197c6142558fc7b1e47801 *man/scatterplotMatrix.Rd
39bd10269ecfd9b30c3f84a66b259e60 *man/showLabels.Rd
Expand Down
16 changes: 16 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
Changes to Version 3.1-2

o Fixed bugs in interface for residualPlots() and residualPlot()

o Fixed hccm() to return a correct error message when regressors are ill-conditioned.

o Use t-distribution for score tests in boxTidwell() and add omnibus score test (suggestions of Peter Dalgaard).

o residualPlots() is no longer confused by a one-column matrix regressor, produced, e.g., by scale() (issue reported by Tom Wenseleers).

o Make the printed formating of hypotheses in linearHypothesis() more tolerant of coefficients with certain non-standard names (after issue reported by Matthieu Stigler).

o Tweak linearHypothesis() for multinom models and add example.

o Update scatter3d() and crPlot3d() to use rgl::*3d() functions; requires rgl (>= 0.111.3) (patch courtesy of Duncan Murdoch).

Changes to Version 3.1-1

o Fixed bug in hccm(): when some cases are fit exactly all versions of the hccm estimate are singular and inconsistent. A error message is now returned.
Expand Down
24 changes: 20 additions & 4 deletions R/boxTidwell.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# 2009-09-29 by J. Fox (renamed)
# 2010-03-11 by J. Fox: output changed
# 2010-03-13 by J. Fox: output row label fixed when just one X
# 2022-10-25 by J. Fox: use t-distribution for score tests, add omnibus score test,
# suggestions of Peter Dalgaard
#-------------------------------------------------------------------------------


Expand Down Expand Up @@ -41,9 +43,17 @@ boxTidwell.default <- function(y, x1, x2=NULL, max.iter=25, tol=.001, verbose=FA
mod.2 <- lm(y ~ cbind(x.log.x, x1, x2), ...)
seb <- sqrt(diag(vcov(mod.2)))
which.coefs <- 2:(1 + k.x1)
F <- if (k.x1 > 1){
H <- cbind(0, diag(k.x1), matrix(0, k.x1, k.x1))
if (!is.null(x2)) H <- cbind(H, matrix(0, k.x1, ncol(x2)))
linearHypothesis(mod.2, H)
} else {
NULL
}
t.vals <- ((coefficients(mod.2))/seb)[which.coefs]
initial <- powers <- 1 + coefficients(mod.2)[which.coefs]/coefficients(mod.1)[which.coefs]
pvalues<-2*(pnorm(abs(t.vals), lower.tail=FALSE))
# initial <-
powers <- 1 + coefficients(mod.2)[which.coefs]/coefficients(mod.1)[which.coefs]
pvalues <- 2*(pt(abs(t.vals), df=df.residual(mod.2), lower.tail=FALSE))
iter <- 0
last.powers <- 1
while ((max(abs((powers - last.powers)/(powers + tol))) > tol) && (iter <= max.iter) ) {
Expand All @@ -58,15 +68,21 @@ boxTidwell.default <- function(y, x1, x2=NULL, max.iter=25, tol=.001, verbose=FA
}
if (iter > max.iter) warning("maximum iterations exceeded")
result <- cbind(powers, t.vals, pvalues)
colnames(result) <- c("MLE of lambda", "Score Statistic (z)", "Pr(>|z|)")
colnames(result) <- c("MLE of lambda", "Score Statistic (t)", "Pr(>|t|)")
rownames(result) <- if (nrow(result) == 1) "" else var.names
result <- list(result=result, iterations=iter)
result <- list(result=result, iterations=iter, F=F)
class(result)<-"boxTidwell"
result
}

print.boxTidwell <- function(x, digits=getOption("digits") - 2, ...){
printCoefmat(x$result, digits=digits, has.Pvalue=TRUE)
cat("\niterations = ", x$iterations,"\n")
if (!is.null(x$F)){
cat("\nScore test for null hypothesis that all lambdas = 1:\n")
cat(paste0("F = ", format(x$F$F[2], digits=digits), ", df = ", x$F$Df[2], " and ",
x$F$Res.Df[2], ", Pr(>F) = ", format.pval(x$F$"Pr(>F)"[2], digits=digits - 1), '\n\n'))
}
return(invisible(x))
}

81 changes: 41 additions & 40 deletions R/crPlot3d.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# added 2022-05-24 by J. Fox
# 2023-01-01: use rgl::*3d() function. Duncan Murdoch

crPlot3d <- function(model, var1, var2, ...) {
UseMethod("crPlot3d")
Expand Down Expand Up @@ -98,8 +99,8 @@ crPlot3d.lm <- function (model,
fogtype <- match.arg(fogtype)

rgl::next3d()
rgl::rgl.viewpoint(fov = fov)
rgl::rgl.bg(color = bg.col, fogtype = fogtype)
rgl::view3d(fov = fov)
rgl::bg3d(color = bg.col, fogtype = fogtype)

x.grid <- eff$variables[[var1]]$levels
z.grid <- eff$variables[[var2]]$levels
Expand Down Expand Up @@ -149,22 +150,22 @@ crPlot3d.lm <- function (model,
if (axis.scales) {
x.labels <- seq(lab.min.x, lab.max.x, by = diff(range(lab.min.x, lab.max.x))/4)
x.at <- seq(min.x, max.x, by = nice(diff(range(min.x, max.x))/4))
rgl::rgl.texts(x.at,-0.05, 0, x.labels, col = axis.col[1])
rgl::text3d(x.at,-0.05, 0, x.labels, col = axis.col[1])
z.labels <-seq(lab.min.z, lab.max.z, by = diff(range(lab.min.z, lab.max.z))/4)
z.at <- seq(min.z, max.z, by = diff(range(min.z, max.z))/4)
rgl::rgl.texts(0,-0.1, z.at, z.labels, col = axis.col[3])
rgl::text3d(0,-0.1, z.at, z.labels, col = axis.col[3])
y.labels <- seq(lab.min.y, lab.max.y, by = diff(range(lab.min.y, lab.max.y))/4)
y.at <- seq(min.y, max.y, by = diff(range(min.y, max.y))/4)
rgl::rgl.texts(-0.05, y.at,-0.05, y.labels, col = axis.col[2])
rgl::text3d(-0.05, y.at,-0.05, y.labels, col = axis.col[2])
}
}
else {
rgl::rgl.texts(min.x,-0.05, 0, lab.min.x, col = axis.col[1])
rgl::rgl.texts(max.x,-0.05, 0, lab.max.x, col = axis.col[1])
rgl::rgl.texts(0,-0.1, min.z, lab.min.z, col = axis.col[3])
rgl::rgl.texts(0,-0.1, max.z, lab.max.z, col = axis.col[3])
rgl::rgl.texts(-0.05, min.y,-0.05, lab.min.y, col = axis.col[2])
rgl::rgl.texts(-0.05, max.y,-0.05, lab.max.y, col = axis.col[2])
rgl::text3d(min.x,-0.05, 0, lab.min.x, col = axis.col[1])
rgl::text3d(max.x,-0.05, 0, lab.max.x, col = axis.col[1])
rgl::text3d(0,-0.1, min.z, lab.min.z, col = axis.col[3])
rgl::text3d(0,-0.1, max.z, lab.max.z, col = axis.col[3])
rgl::text3d(-0.05, min.y,-0.05, lab.min.y, col = axis.col[2])
rgl::text3d(-0.05, max.y,-0.05, lab.max.y, col = axis.col[2])
}
}

Expand All @@ -175,17 +176,17 @@ crPlot3d.lm <- function (model,
size <- sphere.size * ((100 / length(x)) ^ (1 / 3)) * 0.015
radius <- radius / median(radius)
if (size > threshold)
rgl::rgl.spheres(x, y, z, color = point.col, radius = size*radius)
rgl::spheres3d(x, y, z, color = point.col, radius = size*radius)
else
rgl::rgl.points(x, y, z, color = point.col)
rgl::points3d(x, y, z, color = point.col)

if (!axis.scales) axis.col[1] <- axis.col[3] <- axis.col[2]
rgl::rgl.lines(c(0, 1), c(0, 0), c(0, 0), color = axis.col[1])
rgl::rgl.lines(c(0, 0), c(0, 1), c(0, 0), color = axis.col[2])
rgl::rgl.lines(c(0, 0), c(0, 0), c(0, 1), color = axis.col[3])
rgl::rgl.texts(1, 0, 0, xlab, adj = 1, color = axis.col[1])
rgl::rgl.texts(0, 1.05, 0, ylab, adj = 1, color = axis.col[2])
rgl::rgl.texts(0, 0, 1, zlab, adj = 1, color = axis.col[3])
rgl::segments3d(c(0, 1), c(0, 0), c(0, 0), color = axis.col[1])
rgl::segments3d(c(0, 0), c(0, 1), c(0, 0), color = axis.col[2])
rgl::segments3d(c(0, 0), c(0, 0), c(0, 1), color = axis.col[3])
rgl::text3d(1, 0, 0, xlab, adj = 1, color = axis.col[1])
rgl::text3d(0, 1.05, 0, ylab, adj = 1, color = axis.col[2])
rgl::text3d(0, 0, 1, zlab, adj = 1, color = axis.col[3])
if (ellipsoid) {
dfn <- 3
dfd <- length(x) - 1
Expand All @@ -203,17 +204,17 @@ crPlot3d.lm <- function (model,
yhat <- (yhat - miny) / (maxy - miny)
yhat <- matrix(yhat, grid.lines, grid.lines)

rgl::rgl.surface(x.grid,
z.grid,
yhat,
color = surface.col[1],
alpha = surface.alpha,
lit = FALSE)
rgl::surface3d(x = x.grid,
z = z.grid,
y = yhat,
color = surface.col[1],
alpha = surface.alpha,
lit = FALSE)
if (grid)
rgl::rgl.surface(
x.grid,
z.grid,
yhat,
rgl::surface3d(
x = x.grid,
z = z.grid,
y = yhat,
color = if (fill) grid.col else surface.col[1],
alpha = surface.alpha,
lit = FALSE,
Expand All @@ -231,17 +232,17 @@ crPlot3d.lm <- function (model,
yhat <- predict(smooth, newdata=data.frame(expand.grid(x=x.grid, z=z.grid)))
yhat <- matrix(yhat, grid.lines, grid.lines)

rgl::rgl.surface(x.grid,
z.grid,
yhat,
color = surface.col[2],
alpha = surface.alpha,
lit = FALSE)
rgl::surface3d(x = x.grid,
z = z.grid,
y = yhat,
color = surface.col[2],
alpha = surface.alpha,
lit = FALSE)
if (grid)
rgl::rgl.surface(
x.grid,
z.grid,
yhat,
rgl::surface3d(
x = x.grid,
z = z.grid,
y = yhat,
color = if (fill) grid.col else surface.col[2],
alpha = surface.alpha,
lit = FALSE,
Expand Down Expand Up @@ -270,7 +271,7 @@ crPlot3d.lm <- function (model,
if (revolutions > 0) {
for (i in 1:revolutions) {
for (angle in seq(1, 360, length.out = 360 / speed))
rgl::rgl.viewpoint(-angle, fov = fov)
rgl::view3d(-angle, fov = fov)
}
}
return(invisible(NULL))
Expand Down
Loading

0 comments on commit d67a2f5

Please sign in to comment.