[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: command: stpiece

From   Maarten buis <>
Subject   Re: st: command: stpiece
Date   Fri, 22 Feb 2008 11:07:21 +0000 (GMT)

--- Mussida Chiara <> wrote:
> I'm trying to sort out a specification issue for stpiece analysis.
> More precisely I must estimate a piecewise constant hazard model for
> U duration (survival analysis). This, as you know, means to specify
> piece in which the dependent variable (for my model it is the
> unemployment duration, measured in months) is constant. The problem
> arise since, as stata help suggests: 
> The data must be st. In order to create time pieces, an id variable
> must be declared with stset. See st and stset. 
> Now: is the id variable an additional variable to ne generated, or it
> simply refers to my dependent variable and therefore to the precise
> turning point that I want to specify?? this point for me is the
> median of the dependent variable distrn, and in a successive
> estimations there will be more time intervals dictated by the
> relative frequency of the observations...

First of all -stpiece- is not part of official Stata. It realy helps if
you tel us where you got this program form, so we can be sure that we
are all talking about the same program. For now I assume you are using
the version from -ssc-. 

The id variable you can specify in -stset- is a variable that
identifies the respondent. In survival analysis, the same person can
appear in multiple rows in your dataset, actually -stpiece- depends on
this fact. The id variable tells Stata which row belongs to which
individual. If you start with a "one row per person" dataset than the
id variable may be absent. In that case you can make one using: 

gen long id = _n

_n is the current observation number, so the first person will get the
value 1, the second 2, etc. 

I have given this variable the datatype long to make sure that this
will work in large datasets (upto aprox. 2,000,000,000 individuals)
(for more on this issue see here: )

I have added a working at the bottom of this post.

For more on preparing your data for survival analysis see this excelent
course website by Stephen Jenkins:

Hope this helps,

*------------------ begin example -------------
sysuse cancer, clear
gen long id = _n
stset studytime, failure(died) id(id)
xi: stpiece age i.drug, tp(5 10 20) 
*------------------- end example ---------------
(For more on how to use examples I sent to the Statalist, see )

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Sent from Yahoo! Mail.
A Smarter Inbox.
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index