<?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: debug a subroutine; Call NLPQN in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735366#M5458</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I am out of the office this week, so the best I can do is remind you that the LL depends on the data. You are using seed=0, so you get a DIFFERENT likelihood function every time you run your function.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use a positive seed value for reproducibility.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When you see a LL function where the red area is on the boundary, it probably means that the maximum is outside of the domain you are using for ExpandGrid. It might even mean that the function is unbounded. It appears that for some of your random data set, the model does not fit the data. These are the 'spikes' where the optimal (alpha,beta) values are much different than for the bulk of the other data sets.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You either need to reexamine how you are generating the data (is your simulation correct?)&amp;nbsp; or you need to generate larger data sets so that the LL function has a well-defined maximum for most data sets.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have no idea why you are getting Chinese characters.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Apr 2021 21:13:05 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2021-04-19T21:13:05Z</dc:date>
    <item>
      <title>debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735130#M5450</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using (call nlpqn) in order to find MLEs. What I noticed is that the bias is extremely high for some data sets but not all of them. I don't know why this is happening?&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried to debug the subroutine by adding a print statement inside the subroutine to found that there are normal or close values of my likelihood function followed by spikes then values go back to normal values. If I increase the number of the simulation then I get more of these spikes!!!&lt;/P&gt;&lt;P&gt;Any clue why this is happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Salah_0-1618779253019.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58301i34200A0C3F5F8625/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Salah_0-1618779253019.png" alt="Salah_0-1618779253019.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc iml;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;n=20;&lt;/P&gt;&lt;P&gt;m=10;&lt;/P&gt;&lt;P&gt;R=J(m, 1, 0);&lt;/P&gt;&lt;P&gt;R[1]=10;&lt;/P&gt;&lt;P&gt;seed=22;&lt;/P&gt;&lt;P&gt;k=10;&lt;/P&gt;&lt;P&gt;alpha=1.5;&lt;/P&gt;&lt;P&gt;beta=0.8;&lt;/P&gt;&lt;P&gt;***********************************************************************************************;&lt;BR /&gt;*** LOG likelihood for the Lomax using Type II Adaptive progressive censoring ***** ;&lt;BR /&gt;***********************************************************************************************;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;start log_func(y) global (n,m,X,R,q);&lt;/P&gt;&lt;P&gt;func=0;&lt;/P&gt;&lt;P&gt;alpha=y[1];&lt;BR /&gt;beta=y[2];&lt;/P&gt;&lt;P&gt;Rq=R[1:q];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sum1=0;&lt;BR /&gt;Do i=1 to m;&lt;BR /&gt;Sum1=sum1+log(1+beta*X[i]);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sum2=0;&lt;BR /&gt;Do i=1 to q;&lt;BR /&gt;Sum2=Sum2+R[i]*log(1+beta*X[i]);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;func=func+m*log(alpha*beta)-(alpha+1)*Sum1-alpha*sum2-alpha*(n-m-Rq[+])*log(1+beta*X[m]);&lt;/P&gt;&lt;P&gt;*print func;&lt;/P&gt;&lt;P&gt;Return(func);&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;******************************************************************************************;&lt;BR /&gt;alpha_MLE=J(k,1,0);beta_MLE=J(k,1,0); MSE_a=J(k,1,0); MSE_b=J(k,1,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do N1=1 to K;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;****&amp;nbsp; &amp;nbsp; &amp;nbsp;Simulation&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;***;&lt;BR /&gt;****************************;&lt;/P&gt;&lt;P&gt;W=J(m,1,0);V=J(m,1,0);U=J(m,1,0);&amp;nbsp;X_p=J(m,1,0); X_A=J(m,1,0);&amp;nbsp;X=J(m,1,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i=1 to m;&lt;BR /&gt;W[i]=Uniform(seed);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;S=1+R[m];&lt;BR /&gt;V[1]=W[1]**(1/S);&lt;/P&gt;&lt;P&gt;do i=2 to m;&lt;BR /&gt;S=S+(1+R[m-i+1]);&lt;BR /&gt;V[i]=W[i]**(1/S);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;do i=1 to m;&lt;/P&gt;&lt;P&gt;U[i]=1-prod( V[ m:( m-i+1)] );** the U's are the required progressively type II from U(0,1);&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;**********************;&lt;/P&gt;&lt;P&gt;Call sort (U);&lt;BR /&gt;X_p=( (1-U)##(-1/alpha) -1 )/beta;&lt;/P&gt;&lt;P&gt;call sort (X_p);&lt;/P&gt;&lt;P&gt;*T= X_p[m/2];&lt;/P&gt;&lt;P&gt;*T=X_p[4*m/5];&lt;/P&gt;&lt;P&gt;T=X_p[m]+2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do idx=1 to m-1;&lt;BR /&gt;if (( X_p[idx] &amp;lt; T) &amp;amp; (X_p[idx+1] &amp;gt;= T)) then q=idx;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If X_p[m]&amp;gt;T then&lt;/P&gt;&lt;P&gt;do;&lt;/P&gt;&lt;P&gt;X_1_q=J(q,1,0);&lt;/P&gt;&lt;P&gt;X_1_q= X_p[1:q]; /* extract those failures that are less than T i.e. all X_1,...,X_j,X_(j+1) */&lt;/P&gt;&lt;P&gt;Xp_remaining=J(m-q,m,0); Y=J(m-q,m,0);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Y=X_p[q+1:m];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;**************************************************;&lt;BR /&gt;** Generate data of size m-q **;&lt;BR /&gt;**************************************************;&lt;BR /&gt;W1=J(m-q,1,0);&amp;nbsp; YY=J(m-q,1,0);&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;***************************************************************;&lt;BR /&gt;call randseed(seed);&lt;BR /&gt;call randgen(W1, "Uniform",0,1);&lt;/P&gt;&lt;P&gt;Call sort (W1);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;YY=( (1-W1)##(-1/alpha)#(1+beta*T)-1 )/beta;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X_A= X_1_q //YY;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;X=X_A;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;end;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else if ( X_p[m] &amp;lt;= T) then&lt;/P&gt;&lt;P&gt;do;&lt;BR /&gt;q= m;&lt;BR /&gt;X = X_p;&lt;/P&gt;&lt;P&gt;end;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;************* Constrain***********************;&lt;/P&gt;&lt;P&gt;con={.0001 .0001 , . .};&lt;BR /&gt;opt={1};&lt;BR /&gt;x0={0,0};&lt;/P&gt;&lt;P&gt;*************** MLE *********************;&lt;BR /&gt;tc={8000 12000};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call nlpqn(rc, y_ret, "log_func", x0, opt, con,tc);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;alpha_mle[N1]=y_ret[1];&lt;BR /&gt;beta_mle[N1]=y_ret[2];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;MSE_a[N1]=(alpha_mle[N1]-alpha)**2;&lt;BR /&gt;MSE_b[N1]=(beta_mle[N1]-beta)**2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;END; *end simulation;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bias_alpha=abs(alpha_MLE[:]-alpha);&lt;/P&gt;&lt;P&gt;Bias_beta=abs(beta_MLE[:]-beta);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MSE_alpha=MSE_a[:]/m;&lt;BR /&gt;MSE_beta=MSE_b[:]/m;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;print Bias_alpha MSE_alpha Bias_beta MSE_beta ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;print alpha_mle;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 21:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735130#M5450</guid>
      <dc:creator>Salah</dc:creator>
      <dc:date>2021-04-18T21:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735142#M5451</link>
      <description>&lt;P&gt;I am out of the office this week, so I can't run your program. However, it looks like your initial guess is (0,0), which violates the constraints. Try using a different initial guess, such as (1,1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another possibility for "spikes" are singularities on the loglikelihood function, which involves the term&amp;nbsp;&lt;SPAN&gt;log(1+beta*X[i]);&amp;nbsp; Of the LL might not have a local extremum.&amp;nbsp;&lt;/SPAN&gt;My suggestion: Find a data set that is showing the problem. Graph the LL(alpha, beta) as a function of (alpha,beta) on the interval (0.001,10] x (0.001,10] to get a feeling for the graph of the LL on the domain.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To graph the LL, you can evaluate the LL on a dense grid of points and use a scatter plot and the COLORERESPONSE= option. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2016/07/18/color-markers-third-variable-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2016/07/18/color-markers-third-variable-sas.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 23:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735142#M5451</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-04-18T23:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735179#M5452</link>
      <description>&lt;P&gt;I did what you suggested, unfortunately, I got&amp;nbsp; "&lt;FONT color="#FF0000"&gt;ERROR: Variable OPTION not found"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;In case the code worked then what? I am not sure about what I will find? Should I be able to see if there is a local maximum?&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;n=25; m=15; R=J(m, 1, 0); R[1]=10;&lt;/P&gt;&lt;P&gt;seed=0; k=10;&lt;/P&gt;&lt;P&gt;alpha=1.5; beta=0.8;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;*** generate a grid of points **;&lt;BR /&gt;********************************;&lt;/P&gt;&lt;P&gt;/* varies SLOW &amp;lt;-----------------&amp;gt; FAST */&lt;BR /&gt;/* values for alpha beta */&lt;/P&gt;&lt;P&gt;k = expandgrid(0.001:10, 0.001:10 );&lt;/P&gt;&lt;P&gt;start Func(Z) global (n,m,X,R,q);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sum1=0;&lt;BR /&gt;Do i=1 to m;&lt;BR /&gt;Sum1=sum1+log(1+z[,2]*X[i]);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;Sum2=0;&lt;BR /&gt;Do i=1 to q;&lt;BR /&gt;Sum2=Sum2+R[i]*log(1+z[,2]*X[i]);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;Rq=R[1:q];&lt;/P&gt;&lt;P&gt;LL=m#log(z[,1]#z[,2])-(z[,1]+1)#Sum1-z[,1]#sum2-z[,1]#(n-m-Rq[+])#log(1+z[,2]#X[m]);&lt;/P&gt;&lt;P&gt;return( LL);&lt;/P&gt;&lt;P&gt;finish;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;********************************************************************************************;&lt;BR /&gt;** progressive censoring ***;&lt;BR /&gt;****************************;&lt;/P&gt;&lt;P&gt;W=J(m,1,0);V=J(m,1,0);X_p=J(m,1,0); X_A=J(m,1,0); U=J(m,1,0);&lt;/P&gt;&lt;P&gt;X=J(m,1,0);&lt;/P&gt;&lt;P&gt;do i=1 to m;&lt;BR /&gt;W[i]=Uniform(seed);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;S=1+R[m];&lt;BR /&gt;V[1]=W[1]**(1/S);&lt;/P&gt;&lt;P&gt;do i=2 to m;&lt;BR /&gt;S=S+(1+R[m-i+1]);&lt;BR /&gt;V[i]=W[i]**(1/S);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;do i=1 to m;&lt;/P&gt;&lt;P&gt;U[i]=1-prod( V[ m:( m-i+1)] );&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;**********************;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Call sort (U);&lt;BR /&gt;&lt;BR /&gt;X_p=( (1-U)##(-1/alpha) -1 )/beta;&lt;/P&gt;&lt;P&gt;call sort (X_p);&lt;/P&gt;&lt;P&gt;*T= X_p[m/2];&lt;/P&gt;&lt;P&gt;*T=X_p[4*m/5];&lt;/P&gt;&lt;P&gt;T=X_p[m]+2;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;do idx=1 to m-1;&lt;BR /&gt;if (( X_p[idx] &amp;lt; T) &amp;amp; (X_p[idx+1] &amp;gt; T)) then q=idx;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If X_p[m]&amp;gt;T then&lt;/P&gt;&lt;P&gt;do;&lt;/P&gt;&lt;P&gt;X_1_q=J(q,1,0);&lt;/P&gt;&lt;P&gt;X_1_q= X_p[1:q];&lt;/P&gt;&lt;P&gt;Xp_remaining=J(m-q,m,0); Y=J(m-q,m,0);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Y=X_p[q+1:m];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;**************************************************;&lt;BR /&gt;** Generate data of size m-q **;&lt;BR /&gt;**************************************************;&lt;/P&gt;&lt;P&gt;W1=J(m-q,1,0); YY=J(m-q,1,0);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;call randseed(seed);&lt;BR /&gt;&lt;BR /&gt;call randgen(W1, "Uniform",0,1);&lt;/P&gt;&lt;P&gt;Call sort (W1);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;YY=( (1-W1)##(-1/alpha)#(1+beta*T)-1 )/beta;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;X_A= X_1_q //YY;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;X=X_A;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else if ( X_p[m] &amp;lt;= T) then&lt;/P&gt;&lt;P&gt;do;&lt;BR /&gt;q= m;&lt;BR /&gt;X = X_p;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;f = Func(k);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;print k[c={"alpha" "beta" }] f;&lt;/P&gt;&lt;P&gt;alpha=K[,1]; Beta=K[,2];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create _Temp var {alpha, beta};&lt;BR /&gt;append;&lt;BR /&gt;close _Temp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;submit;&lt;BR /&gt;title "Graph log-Likelihood function";&lt;BR /&gt;proc sgplot data=_Temp;&lt;BR /&gt;scatter x=alpha y=beta / colorresponse=option&lt;BR /&gt;markerattrs=(symbol=CircleFilled size=14); /* big filled markers */&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;endsubmit;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 07:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735179#M5452</guid>
      <dc:creator>Salah</dc:creator>
      <dc:date>2021-04-19T07:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735206#M5453</link>
      <description>&lt;P&gt;The error message is telling you that the variable called "option" does not exist in the data set _Temp.&amp;nbsp; You need to export the LL to this data set by adding "f" to the variable list in the CREATE statement and, then use colorresponse=f.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 10:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735206#M5453</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2021-04-19T10:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735207#M5454</link>
      <description>&lt;P&gt;1. You probably need a denser grid. Maybe something like&lt;/P&gt;
&lt;P&gt;xrange = 0.001 || do(0.1, 5, 0.1);&lt;/P&gt;
&lt;P&gt;yange = x;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;k = expandgrid( xrange, yrange );&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. You are trying to visualize the LL, so you need to write the 'f' value as well:&lt;BR /&gt;create _Temp var {alpha beta f};&lt;BR /&gt;append;&lt;BR /&gt;close _Temp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. Use COLORERESPONSE=f&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;4.My suggestion is the first item in &lt;A href="https://blogs.sas.com/content/iml/2016/05/11/tips-before-optimization.html" target="_self"&gt;the list of 10 tips before you run an optimization.&lt;/A&gt;&amp;nbsp;The other tips might also be helpful. I think you are doing some of them.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;5.&amp;nbsp;&lt;EM&gt;In case the code worked then what? I am not sure about what I will find? Should I be able to see if there is a local maximum?&amp;nbsp;&lt;BR /&gt;&lt;/EM&gt;Yes, the idea is that this enables you to visualize the LL for the cases that are failing. It should help you figure out the next step.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 10:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735207#M5454</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-04-19T10:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735355#M5455</link>
      <description>&lt;P&gt;The code is working with no errors but I am confused regarding the outcome values and the graph.&lt;/P&gt;&lt;P&gt;each time I change the range of my parameters I get different initial values&lt;/P&gt;&lt;P&gt;for example if I choose&amp;nbsp;&lt;FONT color="#FF0000"&gt;KK = ExpandGrid( do(0.001,10,0.05), do(0.001,10,.05) );&amp;nbsp;&lt;FONT color="#000000"&gt;then the values that maximize LL are &lt;FONT color="#FF0000"&gt;(alpha, beta)= (9.95, 9.95),&lt;/FONT&gt; for&amp;nbsp;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;KK = ExpandGrid( do(0.001,2,0.05), do(0.001,2,.05) ) I get&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;(alpha, beta)= (0.001, 0.001), f&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;or&amp;nbsp;KK = ExpandGrid( do(0.1,4,0.05), do(0.1,4,.05) );&amp;nbsp; I get (4,4) and so on. I am not sure what range should work?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Moreover, the graph looks confusing.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I should look at the red spot that indicates a maximum LL .....correct??&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I thought that there will be a trend like what I saw in the blogs, instead, I saw things like this&amp;nbsp; with no trend&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Salah_1-1618864705476.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58335iEACA1B1FFA9BF4CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Salah_1-1618864705476.png" alt="Salah_1-1618864705476.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The last thing I may need help with is why all of the sudden I start to have things written in Chinese in the log file!!!!! I don't recall doing anything I was just trying to play with the range of my parameters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Salah_0-1618864685623.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58334iAED8B80A16E250D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Salah_0-1618864685623.png" alt="Salah_0-1618864685623.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The modified code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc iml;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;n=25; m=15; R=J(m, 1, 0); R[1]=10;&lt;/P&gt;&lt;P&gt;seed=0; k=10;&lt;/P&gt;&lt;P&gt;alpha=1.5; beta=0.8;&lt;/P&gt;&lt;P&gt;********************************************************************************************;&lt;BR /&gt;** progressive censoring ***;&lt;BR /&gt;****************************;&lt;/P&gt;&lt;P&gt;W=J(m,1,0);V=J(m,1,0);X_p=J(m,1,0); X_A=J(m,1,0); U=J(m,1,0);&lt;/P&gt;&lt;P&gt;X=J(m,1,0);&lt;/P&gt;&lt;P&gt;do i=1 to m;&lt;BR /&gt;W[i]=Uniform(seed);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;S=1+R[m];&lt;BR /&gt;V[1]=W[1]**(1/S);&lt;/P&gt;&lt;P&gt;do i=2 to m;&lt;BR /&gt;S=S+(1+R[m-i+1]);&lt;BR /&gt;V[i]=W[i]**(1/S);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;do i=1 to m;&lt;/P&gt;&lt;P&gt;U[i]=1-prod( V[ m:( m-i+1)] );&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;**********************;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Call sort (U);&lt;BR /&gt;&lt;BR /&gt;X_p=( (1-U)##(-1/alpha) -1 )/beta;&lt;/P&gt;&lt;P&gt;call sort (X_p);&lt;/P&gt;&lt;P&gt;T= X_p[m/2];&lt;/P&gt;&lt;P&gt;*T=X_p[4*m/5];&lt;/P&gt;&lt;P&gt;*T=X_p[m]+2;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;do idx=1 to m-1;&lt;BR /&gt;if (( X_p[idx] &amp;lt; T) &amp;amp; (X_p[idx+1] &amp;gt;= T)) then q=idx;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;If X_p[m]&amp;gt;T then&lt;/P&gt;&lt;P&gt;do;&lt;/P&gt;&lt;P&gt;X_1_q=J(q,1,0);&lt;/P&gt;&lt;P&gt;X_1_q= X_p[1:q];&lt;/P&gt;&lt;P&gt;Xp_remaining=J(m-q,m,0); Y=J(m-q,m,0);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Y=X_p[q+1:m];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;**************************************************;&lt;BR /&gt;** Generate data of size m-q **;&lt;BR /&gt;**************************************************;&lt;/P&gt;&lt;P&gt;W1=J(m-q,1,0); YY=J(m-q,1,0);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;call randseed(seed);&lt;BR /&gt;&lt;BR /&gt;call randgen(W1, "Uniform",0,1);&lt;/P&gt;&lt;P&gt;Call sort (W1);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;YY=( (1-W1)##(-1/alpha)#(1+beta*T)-1 )/beta;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;X_A= X_1_q //YY;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;X=X_A;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else if ( X_p[m] &amp;lt;= T) then&lt;/P&gt;&lt;P&gt;do;&lt;BR /&gt;q= m;&lt;BR /&gt;X = X_p;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;/* four-hump camel has two global maxima:&lt;BR /&gt;p1 = {-0.08984201 0.71265640 };&lt;BR /&gt;p2 = { 0.08984201 -0.71265640 }; */&lt;/P&gt;&lt;P&gt;start Camel(KK) global (n,m,X,R,q);&lt;/P&gt;&lt;P&gt;alpha = KK[,1]; beta = KK[,2];&lt;/P&gt;&lt;P&gt;Rq=R[1:q];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sum1=0;&lt;BR /&gt;Do i=1 to m;&lt;BR /&gt;Sum1=sum1+log(1+beta*X[i]);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;Sum2=0;&lt;BR /&gt;Do i=1 to q;&lt;BR /&gt;Sum2=Sum2+R[i]*log(1+beta*X[i]);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;f=m#log(alpha#beta)-(alpha+1)#Sum1-alpha#sum2-alpha#(n-m-Rq[+])#log(1+beta#X[m]);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;return( -f ); /* return -f so that extrema are maxima */&lt;BR /&gt;finish;&lt;BR /&gt;&lt;BR /&gt;KK = ExpandGrid( do(0.1,4,0.05), do(0.1,4,.05) );&lt;BR /&gt;&lt;BR /&gt;f = Camel(KK);&lt;/P&gt;&lt;P&gt;optIndex = loc(f=max(f)); /* find maximum values of z */&lt;BR /&gt;opt_parameter = KK[optIndex,]; /* corresponding (alpha,beta) values */&lt;/P&gt;&lt;P&gt;print opt_parameter;&lt;/P&gt;&lt;P&gt;*print q x kk[c={"alpha" "beta" }] f ;&lt;/P&gt;&lt;P&gt;alpha=Kk[,1]; Beta=Kk[,2];&lt;/P&gt;&lt;P&gt;******************* Graph Likelihood function ****************;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create _Temp var {alpha, beta, f};&lt;BR /&gt;append;&lt;BR /&gt;close _Temp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;submit;&lt;BR /&gt;title "Graph log-Likelihood function";&lt;BR /&gt;proc sgplot data=_Temp;&lt;BR /&gt;scatter x=alpha y=beta / colorresponse=f&lt;BR /&gt;markerattrs=(symbol=CircleFilled size=14); /* big filled markers */&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;endsubmit;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 20:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735355#M5455</guid>
      <dc:creator>Salah</dc:creator>
      <dc:date>2021-04-19T20:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735366#M5458</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am out of the office this week, so the best I can do is remind you that the LL depends on the data. You are using seed=0, so you get a DIFFERENT likelihood function every time you run your function.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use a positive seed value for reproducibility.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When you see a LL function where the red area is on the boundary, it probably means that the maximum is outside of the domain you are using for ExpandGrid. It might even mean that the function is unbounded. It appears that for some of your random data set, the model does not fit the data. These are the 'spikes' where the optimal (alpha,beta) values are much different than for the bulk of the other data sets.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You either need to reexamine how you are generating the data (is your simulation correct?)&amp;nbsp; or you need to generate larger data sets so that the LL function has a well-defined maximum for most data sets.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have no idea why you are getting Chinese characters.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 21:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735366#M5458</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-04-19T21:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735375#M5459</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26900"&gt;@Salah&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The last thing I may need help with is why all of the sudden I start to have things written in Chinese in the log file!!!!! I don't recall doing anything I was just trying to play with the range of my parameters.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26900"&gt;@Salah&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much for bringing this up! I've always been wondering (with low priority, though) how to get rid of the rare, but consistently obtained&amp;nbsp;&lt;EM&gt;German&lt;/EM&gt;&amp;nbsp;messages in my log files, typically from PROC SGPLOT and related procedures. Seeing the Japanese (?) note in your log screenshot I got the idea: &lt;STRONG&gt;Change the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/nlsref/n1n9bwctsthuqbn1xgipyw5xwujl.htm" target="_blank" rel="noopener"&gt;LOCALE= system option&lt;/A&gt; to EN_US.&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options locale=EN_US;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My original setting was DE_DE and yours might be JA_JP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally (after six years) my logs are all English! I'm really happy about this. Thanks again! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 22:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735375#M5459</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-04-19T22:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: debug a subroutine; Call NLPQN</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735499#M5460</link>
      <description>Thank you so much. It works!!!&lt;BR /&gt;I didn't know that PROC SGPLOT caused the shift of the language in the log file!!!&lt;BR /&gt;WOOOW I learn a new thing today. Thanks a lot!!!!&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Apr 2021 12:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/debug-a-subroutine-Call-NLPQN/m-p/735499#M5460</guid>
      <dc:creator>Salah</dc:creator>
      <dc:date>2021-04-20T12:08:17Z</dc:date>
    </item>
  </channel>
</rss>

