| Date: | Sat, 20 Mar 2004 19:41:35 -0800 |
| Reply-To: | Gregor <gregor@MRCINA.BFRO.UNI-LJ.SI> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Gregor <gregor@MRCINA.BFRO.UNI-LJ.SI> |
| Organization: | http://groups.google.com |
| Subject: | Problems with initial parameters in NLMIXED (cumulative logit /
multinomial logit) |
| Content-Type: | text/plain; charset=ISO-8859-1 |
Hi!
I'm learning the NLMIXED procedure (I have attached code bellow). I
took data on period of exposure and prevalence of pneumoconiosis
amongst a group of coalminers from McCullagh and Nelder (2nd) page
179.
I successfully used nlmixed procedure with cumulative logit model. I
would like to try also with "usual multinomial logit" without
cumulative assumption. However I can't get the NLMIXED to run. I
always get this error
ERROR: No valid parameter points were found.
Since I tried also with grid search on initial parameters (even with
wider ranges than provided bellow) I think that there might be some
error(s) in my code. Can some drop an eye on it, please?
How can I also apply "multinomial logit model"? Which procedure? Any
examples?
/* DATA */
data coal;
input id time pneumo $ n yvar;
cards;
1 5.8 1normal 98 1
2 5.8 2mild 0 2
3 5.8 3severe 0 3
4 15.0 1normal 51 1
5 15.0 2mild 2 2
6 15.0 3severe 1 3
7 21.5 1normal 34 1
8 21.5 2mild 6 2
9 21.5 3severe 3 3
10 27.5 1normal 35 1
11 27.5 2mild 5 2
12 27.5 3severe 8 3
13 33.5 1normal 32 1
14 33.5 2mild 10 2
15 33.5 3severe 9 3
16 39.5 1normal 23 1
17 39.5 2mild 7 2
18 39.5 3severe 8 3
19 46.0 1normal 12 1
20 46.0 2mild 6 2
21 46.0 3severe 10 3
22 51.5 1normal 4 1
23 51.5 2mild 2 2
24 51.5 3severe 5 3
;
run;
data coal; set coal;
let = log(time);
run;
/* CUMULATIVE LOGIT */
proc nlmixed data = coal;
parms c1 = -3 c2 = -1 b1 = 0.2 b2 = 0.1;
array c[2] c1-c2;
array b[2] b1-b2;
array y[2] y1-y2;
array gamma[2] gamma1-gamma2;
do i = 1 to 2;
y[i] = c[i] + b[i] * let ;
gamma[i] = exp(-y[i])/(1 + exp(-y[i]));
end;
if (yvar = 1) then z = 1 - gamma1; /* cumulative logit
*/
else if (yvar = 2) then z = gamma1 - gamma2;
else z = gamma2;
if (z > 1e-8) then ll = log(z);
else ll = -1e100;
model yvar ~ general(ll);
replicate n;
run;
quit;
/* MULTINOMIAL LOGIT */
proc nlmixed data = coal;
parms c1 = -3 to 3 by 1
c2 = -3 to 3 by 1
b1 = -3 to 3 by 1
b2 = -3 to 3 by 1;
array c[2] c1-c2;
array p[2] p1-p2;
array y[2] y1-y2;
do i = 1 to 2;
y[i] = c[i] + b1 * let + b2 * let;
Psum = Psum + exp(y[i]);
end;
do i = 1 to 2;
p[i] = exp(y[i]) / (1 + Psum);
if (yvar = i) then z = p[i];
end;
if (yvar = 3) then z = 1 - p1 - p2;
if (z > 1e-8) then ll = log(z);
else ll = -1e100;
model yvar ~ general(ll);
replicate n;
run;
quit;
|