全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
10605 1
2022-02-02
代码如下,set.seed里面是学号,数据是随机生成的,但是运行的时候显示

Warning message:
In coxph.fit(X, Y, istrat, offset, init, control, weights = weights,  :
  Loglik converged before variable  1 ; coefficient may be infinite.


这是原代码:
library(survival)
RNGkind(sample.kind = "Rejection")
set.seed(9766)   ## Change this number
#
#     Generate sample A times with censorng
#
LenA <- 5
TimeA <- sort(round(rexp(LenA, 0.48), digits = 10))
CensorA <- rbinom(LenA,1,0.5)
if(sum(CensorA[1:(LenA-1)]) == 0){
  CensorA[1] <- 1
}
cbind(TimeA, CensorA)
#
#     Generate sample B times with censorng
#
LenB <- 5
TimeB <- sort(round(rexp(LenB, 0.52), digits = 10))
CensorB <- rbinom(LenB,1,0.4)
if(sum(CensorB[1:(LenB-1)]) == 0){
  CensorB[1] <- 1
}
cbind(TimeB, CensorB)
#
#     Combine data
#
Time <- c(TimeA, TimeB)
Censor <- c(CensorA, CensorB)
Group <- factor(c(rep(1,LenA), rep(2,LenB)))
#
LenCom <- LenA + LenB
Age <- floor(runif(LenCom,10,100))
#
cbind(Time, Censor, Group, Age)

## Fit a Cox proportional hazards model
Cox.fit <- coxph(Surv(Time, Censor) ~ Group + Age)  

我输入过其他数字,9765和9767都没有这个问题,附近的数只有9762出现了同样的问题,所以问题是出在我这个学号上吗……?
二维码

扫码加我 拉你入群

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

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

全部回复
2022-2-2 18:06:43
顶一顶,求大神帮忙看一下
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群