Dear Statalist,
I'm running this code, generating cubic splines for the variable FFMI against HRs. This gives me the error code "r(123); invalid numlist has too many elements". Why does this happen, and how can I improve my code to avoid this?
I'm running this code, generating cubic splines for the variable FFMI against HRs. This gives me the error code "r(123); invalid numlist has too many elements". Why does this happen, and how can I improve my code to avoid this?
Code:
foreach num of numlist 3/7{ preserve keep if cohort==1 & PartAg_NT4BLQ1>40.0 & PartAg_NT4BLQ1!=. stset enddate_ffmi, id(PID_109925) failure(RegisStat==5) origin(time BirthYear) enter(time PartDat_NT4BLQ1) scale(365.25) mkspline spl_ffmi = FFMI, cubic nknots(`num') displayknots stcox c.spl_ffmi* i.Sex, vce(robust) estat ic levelsof FFMI, local(levels) xblc spl_ffmi*, covname(FFMI) at(`levels') reference(18.5) eform gen(wffmi hr lb ub) keep if wffmi>12.0 & wffmi<29.0 twoway rline lb ub wffmi, lp(solid) lc(red) lw(medium) || line hr wffmi, lc(blue) lp(solid) lw(medium) /// legend(off) ylabel(, nogrid format(%3.2f)) yscale(log) yticks() xlabel(12(1)29, format(%3.0f)) xticks() xtitle("{bf:FFM (kg/m{sup:2})}") ytitle("{bf:HR (95% CI) for all-cause mortality}") /// yline(1, lc(black) lp(dash) lw(medthin)) name(no_copd_death_spl_ffmi_knot`num', replace) saving("M:\FFMIsplines.gph", replace) restore }
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str13 PID_109925 float FFMI "1099250000068" 20.257673 "1099250000075" 16.41549 "1099250000303" 16.261368 "1099250000433" 18.844908 "1099250000440" 19.078123 "1099250000556" 16.711199 "1099250000594" 16.096815 "1099250000747" 17.166037 "1099250000808" 23.12851 "1099250000815" 16.872831 "1099250000839" 21.20099 "1099250000976" 18.357824 "1099250001072" 15.002635 "1099250001102" 16.622509 "1099250001218" 15.96405 "1099250001379" 17.252134 "1099250001645" 18.876345 "1099250001690" 16.994984 "1099250001874" 20.27285 "1099250001911" 24.86499 "1099250001980" 15.426138 "1099250001997" 20.51911 "1099250002000" 21.389755 "1099250002017" 18.948357 "1099250002031" 20.587954 "1099250002079" 16.991798 "1099250002086" 22.66436 "1099250002154" 17.340462 "1099250002185" 21.074715 "1099250002222" 14.76981 "1099250002307" 20.29168 "1099250002499" 20.79452 "1099250002604" 15.637706 "1099250002680" 13.729548 "1099250002727" 24.500887 "1099250002840" 17.770155 "1099250002956" 17.600523 "1099250002970" 16.451637 "1099250003007" 22.63712 "1099250003052" 19.406385 "1099250003144" 16.657373 "1099250003243" 20.07525 "1099250003366" 17.922968 "1099250003373" 18.827162 "1099250003618" 16.72992 "1099250003700" 15.712954 "1099250003731" 18.618073 "1099250003984" 16.122509 "1099250004004" 22.994595 "1099250004035" 19.515856 "1099250004042" 14.438632 "1099250004073" 17.067698 "1099250004103" 17.162767 "1099250004134" 20.198105 "1099250004141" 21.98878 "1099250004196" 20.644033 "1099250004219" 19.55816 "1099250004233" 19.101213 "1099250004295" 19.83154 "1099250004486" 14.690882 "1099250004516" 16.955017 "1099250004615" 19.148285 "1099250004752" 19.73008 "1099250004783" 17.988977 "1099250004868" 16.573256 "1099250004899" 17.834265 "1099250004998" 17.433004 "1099250005025" 20.97489 "1099250005049" 18.173464 "1099250005216" 21.99749 "1099250005278" 19.14934 "1099250005285" 16.772224 "1099250005360" 15.84676 "1099250005421" 22.20912 "1099250005445" 15.887088 "1099250005544" 17.749592 "1099250005681" 17.077469 "1099250005728" 21.3407 "1099250005797" 16.324526 "1099250005803" 19.90521 "1099250005834" 20.154686 "1099250005865" 16.670069 "1099250005988" 20.57978 "1099250006190" 17.966629 "1099250006213" 24.858364 "1099250006244" 17.207388 "1099250006275" 18.172617 "1099250006305" 19.501144 "1099250006374" 19.584696 "1099250006398" 16.620935 "1099250006435" 19.601484 "1099250006558" 18.326319 "1099250006732" 17.016905 "1099250006749" 21.97266 "1099250006787" 17.824898 "1099250006794" 17.189758 "1099250006909" 16.591694 "1099250006916" 18.457619 "1099250006923" 19.51468 "1099250006985" 17.643011 end
Comment