turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- proc glm and proc Nlin

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-26-2014 01:40 AM

hi Guys

I hvae the following GLM program

**proc** **glm** data=GLM ;

class grdesc kmnrt ;

model logdlr=grdesc kmnrt kmnrt*age /solution;

; **quit**;

is there away that i can use the proc nlin procrdure to model the same situation to view the relevant results.

grdesc = different sub categories;

kmnrt related to grdesc as another sub category related to time,

logdlr is just another numeric cost and age as age;

thank you

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kana

06-26-2014 10:14 AM

PROC NLIN fits an equation that you specify that is non-linear in the parameters. It can be used for linear regression, but there are much better tools, such as PROC GLM that you have already used. So, to implement NLIN, it is important to know the functional form that you wish to fit. Please reply with that equation.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

06-27-2014 01:39 AM

hi Steve

please find a similar equation that is used at some point in the process.

Logdlr=((exp(&Intercept)*exp(VehFctr)*exp(kmintfct)*(EXP(AGE*kmage)))/10000).

I actually wanted to do linear regression with Proc nlin so see how vastly the parameters differ with respect to proc glm.

is there a way that i can model the above glm model with the varibles using proc nlin. just to see how converence of the model.

thanks steve

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kana

06-27-2014 09:18 AM

Well, let's deal with getting the glm model into NLIN first, as it is a multi-step process. First, since NLIN does not support a CLASS statement, you'll need to get everything correctly coded in dummy variables that NLIN will use. PROC GLMMOD is ideal for this:

proc glmmod data=glm outdesign=fornlin;

class grdesc kmnrt;

model logdlr = grdesc kmnrt kmnrt*age;

run;

From this, you will need to examine the structure of the fornlin dataset, to see the number of columns. The variable Col1 should be identically equal to 1, and represents the intercept. You won't need it for the regression:

proc nlin data=fornlin;

model logdlr = col2-col<maximum value of column numbers goes here, without the angle brackets>;

run;

Because this is linear in the parameters, you can skip a lot of the statements that are often included in NLIN code (PARAMETERS and DER). Also, NLIN does not support TEST, CONTRAST, ESTIMATE, LSMEANS or LSMESTIMATE, so your comparison must be on the solution vectors from the two procedures.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

06-30-2014 03:26 AM

hi steve

i have used the the following syntax

proc nlin data = fornlin noitprint;

model logdlr = col2 -col130;

run;

the log states that there are no parameters inthe model.

my next question is with regards to the dummy varibles, how do i use these dummy varibles in the model.

thanks steve

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kana

06-30-2014 09:44 AM

Looking through the documentation, it doesn't abppear that the MODEL statement in NLIN will accept the list form I gave (which is fine for REG). It must be of the form:

model y=b2*col2 + b3*col3 + b4*col4 ... and so forth on out to all 129 parameters.

I guess that explains why people so seldom use NLIN for regression of this sort.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

07-01-2014 03:49 AM

thanks steve

I managed to get the model to work. i am just worried that there are to many parameters ,

is there anothere wmodeling process that i can use instead of glm. to compare results.

regards

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kana

07-01-2014 07:32 AM

PROC REG immediately comes to mind. As do MIXED and GLIMMIX, which also accommodate the CLASS statement.

One thing to note about the two mixed model procedures--they are maximum likelihood oriented. The results should be the same as the OLS methods (GLM and REG) if there are no RANDOM or REPEATED statement.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

07-16-2014 04:07 AM

Hi Steve

Sorry for the late reply.

when using Proc nlin do i use the intercept in the model..

Next is it not possible to keep the names of the varibles as they are instead of col1 col2 col 3 .

regards

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kana

07-16-2014 07:50 AM

It is your choice as to including an intercept or not. It is coded as col1 in the GLMMOD output. As far as keeping the names of the variables, I don't have an answer. It seems to me that a format statement would be as code intensive as just renaming the variables.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

01-14-2015 10:51 AM

Hi Steve,

I am using NLIN - strangely, when my equation has intercept, it gives zero estimates for parameters A,B,C .

However, when I remove intecept, it gives estimates for A,B,C.

Model equation: y = C*exp(-(A+B*x))/(1 + exp(-(A+B*x)));

Any help would be greatly appreciated.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to abhik_giri

01-14-2015 11:06 AM

Could you please share your NLIN code, for both "with intercept" and "without intercept"? Unless this directly mirrors @Kana's situation, where dummy variables were involved, in which case the column vector of 1's should be excluded (without intercept, sort of).

I would guess that the zero estimates with an intercept included mean that the intercept value is a local minimum, but I need to se your code to really make any statement about that.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

01-14-2015 12:01 PM

without intercept:

PROC NLIN data=input_ds alpha=0.1;

PARAMETERS C=0 A=0 B=0;

MODEL y= C*exp(-(A+B*x))/(1 + exp(-(A+B*x)));

RUN;

with intercept:

PROC NLIN data=input_ds alpha=0.1;

PARAMETERS intercept=0 C=0 A=0 B=0;

MODEL y= intercept + C*exp(-(A+B*x))/(1 + exp(-(A+B*x)));

RUN;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to abhik_giri

01-14-2015 12:49 PM

Local minimum that the optimizer gets stuck in is my first guess. If you truly wish to offset by an additive amount (the intercept value), then there are two approaches. One is to grid search the initial estimates in the PARAMETERS statement. The other would be to use the values for A, B and C from fitting without an intercept as starting values for the "with intercept" model. These were derived with the assumption that the intercept is zero, and that is the starting value, so this would be a logical extension to see if the curve is offset along the Y axis.

Steve Denham

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SteveDenham

01-15-2015 02:06 AM

Thanks so much for the help Steve.

I tried with the second approach you suggested, however it spits missing value as standard error for B.

I am getting estimate value for all the parameters including B, but missing standard error only for B. The standard errors of the other three parameters are between 0.5 to 6.6