# Specifying the linear predictor, survival function and PDF of a log-normal survival distribution

Continuing on my exploration of the log-normal distribution, I'm working on reimplementing some code originally written for a Weibull/Exponential model for a log-normal model. Among the things it does is use SAS's PROX NLMIXED to hard-calculate some likelihoods. While this is technically SAS code, I think it's pretty readable in a code-agnostic fashion.

For example, the Weibull Version:

*Linear Predictor of Event A
lam=exp(-(f0*alpha+f1*alpha*X));

*Density of Event A;
ff1=alpha*lam*t1**(alpha-1)*exp(-lam*t1**alpha);
ff2=alpha*lam*t2**(alpha-1)*exp(-lam*t2**alpha);

*Survival function of Event A;
sf1=exp(-lam*t1**alpha);
sf2=exp(-lam*t2**alpha);


The two survival functions are just at two different points in time for interval censoring.

I've implemented, I believe, the appropriate survival and density functions for a Log-Normal as follows:

*Density of EventA;
ff1 = exp(-0.5*((log(t1)-mu)/sigma)**2)/((t1*(2*CONSTANT('PI'))**0.5)*sigma);
ff2 = exp(-0.5*((log(t2)-mu)/sigma)**2)/((t2*(2*CONSTANT('PI'))**0.5)*sigma);

*Survival function of EventA;
sf1= 1 - CDF('Normal',((log(t1)-mu)/sigma));
sf2= 1 - CDF('Normal',((log(t2)-mu)/sigma));


I guess the first part of the question is does that appear correct? My second question is where I'm getting caught up, actually defining the linear predictor for the log normal. I think it should be something along the form of:

mu = exp(f0+f1*X) ala the Weibull above and with sigma estimated outside the linear predictor, but I'm not positive. Can someone point me in the right direction?

Edit: The goal PDF once the syntax errors are fixed is:

-
Hi, Epi. The code looks pretty close, except I think ff1 and ff2 have misplaced parentheses (syntax error) and sf2 should use t2, probably. Other than that, think of the lognormal just like it sounds: The log of the random variable is normal. So, if you wanted to do OLS, e.g., $\log Y$ would be your response variable. That should tell you how the predictors should enter in your scenario. :) – cardinal Aug 16 '12 at 10:29
Should it be something like: ff1 = exp(-0.5*((log(t1)-mu)/sigma)**2)/(t1*sigma*(2*CONSTANT('PI'))**0.5)? – cardinal Aug 16 '12 at 16:26
@cardinal I edited the code to, I believe, fix the problem. I'll post the actual function in an edit because it may be easier to keep track of than code. – EpiGrad Aug 16 '12 at 16:28
Ok. I'm much more comfortable with R, but I was just trying to match parentheses in a natural way to get them to come in the order I expected. Note that right after the first **2, that close parentheses has no matching open one. Also, I'm guessing based on standard rules of evaluation that the *sigma at the end will be in the numerator and not the denominator (where it should be). I realize my previous comments regarding this were likely too terse to be very useful. I'll await your further edits before commenting further. :-) – cardinal Aug 16 '12 at 16:34
@cardinal Don't underestimate their utility - the first one caused me to rethink what I had as the linear predictor. I believe I've fixed the functions now - there's a proper close parentheses, and the denominator is all wrapped up together. – EpiGrad Aug 16 '12 at 16:40