options crt; supres smpl ; ? ? Hazard function estimation ? Clint Cummins and Bronwyn H. Hall ? Version 4.2B ? January 1993 ? ? The example here is a log-linear hazard rate example, which ? is a variation of the Weibull model. See Lancaster, The ? Econometric Analysis of Transition Data, pp. 169-171 for further ? information. (Cambridge University Press). ? ? P(X,t) is the conditional probability that an individual who ? is employed at time t is still employed at time t+1. ? P(X,t) = 1/[1+exp(Xb + a*t)] ? ? For a person who become unemployed at time T, the likelihood ? function is P(X,1)*P(X,2)*...*P(X,T-1)*[1-P(X,T)] ? ? Toss some sample data. There is a single covariate x, normally ? distributed with mean zero and variance 1. Assume there are no ? time-varying covariates (no t term) for data generation. Therefore ? true value of a (below) will be zero. ? const nobs 100 ; smpl 1 nobs ; random x ; param a 0 b0 .5 b1 1 ; do iobs = 1 to nobs ; smpl iobs iobs ; set logthet = log(1+exp(x(iobs)*b1+b0))-.5772 ; random(mean=logthet,stdev=1.6449) logt ; enddo ; smpl 1 nobs ; t = int(exp(logt)+.999) ; msd t logt x ; hist (discrete,nbins=100,width=1) t ; smplif t>=0 & t<21 ; ? ? The program below shows how to automate the likelihood function ? construction if you know the maximum number of periods of ? observation. ? frml hazard logl = terms + (Xb + a*t) - log[1+exp(Xb + a*t)]; ? terms + log[1-P(X,T)] frml trick more = terms; set ti = 0; dot 1-20; ? E.g., the maximum for T is 20 set ti = ti+1; set t. = ti; ? T1=1, T2=2, etc. frml terms -(t>t.)*log(1+exp(Xb + a*t.)) + more; ? this term is ? non-zero if t > t. eqsub hazard terms trick; ? the trick turns more back into terms enddot; print hazard ; frml Xb b0 + b1*X ; ? Xb formula -- user-defined ? t is the "dependent variable" frml last terms = 0; eqsub hazard last Xb; ? ? Maximum likelihood estimation. ? ml (maxit=50) hazard; stop ; end ;