搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  ships & veteran.zip
资料下载链接地址: https://bbs.pinggu.org/a-2943771.html
本附件包括:
  • veteran.csv
  • ships.csv
附件大小:
因为需要对分类变量不同组别的效应进行作图比较,用到qvcalc函数(回归分析中分类变量中各组通常只与参照组对比)。
按help中的例子用glm来做是没有问题的,数据集为R包里的"ships":
  1. library(qvcalc)
  2. ships <- read.csv(file = "/Users/ships.csv", header = TRUE)
  3. ships$year <- as.factor(ships$year)
  4. ships$period <- as.factor(ships$period)
  5. shipmodel <- glm(formula = incidents ~ type + year + period,
  6. family = quasipoisson,
  7. data = ships,
  8. subset = (service > 0),
  9. offset = log(service))
  10. shiptype.qvs <- qvcalc(shipmodel, "type")
  11. summary(shiptype.qvs, digits = 4)
  12. 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":
  1. library(survival)
  2. veteran <- read.csv(file = "/Users/veteran.csv", header = TRUE)
  3. cancermodel<-coxph(Surv(time,status)~celltype,data=veteran,x=T)
  4. cancercelltype.qvs <- qvcalc(cancermodel, "celltype")
复制代码


不同文献都提到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.



    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

GMT+8, 2026-2-7 23:40