因为需要对分类变量不同组别的效应进行作图比较,用到qvcalc函数(回归分析中分类变量中各组通常只与参照组对比)。
按help中的例子用glm来做是没有问题的,数据集为R包里的"ships":
但是用比例风险模型时总是报错,因变量是factor类型,不知道哪里出了问题:
Error in if (n <= 2) stop("qvcalc works only for factors with 3 or more levels") :
参数长度为零
数据集为R包里的"veteran":
不同文献都提到qvcalc函数可以应用于比例风险模型:
The function qvcalc may be appliedto R objects of class lm (linear regressions), glm (generalized linear models), polr (orderedlogit or ‘proportional odds’ models), coxph (proportional hazards models), survreg (parametric survival models), gls (linear models fit by generalized least squares), lme (linearmixed-effect models, e.g., for hierarchical and longitudinal data) and others.