以下是用STATA计算相加模型交互作用指标 RERI 的95%CI的程序(从文献复制过来 的),但程序运行到最后的时候出现的错误提示:
41.
. } /* close forvalues loop */
invalid syntax
program error: code follows on the same line as close brace
program error: code follows on the same line as close brace
program error: code follows on the same line as close brace
r(198);
本人对STATA了解甚少,请各位指点应该怎样纠正程序,谢谢!
原程序如下:
* obtain likelihood based CI limits *
***********************************
* initialize -2LL values
global LL = -2*e(ll)
global refLL = -2*e(ll)
* get interaction coefficient and standard error
matrix A = e(b)
global b3 = A[1,4]
matrix B = e(V)
global seb3 = sqrt(B[4,4])
* initialize other variables
global null = 0
global neglogl = 0
global diff = 0
global param = 0
global step = 0
global lcl = .
global ucl = .
* i = 1 for lower bound and i = 2 for upper bound
forvalues i = 1(1)2 {
global conv = 0
global step = $seb3
global beta = $b3
global num = 0
while $conv == 0 {
global num = $num + 1
constraint define $num _b[eq2:inter]== $beta
ml model lf linearodds (cons: ) (case = alcohol smoke inter, nocons),
constraint($num)
ml init A, copy
quietly ml maximize, difficult repeat(10)
global LL = -2*e(ll)
global diff = ($LL - $refLL)
if ($diff >= 3.8413 & $diff <= 3.8415) {
global conv = 1
if (`i' == 1) {
global lcl = $beta
}
if (`i' == 2) {
global ucl = $beta
}
}
if ($diff >= 3.8415) {
if (`i' == 1) {
global beta = ($beta + $step)
}
if (`i' == 2) {
global beta = ($beta - $step)
}
global step = ($step * 0.5)
}
disp $num, "null =", %8.4f $refLL," ","neglogl =", %8.4f $LL," ", "diff =", /*
*/ %6.4f $diff," ","step =", %6.4f $step," ","b3 =", %6.4f $beta
if (`i' == 1) {
global beta = ($beta - $step)
}
if (`i' == 2) {
global beta = ($beta + $step)
}
} /* close of while loop */
} /* close forvalues loop */
disp "-------------------------------------------------------------------------------"
disp "The likelihood based 95% CI limits are:", %6.4f $lcl,",",%6.4f $ucl