按help中的例子用glm来做是没有问题的,数据集为R包里的"ships":
- library(qvcalc)
- ships <- read.csv(file = "/Users/ships.csv", header = TRUE)
- ships$year <- as.factor(ships$year)
- ships$period <- as.factor(ships$period)
- shipmodel <- glm(formula = incidents ~ type + year + period,
- family = quasipoisson,
- data = ships,
- subset = (service > 0),
- offset = log(service))
- shiptype.qvs <- qvcalc(shipmodel, "type")
- summary(shiptype.qvs, digits = 4)
- plot(shiptype.qvs, xlab = "ship type")
但是用比例风险模型时总是报错,因变量是factor类型,不知道哪里出了问题:
Error in if (n <= 2) stop("qvcalc works only for factors with 3 or more levels") :
参数长度为零
数据集为R包里的"veteran":
- library(survival)
- veteran <- read.csv(file = "/Users/veteran.csv", header = TRUE)
- cancermodel<-coxph(Surv(time,status)~celltype,data=veteran,x=T)
- cancercelltype.qvs <- qvcalc(cancermodel, "celltype")
ships & veteran.zip
(2.98 KB)
本附件包括:- veteran.csv
- ships.csv
不同文献都提到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.


雷达卡



京公网安备 11010802022788号







