全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
8175 7
2013-04-07
我在做一个cubic spline的统计,统计饮酒量与肺癌发病RR的量效关系。
方法是是采用glst法,
想重复一下该方法原创者统计学家尼可拉斯提供的一个例子,http://nicolaorsini.altervista.org/stata/tutorial/g/alcohol_lc.txt结果发现最后画图的命令(红字部分)无法实现,说是无效命令或变量缺失。请有经验的朋友帮我看看,给予指点,不知是我的stata问题还是其他问题?谢

// Example 2

use http://nicolaorsini.altervista.org/data/ex_alcohol_lc, clear

// Two-stage fixed-effect dose-response model assuming linearity

glst logrr dose , se(se) cov(peryears cases) pfirst(study type) ts(f)

/* Relative risk for 12 grams/day incremental unit */
lincom dose*12 , eform

// Two-stage random-effect dose-response model assuming linearity

glst logrr dose , se(se) cov(peryears cases) pfirst(study type) ts(r)
/* Relative risk for 12 grams/day incremental unit */
lincom dose*12 , eform

// Non-linearity using fixed-effect  

capture drop doses*
_pctile dose , percentile(5 35 65 95)
ret list
mkspline doses  = dose  , knots(`=r(r1)' `=r(r2)' `=r(r3)' `=r(r4)') cubic displayknots
glst logrr doses* , se(se)  cov(peryears cases)    pfirst(study type)  
testparm doses2 doses3

// Figure 1 B of the paper  

glst  logrr dose , se(se)   cov(peryears cases)   pfirst(study type)  ts(f)
predictnl lrr_lin = _b[dose]*dose
gen rr_lin = exp(lrr_lin)

// using 0 as referent

glst logrr doses*, se(se) cov(peryears cases) pfirst(study type)
predictnl logrrwithref = _b[doses1]*doses1 + _b[doses2]*doses2 + _b[doses3]*doses3, ci(lo hi)
gen rrwithref  = exp(logrrwithref)
gen lbwithref  = exp(lo)
gen ubwithref  = exp(hi)

// Tabulate result using xblc (findit xblc)

levelsof dose, local(level)
xblc doses*, c(dose) at(`r(levels)') ref(0) eform  

twoway   ///
        (line lbwithref ubwithref rrwithref  dose,  sort lp(longdash longdash l ) lc(black black black) ) ///
                (line rr_lin  dose,  sort lp(shortdash) lc(black) )  ,    ///  
scheme(s1mono) ylabel(.9 1 1.2 1.5 1.8, angle(horiz) format(%3.2fc)) ///
xlabel(0(5)45)   ///
legend(off) ///  
ytitle("Relative Risk", margin(right)) ///   
xtitle("Alcohol intake, grams/day" , margin(top_bottom) ) name(figure1B, replace) yscale(log)  ///
  plotregion(style(none))
  

二维码

扫码加我 拉你入群

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

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

全部回复
2013-8-31 14:56:09
你解决了吗,我在作图的时候也遇到了一些问题哦~~~
二维码

扫码加我 拉你入群

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

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

2013-10-14 18:56:18
亲,把斜杠去了看看
二维码

扫码加我 拉你入群

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

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

2013-10-14 21:06:09
没有问题可以执行
二维码

扫码加我 拉你入群

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

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

2014-8-19 12:29:49
去掉那三条斜线就可以执行
二维码

扫码加我 拉你入群

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

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

2014-12-15 11:47:16
请问怎么做COX呢?
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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