In the attempt to learn the use of stpm3 & related commands i tried to replicate the example given in the tutorial of Paul Lambert – Sofware & Tutorials site (https://pclambert.net/software.html) (Software&Tutorials-> standsurv ->Standardized Relative Survival) . Running the commands I got an error (r(198)) when running predict. The error occurs because of the option frame() of the cmd predict, particularly it happens when specifying the sub option mergecreate (or create or merge or replace in successive attempts)
I am using StataNow/SE 19.5 for windows, Revision 03 Jun 2026.
Follow a copy of the do file commands up until the point of error (is a copy of the command posted on the tutorial):
CODE
use https://www.pclambert.net/data/colonsim, clear
stset t, failure(dead=1,2) id(id) exit(time 5)
gen age = min(floor(agediag + _t),99)
gen year = floor(yeardiag + _t)
merge m:1 age year dep sex using https://www.pclambert.net/data/popmort_uk_2017, keep(match master) keepusing(rate)
drop age year
gen female = sex == 2
stpm3 i.dep i.female i.dep#i.female @ns(agediag,df(3)) (i.dep i.female)#@ns(agediag,df(3)), scale(lncumhazard) df(5) tvc(i.dep i.female @ns(agediag,df(3))) dftvc(3) bhazard(rate)
foreach age in 50 65 80 {
predict S`age'_dep1 S`age'_dep5, survival timevar(0 5, step(0.1)) ci ///
frame(surv_age, mergecreate) ///
at1(agediag `age' dep 1 female 1) ///
at2(agediag `age' dep 5 female 1)
}
CODE
Since I am new to frame use I am, probably, doing a mistake. But I am not able to figure out.
Thank a lot in advance for any help.
Dino F Vitale
I am using StataNow/SE 19.5 for windows, Revision 03 Jun 2026.
Follow a copy of the do file commands up until the point of error (is a copy of the command posted on the tutorial):
CODE
use https://www.pclambert.net/data/colonsim, clear
stset t, failure(dead=1,2) id(id) exit(time 5)
gen age = min(floor(agediag + _t),99)
gen year = floor(yeardiag + _t)
merge m:1 age year dep sex using https://www.pclambert.net/data/popmort_uk_2017, keep(match master) keepusing(rate)
drop age year
gen female = sex == 2
stpm3 i.dep i.female i.dep#i.female @ns(agediag,df(3)) (i.dep i.female)#@ns(agediag,df(3)), scale(lncumhazard) df(5) tvc(i.dep i.female @ns(agediag,df(3))) dftvc(3) bhazard(rate)
foreach age in 50 65 80 {
predict S`age'_dep1 S`age'_dep5, survival timevar(0 5, step(0.1)) ci ///
frame(surv_age, mergecreate) ///
at1(agediag `age' dep 1 female 1) ///
at2(agediag `age' dep 5 female 1)
}
CODE
Since I am new to frame use I am, probably, doing a mistake. But I am not able to figure out.
Thank a lot in advance for any help.
Dino F Vitale
