楼主: yan_0103
4248 9

[问答] R程序求助 [推广有奖]

  • 0关注
  • 1粉丝

大专生

78%

还不是VIP/贵宾

-

威望
0
论坛币
58 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
2106 点
帖子
23
精华
0
在线时间
91 小时
注册时间
2009-11-10
最后登录
2016-6-4

楼主
yan_0103 发表于 2011-6-11 14:59:59 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
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程序,但是不知道为什么实现不了,还请高手帮忙解决,不胜感激
二维码

扫码加我 拉你入群

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

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

关键词:R程序 求助 程序

沙发
zhangtao 发表于 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"这个函数
应该是少了个什么包吧?
数学好就是要天天学

藤椅
zhangtao 发表于 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
数学好就是要天天学

板凳
zhangtao 发表于 2011-6-11 15:37:33
少了个什么包吧?希望楼主提供文章等更多的信息。
数学好就是要天天学

报纸
yan_0103 发表于 2011-6-11 16:09:30
4# zhangtao


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

地板
qoiqpwqr 发表于 2011-6-11 21:18:07
google搜不到这个函数

7
yan_0103 发表于 2011-6-11 21:46:25
6# qoiqpwqr


恩,是呢,我也是没找见才会请教大家的,希望高手帮忙解决哦

8
ywh19860616 发表于 2011-6-11 22:14:17
找一下这个程序是谁写的,到他主页看看
如果R里面找不到Simulationposstgl,肯定是自编的
一份耕耘,一份收获。

9
yan_0103 发表于 2011-6-12 08:27:42
8# ywh19860616
谢谢诶,应该是自编的

10
qoiqpwqr 发表于 2011-6-12 08:42:20
楼主从哪儿搞到这一段程序的?

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 15:29