全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
4205 9
2011-06-11
M<-500
K<-100
n<-2
N<-n*K
alfa<-0.25
delta<-0.2  
beta<-0
stoptime<-2
condest<-matrix(0,M,5)
condsc<-matrix(0,M,2)
for(i in 1:M){  
print(i)

x<-Simulationposstgl(K,alfa,beta)  
clid<-as.vector(t(matrix(rep((1:K),2),K,2)))
time<-as.vector(t(x[,,1]))
status<-as.vector(t(x[,,2]))
z<-as.vector(t(x[,,3]))
s.tider<-sort(time[status[]==1])
k<-length(s.tider)
condest[i,5]<-coxph(Surv(time,status)~z)$coef
condest[i,4]<-coxph(Surv(time,status)~z+strata(clid))$coef  
condest[i,3]<-condest[i,5]/condest[i,4]
beta.I<-condest[i,5]
Lam<-cumsum(breslow.I(beta.I))
delta<-(s.tider[exp(-Lam)<=(1-0.05)])[1]
print(delta)
res<-c(0,0)
V<-1:4
U.c.res<-U.c(beta/alfa,alfa)
condsc[i,]<-as.vector(U.c.res[[4]])
condest[i,(1:2)]<-as.vector(NewR(beta/alfa,alfa))
print(condest[i,])
print(condsc[i,])
}
这是一段R程序,但是不知道为什么实现不了,还请高手帮忙解决,不胜感激
二维码

扫码加我 拉你入群

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

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

全部回复
2011-6-11 15:34:02
> M<-500
> K<-100
> n<-2
> N<-n*K
> alfa<-0.25
> delta<-0.2  
> beta<-0
> stoptime<-2
> condest<-matrix(0,M,5)
> condsc<-matrix(0,M,2)
> for(i in 1:M){  
+ print(i)
+
+ x<-Simulationposstgl(K,alfa,beta)  
+ clid<-as.vector(t(matrix(rep((1:K),2),K,2)))
+ time<-as.vector(t(x[,,1]))
+ status<-as.vector(t(x[,,2]))
+ z<-as.vector(t(x[,,3]))
+ s.tider<-sort(time[status[]==1])
+ k<-length(s.tider)
+ condest[i,5]<-coxph(Surv(time,status)~z)$coef
+ condest[i,4]<-coxph(Surv(time,status)~z+strata(clid))$coef  
+ condest[i,3]<-condest[i,5]/condest[i,4]
+ beta.I<-condest[i,5]
+ Lam<-cumsum(breslow.I(beta.I))
+ delta<-(s.tider[exp(-Lam)<=(1-0.05)])[1]
+ print(delta)
+ res<-c(0,0)
+ V<-1:4
+ U.c.res<-U.c(beta/alfa,alfa)
+ condsc[i,]<-as.vector(U.c.res[[4]])
+ condest[i,(1:2)]<-as.vector(NewR(beta/alfa,alfa))
+ print(condest[i,])
+ print(condsc[i,])
+ }
[1] 1
错误: 没有"Simulationposstgl"这个函数
应该是少了个什么包吧?
二维码

扫码加我 拉你入群

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

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

2011-6-11 15:36:44
> M<-500
> K<-100
> n<-2
> N<-n*K
> alfa<-0.25
> delta<-0.2  
> beta<-0
> stoptime<-2
> condest<-matrix(0,M,5)
> condsc<-matrix(0,M,2)
> for(i in 1:M)  
+
+ x<-Simulationposstgl(K,alfa,beta)  
错误: 没有"Simulationposstgl"这个函数
> clid<-as.vector(t(matrix(rep((1:K),2),K,2)))
> time<-as.vector(t(x[,,1]))
错误于x[, , 1] : 量度数目不对
> status<-as.vector(t(x[,,2]))
错误于x[, , 2] : 量度数目不对
> z<-as.vector(t(x[,,3]))
错误于x[, , 3] : 量度数目不对
> s.tider<-sort(time[status[]==1])
错误于sort(time[status[] == 1]) : 找不到对象'status'
> k<-length(s.tider)
错误: 找不到对象's.tider'
> condest[i,5]<-coxph(Surv(time,status)~z)$coef
错误: 没有"coxph"这个函数
> condest[i,4]<-coxph(Surv(time,status)~z+strata(clid))$coef  
错误: 没有"coxph"这个函数
> condest[i,3]<-condest[i,5]/condest[i,4]
> beta.I<-condest[i,5]
> Lam<-cumsum(breslow.I(beta.I))
错误: 没有"breslow.I"这个函数
> delta<-(s.tider[exp(-Lam)<=(1-0.05)])[1]
错误: 找不到对象's.tider'
> print(delta)
[1] 0.2
> res<-c(0,0)
> V<-1:4
> U.c.res<-U.c(beta/alfa,alfa)
错误: 没有"U.c"这个函数
> condsc[i,]<-as.vector(U.c.res[[4]])
错误于as.vector(U.c.res[[4]]) : 找不到对象'U.c.res'
> condest[i,(1:2)]<-as.vector(NewR(beta/alfa,alfa))
错误于as.vector(NewR(beta/alfa, alfa)) : 没有"NewR"这个函数
> print(condest[i,])
[1]   0   0 NaN   0   0
> print(condsc[i,])
[1] 0 0
二维码

扫码加我 拉你入群

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

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

2011-6-11 15:37:33
少了个什么包吧?希望楼主提供文章等更多的信息。
二维码

扫码加我 拉你入群

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

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

2011-6-11 16:09:30
4# zhangtao


我也是想知道用什么软件包的,是关于positive stable frailty model的一个模拟程序,但是不知道用的是哪一个软件包
二维码

扫码加我 拉你入群

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

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

2011-6-11 21:18:07
google搜不到这个函数
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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