Hi All,
I am running a nlimixed procedure in the code below but getting large Gradient values. Any tip to address it is really appreciated.
SAS Code:
title"NLMIXED model";
proc nlmixed data=library.projectfulldata ;
parms intercept=0 s0=1 b_age=0 b_gender=0 b_NUMGO=0 b_meandelay=0 b_meanrt=0 b_ADHD1=0 b_OCD1=0 b_ASD1=0 b_ADHDOCD1=0 b_ADHDASD1=0 b_stoperror1=0 b_goerror1=0 b_noresponse1=0 b_prepush1=0 b_stopcorrect1=0;
eta=exp (intercept+ (b_age)*age+(b_gender)*gender+ (b_NUMGO)*NUMGO+(b_meandelay)*meandelay+ (b_meanrt)*meanrt+(b_ADHD1)*ADHD1+(b_OCD1)*OCD1 +(b_ASD1)*ASD1 +(b_ADHDOCD1)*ADHDOCD1 +(b_ADHDASD1)*ADHDASD1 +(b_stoperror1)*stoperror1+(b_goerror1)*goerror1 +(b_noresponse1)*noresponse1 +(b_prepush1)*prepush1 +(b_stopcorrect1)*stopcorrect1 + u0);
p=eta/(1+eta);
model stopcorrect~binary(p);
random u0~N(0,s0) subject=id ;
run;
SAS OUTPUT:
SAS Output
Data Set | LIBRARY.PROJECTFULLDATA |
Dependent Variable | stopcorrect |
Distribution for Dependent Variable | Binary |
Random Effects | u0 |
Distribution for Random Effects | Normal |
Subject Variable | id |
Optimization Technique | Dual Quasi-Newton |
Integration Method | Adaptive Gaussian Quadrature |
Observations Used | 327309 |
Observations Not Used | 0 |
Total Observations | 327309 |
Subjects | 13696 |
Max Obs per Subject | 24 |
Parameters | 17 |
Quadrature Points | 3 |
0.007191 | 0.03493 | 14E3 | 0.21 | 0.8369 | 0.05 | -0.06127 | 0.07565 | -1933.22 |
-111E-14 | 0.003041 | 14E3 | -0.00 | 1.0000 | 0.05 | -0.00596 | 0.005961 | 3464.237 |
-0.03399 | 0.001581 | 14E3 | -21.50 | <.0001 | 0.05 | -0.03709 | -0.03089 | -39226.8 |
0.01530 | 0.007302 | 14E3 | 2.10 | 0.0361 | 0.05 | 0.000992 | 0.02962 | -3119.54 |
-0.06348 | 0.001451 | 14E3 | -43.76 | <.0001 | 0.05 | -0.06632 | -0.06064 | -21301.3 |
0.001929 | 0.000024 | 14E3 | 80.07 | <.0001 | 0.05 | 0.001882 | 0.001976 | 611828.1 |
0.000160 | 0.000042 | 14E3 | 3.84 | 0.0001 | 0.05 | 0.000078 | 0.000242 | -168051 |
-0.00397 | 0.01599 | 14E3 | -0.25 | 0.8037 | 0.05 | -0.03532 | 0.02737 | -77.9574 |
-0.00032 | 0.05434 | 14E3 | -0.01 | 0.9953 | 0.05 | -0.1068 | 0.1062 | -29.3978 |
-0.00151 | 0.03943 | 14E3 | -0.04 | 0.9695 | 0.05 | -0.07880 | 0.07578 | 16.8127 |
-0.00066 | 0.06224 | 14E3 | -0.01 | 0.9915 | 0.05 | -0.1227 | 0.1213 | -8.02057 |
0.001201 | 0.06859 | 14E3 | 0.02 | 0.9860 | 0.05 | -0.1333 | 0.1357 | -49.1149 |
0.5016 | 0.01378 | 14E3 | 36.39 | <.0001 | 0.05 | 0.4746 | 0.5286 | 906.2667 |
-0.2435 | 0.01857 | 14E3 | -13.11 | <.0001 | 0.05 | -0.2799 | -0.2071 | 327.0716 |
-0.07538 | 0.03074 | 14E3 | -2.45 | 0.0142 | 0.05 | -0.1356 | -0.01513 | 314.5398 |
-0.05688 | 0.04590 | 14E3 | -1.24 | 0.2153 | 0.05 | -0.1469 | 0.03310 | 251.5092 |
0.1292 | 0.01291 | 14E3 | 10.01 | <.0001 | 0.05 | 0.1039 | 0.1545 | -522.615 |
A large gradient suggests the parameter estimate is not located at the minimum and, thus, could be changed to produce a better model fit. If any gradient is much above 0.001, one should adjust the initial parameter estimates and rerun the program.
Thanks Mohamed !
To change initial values for the parameters in the SAS code which values are preferable ?
For example, if we use the current SAS output coefficient values as the initial parameter values for the modified SAS code , will it be OK ? or generally, its try and error ?
For your specific case, this looks like it might be a logistic regression with a random-effects term added. In that situation, I would use PROC LOGISTIC to fit a fixed-effects model, then use those estimates as the initial estimates of the random-effects model.
Thank You Rick ! Will try it.
And I would fit it all in GLIMMIX, rather than doing the two step LOGISTIC followed by NLMIXED. I don't see anything in the NLMIXED code that couldn't be easily ported over to GLIMMIX. There is only a single subject level random effect being modeled as an additive term in the logit.
Steve Denham
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.