proc glm and proc Nlin

Reply
Occasional Contributor
Posts: 18

proc glm and proc Nlin

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

Respected Advisor
Posts: 2,655

Re: proc glm and proc Nlin

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

Occasional Contributor
Posts: 18

Re: proc glm and proc Nlin

Posted in reply to SteveDenham

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

Respected Advisor
Posts: 2,655

Re: proc glm and proc Nlin

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

Occasional Contributor
Posts: 18

Re: proc glm and proc Nlin

Posted in reply to SteveDenham

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

Respected Advisor
Posts: 2,655

Re: proc glm and proc Nlin

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

Occasional Contributor
Posts: 18

Re: proc glm and proc Nlin

Posted in reply to SteveDenham

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

Respected Advisor
Posts: 2,655

Re: proc glm and proc Nlin

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

Occasional Contributor
Posts: 18

Re: proc glm and proc Nlin

Posted in reply to SteveDenham

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

Respected Advisor
Posts: 2,655

Re: proc glm and proc Nlin

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

Contributor
Posts: 35

Re: proc glm and proc Nlin

Posted in reply to SteveDenham

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.


Respected Advisor
Posts: 2,655

Re: proc glm and proc Nlin

Posted in reply to abhik_giri

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

Contributor
Posts: 35

Re: proc glm and proc Nlin

Posted in reply to SteveDenham

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;

Respected Advisor
Posts: 2,655

Re: proc glm and proc Nlin

Posted in reply to abhik_giri

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

Contributor
Posts: 35

Re: proc glm and proc Nlin

Posted in reply to SteveDenham

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


Ask a Question
Discussion stats
  • 19 replies
  • 756 views
  • 3 likes
  • 3 in conversation