Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Using the predictnl command following a model containing restricted cubic splines and time-dependent effects


From   "Lambert, Paul C. (Dr.)" <pl4@leicester.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Using the predictnl command following a model containing restricted cubic splines and time-dependent effects
Date   Thu, 4 Oct 2012 09:54:18 +0100

Alison,

You can make use of the hrnumerator() and hrdenominator() options of stpm2's predict command. 

Below is an example for a model with a dichotomous and continuous covariate.

One think to note is that stpm2 models on the log cumulative hazard scale. The time-dependent hazard ratio for one of the covariates will depend on the value of other time-dependent covariates. This would not happen with models on the log hazard scale (unless of course you fitted an interaction). The differences are usually small, but it is something you should be aware of. I demonstrate this by obtaining predictions for the effect of  the dichotomous covariate (hormon) at different levels of the continuous covariate (age) and similarly for the hazard ratio for age.  

Paul


webuse brcancer, clear
stset rectime, f(censrec==1) scale(365.25)
rename x1 age
stpm2 hormon age, scale(hazard) df(4) tvc(hormon age) dftvc(2)

/* hazard ratio for hormon at age 40 and 60 */
predict hr1, hrnum(hormon 1 age 40) hrdenom(hormon 0 age 40) ci
predict hr2, hrnum(hormon 1 age 70) hrdenom(hormon 0 age 70) ci

line hr1* hr2* _t ,sort yscale(log)

/* hazard ratio for age at time 1*/
/* age 50 is set as the reference age */
gen t1=1
predict hr3, hrnum(hormon 0 age .) hrdenom(hormon 0 age 50) timevar(t1) ci
predict hr4, hrnum(hormon 1 age .) hrdenom(hormon 1 age 50) timevar(t1) ci
line hr3 hr4 age, sort yscale(log)

Dr Paul C Lambert
Reader in Medical Statistics
Centre for Biostatistics & Genetic Epidemiology
Department of Health Sciences 
University of Leicester
2nd Floor, Adrian Building
University Road 
Leicester LE1 7RH
Tel: +44 (0)116 229 7265, Fax: +44 (0)116 229 7250
e-mail: paul.lambert@le.ac.uk
Homepage: http://www2.le.ac.uk/Members/pl4/



-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Turnbull, Alison E.
Sent: 04 October 2012 03:35
To: statalist@hsphsun2.harvard.edu
Subject: st: Using the predictnl command following a model containing restricted cubic splines and time-dependent effects

Hello, 

I'm working with a model developed using the stpm2 package from SCC.  
The baseline hazard has 4 degrees of freedom with knots at time = 3, 7 and 21. 

Variable x1 is a continuous variable with a time-dependent effect and a knot at time=21. 
Variables x2 is a dichotomous variable with a time-dependent effect and a knot at time= 21.

The 4 derived spline variables for the baseline log cumulative hazard are 
_rcs1
_rcs2
_rcs3
_rcs4

And the spline variables for the time-dependent effects of x1 and x2 are
_rcs_x11
_rcs_x12
and 
_rcs_x21
_rcs_x22

I would like calculate the hazard ratios and associated 95% CIs for individuals with x1=1 relative to those with x1=0 at time = 2, 7, 10 and 30 as well as the hazard ratios for individuals with varying levels of x2 at the same time points.  I realize that these hazard ratios are non-linear functions of the model parameters  and will require use of the predictnl command but I am struggling to figure out the right equation.  

I would be greatly appreciative if someone could write out the command for one of these desired hazard ratios to help get me started.  

Thank you, 
alison

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index