--- Claus Dethlefsen <[email protected]> wrote:
> However, it is still not quite what I want. In
> your setting, I want to set the variable ammonia to a given
> reference, for example 3. Then, the relative hazard should be 1 for
> ammonia=3. In your example code, the reference level for ammonia is
> set to 0, which is out of the observed range.
As long as the reference value is less than the second knot you can
just subtract that value from the original variable (ammonia) before
creating the spline terms (right now I can't think of a solution for
the situation when the reference category is more than the second
knot):
*------------------- begin example ------------------
set more off
use http://www.stata-press.com/data/cgg/reyes, clear
sum ammonia, detail
gen ammonia2 = ammonia - r(min)
mkspline rsam = ammonia2, cubic nknots(3)
stcox treat rsam*
adjust treat=0, by(ammonia) ci replace exp
twoway rarea lb ub ammonia || ///
line exp ammonia, ///
legend(off) ///
ytitle(hazard ratio) ///
name(nonlog, replace)
twoway rarea lb ub ammonia || ///
line exp ammonia, ///
legend(off) ///
ytitle("hazard ratio (log scale)") ///
yscale(log) yline(1) ///
ylab(1 2(2)10 20(20)100 200) ///
name(log, replace)
*-------------------- end example -------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/