拟合模型后,为什么不使用预测缺陷作为变量,使用对他们有意义的任何标准技术与其他缺陷进行比较?它具有作为连续变量的优点,因此您可以看到甚至很小的差异。例如,人们会理解 1.4 和 0.6 的预期缺陷数之间的差异,即使它们都舍入为 1。
有关预测值如何取决于两个变量的示例,您可以绘制时间与复杂度的等高线图,作为两个轴以及颜色和等高线来显示预测的缺陷;并将实际数据点叠加在顶部。
下面的图需要一些修饰和一个图例,但可能是一个起点。

另一种方法是添加变量图或部分回归图,这在传统的高斯响应回归中更为熟悉。这些在汽车库中实现。在其余解释变量对响应和解释变量的贡献都被删除之后,有效地显示了响应的剩余部分和解释变量之一的剩余部分之间的关系。以我的经验,大多数非统计受众发现这些有点难以理解(当然,这可能是我糟糕的解释)。

#--------------------------------------------------------------------
# Simulate some data
n<-200
time <- rexp(n,.01)
complexity <- sample(1:5, n, prob=c(.1,.25,.35,.2,.1), replace=TRUE)
trueMod <- exp(-1 + time*.005 + complexity*.1 + complexity^2*.05)
defects <- rpois(n, trueMod)
cbind(trueMod, defects)
#----------------------------------------------------------------------
# Fit model
model <- glm(defects~time + poly(complexity,2), family=poisson)
# all sorts of diagnostic checks should be done here - not shown
#---------------------------------------------------------------------
# Two variables at once in a contour plot
# create grid
gridded <- data.frame(
time=seq(from=0, to=max(time)*1.1, length.out=100),
complexity=seq(from=0, to=max(complexity)*1.1, length.out=100))
# create predicted values (on the original scale)
yhat <- predict(model, newdata=expand.grid(gridded), type="response")
# draw plot
image(gridded$time, gridded$complexity, matrix(yhat,nrow=100, byrow=FALSE),
xlab="Time", ylab="Complexity", main="Predicted average number of defects shown as colour and contours\n(actual data shown as circles)")
contour(gridded$time, gridded$complexity, matrix(yhat,nrow=100, byrow=FALSE), add=TRUE, levels=c(1,2,4,8,15,20,30,40,50,60,70,80,100))
# Add the original data
symbols(time, complexity, circles=sqrt(defects), add=T, inches=.5)
#--------------------------------------------------------------------
# added variable plots
library(car)
avPlots(model, layout=c(1,3))