如何在加载 LogisticDx 后重置 plot 函数的默认 (graphics::) 行为?

How to reset the default (graphics::) behavior of the plot function after loading LogisticDx?

LogisticDx 包占用了plot 功能。

在加载 LogisticDx 之前,如果您拟合逻辑模型(使用 glmfamily=binomial),您可以简单地使用 plot 命令获得诊断图。加载 LogisticDx 包后,当您尝试绘制 glm 对象时,您只能得到 LogisticDx 版本。

注1: LogisticDX没有plot方法。它以某种方式完全改变了情节功能。因此不存在 LogisticDx::plot.

这样的东西

注意 2: 即使在卸载 LogisticDx 包之后,glm 对象的 plot 函数行为仍然改变。

注意 3: 即使直接从 graphics 库调用 plot 也会导致行为改变。

注4:我刚刚注意到plot.glm plot 变体现在丢失了。

好像没有办法恢复原来的plot功能了!

例如:

example(glm)
plot(glm.D93, ask=FALSE) # works
library(LogisticDx)
plot(glm.D93)
## Error in plot.glm(glm.D93) : x$family$family == "binomial" is not TRUE

您可以拨打stats:::plot.lm()。 (令人困惑的是,plot.lm() 也处理 glm 图,这就是为什么你找不到 stats:::plot.glm。)

example(glm)
plot(glm.D93, ask=FALSE)
library(LogisticDx)
try(plot(glm.D93))
## Error in plot.glm(glm.D93) : x$family$family == "binomial" is not TRUE
stats:::plot.lm(glm.D93, ask=FALSE)  ## works
  • LogisticDx 是否有 plot.glm 方法,它只是被隐藏了:LogisticDx:::plot.glm
  • 你是对的 detach("package:LogisticDx") 不会删除方法定义。如果您不想重新启动 R,您可以做的最好的事情是 plot.glm <- stats:::plot.lm 屏蔽来自 LogisticDx.
  • 的版本