********************************************************************************** *Log-normal Survival Model with Stock Sampling and Right Censoring (equation (4.17) of my PhD paper) ********************************************************************************** *** *$ML_y1=dur - life time of firm i for non-censored (complete) observations *$ML_y2= tleft - life time of firm i at the moment of the first questionnaire (stock sampling parametre) *$ML_y3=d - dummy= 1 if observation is complete (noncensored), and 0 otherwise * $ML_y4=tright - life time of firm i at the moment of the last questionnaire (right censoring parametre) *X1=theta5 - vector of covariates *** #delimit cr cap prog drop kostya_lognormal_survival program define kostya_lognormal_survival version 8.0 args lnf theta5 sigma2 tempvar sigmad qui gen double `sigmad'=exp(`sigma2') local V=`sigmad' tempvar A B qui g double `A'=(normden(ln($ML_y1)-`theta5',0,`V'))/(1- normprob((ln($ML_y2)-`theta5')/`V')) qui g double `B'=[1-normprob((ln($ML_y4)-`theta5')/`V')]/(1- normprob((ln($ML_y2)-`theta5')/`V')) qui replace `lnf'=ln( $ML_y3*`A' +(1-$ML_y3)*`B') end #delimit; ml model lf kostya_lognormal_survival (survival: dur tleft d tright = cj artisan francha loc2 sexe etrange age age_2 diplom1 diplom2 diplom3 nbcr expro1 expro2 proch1 motiv1a motiv2a motiv3a crqui2 crqui3 crqui4 crqui5 k pret sub exo iaa horsiaa constr transp immobil serventr servpart educsant reg21 reg22 reg23 reg24 reg25 reg26 reg31 reg41 reg42 reg43 reg52 reg53 reg54 reg72 reg73 reg74 reg82 reg83 reg91 reg93 reg94) /lnsigma2 ; ml maximize;