<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Find the global optimization for non-linear model (like Excel Solver) in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798536#M9091</link>
    <description>&lt;P&gt;&lt;EM&gt;&amp;gt; Moreover, I still wonder what is the difference between PROC HPNLMOD and NLMIXED that result the situation I encountered? Is there a specific method HPNLMOD use and another for NLMIXED.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Different procedures have different default options and methods (see the doc), but you could use HPNLMOD if you prefer. Take my example and replace "NLMIXED" with "HPNLMOD":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC HPNLMOD DATA=TEMP01;
PARAMETERS A=0 B=1;
PRED=EXP(A+B*RANKING);
LL=WEIGHT*ABS(PRED-TARGET);
MODEL Y ~ GENERAL(-LL);
ODS OUTPUT PARAMETERESTIMATES=TEMP_PARAM(KEEP=ESTIMATE);
RUN;

proc print data=Temp_Param; run;

/* visualize the fit */
data Pred;
set Temp01;
eta = -9.9997 + 1.0036 * Ranking;
Pred = exp(eta);
run;

proc sgplot data=Pred;
   scatter x=Ranking y=Target;
   series x=Ranking y=Pred;
   xaxis grid integer;
   yaxis grid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not sure what target_new(i) means, but perhaps it means the predicted values of the model. There is no reason to expect that the sum(weight[i]*Y[i]) is equal to the sum(weight[i]*Pred[i]). You are minimizing sum(weight[i]*abs(Y[i]-Pred[i])), which does not require that the sum of weights be equal.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Feb 2022 12:02:20 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-02-25T12:02:20Z</dc:date>
    <item>
      <title>Find the global optimization for non-linear model (like Excel Solver)</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798364#M9088</link>
      <description>&lt;P&gt;Hi everybody!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset as attached. The problem is find parameter a, b to minimize weighted error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used Excel Solver as illustrated and it worked like a charm. But when I wanted to use PROC HPNLMOD in SAS like below, it stopped at a point in which the error value is very far from the Excel's result. I don't know how to solve the most optimal value from PROC HPNLMOD.&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;PROC HPNLMOD DATA=TEMP01; &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;PARAMETERS A=0 B=0 LAMBDA=0; &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;PRED=EXP(A+B*RANKING); &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;LL=WEIGHT*ABS(PRED-TARGET); &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;MODEL Y ~ GENERAL(-LL); &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;ODS OUTPUT PARAMETERESTIMATES=TEMP_PARAM(KEEP=ESTIMATE); &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;RUN;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 12:04:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798364#M9088</guid>
      <dc:creator>lienbb2</dc:creator>
      <dc:date>2022-02-24T12:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Find the global optimization for non-linear model (like Excel Solver)</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798383#M9089</link>
      <description>&lt;P&gt;Your syntax has a few errors. You should always check the log to see what errors and warnings are present.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With such a small data set, you can use NLMIXED, which performs MLE estiamation. I think the following code is self-explanatory, but I would be happy to clarify any steps that might be confusing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Temp01;
input Pct Ranking	ABR Target;
Weight = Pct / 100;
Y = 0;
datalines;
5.74	1	-7.080829537	0.01
7.32	2	-6.224511583	0.04
8.01	3	-5.368193629	0.07
11.15	4	-4.511875675	0.06
13.57	5	-3.655557721	0.10
13.43	6	-2.799239766	0.15
12.69	7	-1.942921812	0.27
9.34	8	-1.086603858	0.48
6.68	9	-0.230285904	1.02
4.32	10	0.62603205	2.10
2.86	11	1.482350004	4.59
1.74	12	2.338667959	8.87
1.14	13	3.194985913	18.40
2.01	14	4.051303867	57.47
run;

/* fit the model to the data */
PROC NLMIXED DATA=TEMP01;
   PARAMETERS A=0 B=1;
   PRED=EXP(A+B*RANKING);
   LL=WEIGHT*ABS(PRED-TARGET);
   MODEL Y ~ GENERAL(-LL);
   ODS OUTPUT PARAMETERESTIMATES=TEMP_PARAM(KEEP=ESTIMATE);
RUN;

proc print data=Temp_Param; run;

/* visualize the fit */
data Pred;
set Temp01;
eta = -7.5314 + 0.8273 * Ranking;
Pred = exp(eta);
run;

proc sgplot data=Pred;
   scatter x=Ranking y=Target;
   series x=Ranking y=Pred;
   xaxis grid integer;
   yaxis grid;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Feb 2022 13:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798383#M9089</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-02-24T13:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Find the global optimization for non-linear model (like Excel Solver)</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798505#M9090</link>
      <description>Thank you very much it worked miracles.&lt;BR /&gt;&lt;BR /&gt;But when I checked the result, I found out that sum of weight(i)*target(i) didn't equal to sum of weight(i)*target_new(i), which I need for my problem. How can I add such a constraint in the code?&lt;BR /&gt;&lt;BR /&gt;Moreover, I still wonder what is the difference between PROC HPNLMOD and NLMIXED that result the situation I encountered? Is there a specific method HPNLMOD use and another for NLMIXED.&lt;BR /&gt;&lt;BR /&gt;Thank you again for your so helpful reply.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Feb 2022 03:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798505#M9090</guid>
      <dc:creator>lienbb2</dc:creator>
      <dc:date>2022-02-25T03:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Find the global optimization for non-linear model (like Excel Solver)</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798536#M9091</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; Moreover, I still wonder what is the difference between PROC HPNLMOD and NLMIXED that result the situation I encountered? Is there a specific method HPNLMOD use and another for NLMIXED.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Different procedures have different default options and methods (see the doc), but you could use HPNLMOD if you prefer. Take my example and replace "NLMIXED" with "HPNLMOD":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC HPNLMOD DATA=TEMP01;
PARAMETERS A=0 B=1;
PRED=EXP(A+B*RANKING);
LL=WEIGHT*ABS(PRED-TARGET);
MODEL Y ~ GENERAL(-LL);
ODS OUTPUT PARAMETERESTIMATES=TEMP_PARAM(KEEP=ESTIMATE);
RUN;

proc print data=Temp_Param; run;

/* visualize the fit */
data Pred;
set Temp01;
eta = -9.9997 + 1.0036 * Ranking;
Pred = exp(eta);
run;

proc sgplot data=Pred;
   scatter x=Ranking y=Target;
   series x=Ranking y=Pred;
   xaxis grid integer;
   yaxis grid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not sure what target_new(i) means, but perhaps it means the predicted values of the model. There is no reason to expect that the sum(weight[i]*Y[i]) is equal to the sum(weight[i]*Pred[i]). You are minimizing sum(weight[i]*abs(Y[i]-Pred[i])), which does not require that the sum of weights be equal.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 12:02:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798536#M9091</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-02-25T12:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find the global optimization for non-linear model (like Excel Solver)</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798796#M9092</link>
      <description>&lt;P&gt;Thank you for your great help ^^&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 03:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Find-the-global-optimization-for-non-linear-model-like-Excel/m-p/798796#M9092</guid>
      <dc:creator>lienbb2</dc:creator>
      <dc:date>2022-02-26T03:24:53Z</dc:date>
    </item>
  </channel>
</rss>

