Programming the statistical procedures from SAS

proc nlin how to determine the initial parameters

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 117
Accepted Solution

proc nlin how to determine the initial parameters

 

%let a= 54.8829483019154;
%let b= 61.8215366579612  ;
%let c= 8.4693242460909 ;

proc nlin 	
		data=TXPTE_GENEALL method= MARQUARDT MAXITER=500;
		parms a=&a b=&b c=&c ;
		model GENEALL = 1 / (a + ((TRIM-b)/c)**2);
		output out= MODEL_GENERALISTE_CTX
		predicted= ESTIM_GENEALL
		parms= A B C;
	run;	

Hello,

 

 

I have a dataset "TXPTE_GENEALL" that holds 32 values.

by lauching the this proc nlin, the problem I encounter is tha the ESTIM_GENEALL column get only one value for each observations.

and the message is below:

WARNING: Step size shows no improvement.
WARNING: PROC NLIN failed to converge.
NOTE: Negative model SS. Check model and initial parameters.

 

I Wonder how to determine the correct values a, b, c.

thanks a lot in advance for your help

Nasser


Accepted Solutions
Solution
a month ago
SAS Super FREQ
Posts: 4,240

Re: proc nlin how to determine the initial parameters

Posted in reply to Nasser_alfea

I don't know. Your initial post says that the procedure does not converge. Usually that means that either 

1. The model does not fit the data, or

2. The model does not converge from the initial guess that you specified.

 

You can specify a grid of initial values if you think the model fits, but that it doesn't converge from the initial values &a, &b, and &c. See the doc for the PARMS statement. For example, you could try

 

PARMS a=25, 50, 100

      b=20 to 100 by 20 

      c = 5 to 12;     

 

I assume you've plotted the response against TRIM to see that your model is reasonable?

View solution in original post


All Replies
Frequent Contributor
Posts: 117

Re: proc nlin how to determine the initial parameters

Posted in reply to Nasser_alfea

I succeed to determine the starting values but I don't know how many values should be contained inside the input table

SAS Super FREQ
Posts: 4,240

Re: proc nlin how to determine the initial parameters

Posted in reply to Nasser_alfea

You need to  check the documentation and review the correct syntax for the MODEL statement. That syntax is invalid. Look at the examples, too. Perhaps you intended to say something like

LL =  1 / (a + ((TRIM-b)/c)**2);

MODEL GENEALL ~ general(LL);

Frequent Contributor
Posts: 117

Re: proc nlin how to determine the initial parameters

Thanks Rick for your quick response

I checked the documentation (your link) but i do not manage to find the correct syntax.

I took a look at the "Iteratively Reweighted Least Squares" paragraph.

and the syntax you suggested does not seem to work .

SAS Super FREQ
Posts: 4,240

Re: proc nlin how to determine the initial parameters

Posted in reply to Nasser_alfea

I'm sorry. My mistake. I gave you the link and syntax for PROC NLMIXED instead of NLIN. My apologies.

Frequent Contributor
Posts: 117

Re: proc nlin how to determine the initial parameters

don't worry about that. I noticed it. I think my syntax is correct because it works with another set of data.

my input dataset gets one column (a rate %) and there are obs. What I don not understand is why the "

ESTIM_GENEALL" column in the output table has the same value for all obs.

 

SAS Super FREQ
Posts: 4,240

Re: proc nlin how to determine the initial parameters

Posted in reply to Nasser_alfea

The following call to PROC NLIN uses your syntax on simulated data and gets non-constant predicted values. Therefore the problem you report is not because of the procedure. The most likely cause, therefore, is your data. This problem would occur if the parameter estimate for 'a' is huge or if TRIM is equal to 'b' or is very very close to 'b' for all observations.

 

%let a= 54.8829483019154;
%let b= 61.8215366579612  ;
%let c= 8.4693242460909 ;

data TXPTE_GENEALL;
do i = 1 to 200;
   TRIM = rand("Normal", &b, &c);
   GENEALL = 1 / (&a + ((TRIM-&b)/&c)**2) + 0.1*rand("Normal");
   output;
end;
run;

proc nlin 	
		data=TXPTE_GENEALL method= MARQUARDT MAXITER=500;
		parms a=&a b=&b c=&c ;
		model GENEALL = 1 / (a + ((TRIM-b)/c)**2);
		output out= MODEL_GENERALISTE_CTX
		predicted= ESTIM_GENEALL
		parms= A B C;
	run;	

/* visualize the predicted values */
proc sort data=MODEL_GENERALISTE_CTX;  by TRIM; run;

proc sgplot data=MODEL_GENERALISTE_CTX;
series x=TRIM y=ESTIM_GENEALL;
run;
Frequent Contributor
Posts: 117

Re: proc nlin how to determine the initial parameters

Thanks Rick.

sorry but I do not understand.

the rates values are like this below

 

data TXPTE_GENEALL;

input geneall 12.;

datalines;

 

0.0133904

0.0132869

0.0121815

0.0110640

0.0118499

...

and trim (that means quarters from year 2010 SEPT to 2017 DEC) so trim values are 1,2,3,4...31,32. so trim not close to b parameter wich is equal to 61.8215366579612.

do you mean I should change the b value ?

Solution
a month ago
SAS Super FREQ
Posts: 4,240

Re: proc nlin how to determine the initial parameters

Posted in reply to Nasser_alfea

I don't know. Your initial post says that the procedure does not converge. Usually that means that either 

1. The model does not fit the data, or

2. The model does not converge from the initial guess that you specified.

 

You can specify a grid of initial values if you think the model fits, but that it doesn't converge from the initial values &a, &b, and &c. See the doc for the PARMS statement. For example, you could try

 

PARMS a=25, 50, 100

      b=20 to 100 by 20 

      c = 5 to 12;     

 

I assume you've plotted the response against TRIM to see that your model is reasonable?

Frequent Contributor
Posts: 117

Re: proc nlin how to determine the initial parameters

thanks a lot Rick

 

it works. I don't have the message "PROC NLIN failed to converge" anymore but "Convergence criterion met"

I Wonder why you suggeses this grid values ?

I assume it is because my initials values were around a=55, b=62 and c=8, , exact ?

thanks

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 145 views
  • 2 likes
  • 2 in conversation