<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://gretlwiki.econ.univpm.it/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ekkehart</id>
	<title>GretlWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://gretlwiki.econ.univpm.it/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ekkehart"/>
	<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php/Special:Contributions/Ekkehart"/>
	<updated>2026-05-20T16:55:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.7</generator>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=74</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=74"/>
		<updated>2023-01-11T07:55:31Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: Formatting improved&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful to indicate the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt;  command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File → Script files → New script) and paste the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set verbose off&lt;br /&gt;
# This defines the function to be maximized&lt;br /&gt;
function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&lt;br /&gt;
scalar x = param[1]&lt;br /&gt;
scalar y = param[2]&lt;br /&gt;
printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&lt;br /&gt;
flush                                         # this induces immediate printing&lt;br /&gt;
sleep(.003)                                   # this simulates a time-consuming process&lt;br /&gt;
return -(1-x)^2 - 100 * (y - x^2)^2&lt;br /&gt;
end function&lt;br /&gt;
&lt;br /&gt;
# This invokes the maximization routine&lt;br /&gt;
matrix theta = {0, 0}                         # initial values for theta&lt;br /&gt;
set max_verbose off&lt;br /&gt;
M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&lt;br /&gt;
printf &amp;quot;                      \r&amp;quot;             # destroy the last step message&lt;br /&gt;
flush                                         # flush it&lt;br /&gt;
printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=73</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=73"/>
		<updated>2023-01-11T07:51:27Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: deleted left-over word&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful to indicate the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt;  command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File → Script files → New script) and paste the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set verbose off&lt;br /&gt;
# This defines the function to be maximized&lt;br /&gt;
function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&lt;br /&gt;
scalar x = param[1]&lt;br /&gt;
scalar y = param[2]&lt;br /&gt;
printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&lt;br /&gt;
flush                                         # this induces immediate printing&lt;br /&gt;
sleep(.003)                                   # this simulates a time-consuming process&lt;br /&gt;
return -(1-x)^2 - 100 * (y - x^2)^2&lt;br /&gt;
end function&lt;br /&gt;
&lt;br /&gt;
# This invokes the maximization routine&lt;br /&gt;
matrix theta = {0, 0} # initial values for theta&lt;br /&gt;
set max_verbose off&lt;br /&gt;
M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&lt;br /&gt;
printf &amp;quot;                      \r&amp;quot;              # destroy the last step message&lt;br /&gt;
flush                                          # flush it&lt;br /&gt;
printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=70</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=70"/>
		<updated>2022-12-30T14:57:53Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful to indicate the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt;current  command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File → Script files → New script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;                      \r&amp;quot;              # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                          # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=69</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=69"/>
		<updated>2022-12-30T14:54:52Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful to indicate the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt;current  command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File → Script files → New script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;                      \r&amp;quot;              # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                          # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=68</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=68"/>
		<updated>2022-12-30T14:54:32Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful to indicates the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt;current  command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File → Script files → New script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;                      \r&amp;quot;              # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                          # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=67</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=67"/>
		<updated>2022-12-30T14:53:42Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful that indicates the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File → Script files → New script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;                      \r&amp;quot;              # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                          # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=66</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=66"/>
		<updated>2022-12-30T14:52:53Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful that indicates the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File → Script files → New script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;                      \r&amp;quot;              # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                          # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function. Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=65</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=65"/>
		<updated>2022-12-30T14:50:06Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful that indicates the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File -&amp;gt; Script files -&amp;gt;new script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;                      \r&amp;quot;              # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                          # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function. Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=64</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=64"/>
		<updated>2022-12-30T14:46:26Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: cosmetic&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful that indicates the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File -&amp;gt; Script files -&amp;gt;new script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;                      \r&amp;quot;              # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                          # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=63</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=63"/>
		<updated>2022-12-30T14:43:49Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: minor touch-up&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful that indicates the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command prints the values of x and y and ends with a carriage return. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Open the the gretl script editor (File -&amp;gt; Script files -&amp;gt;new script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot; \r&amp;quot; # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
	<entry>
		<id>https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=62</id>
		<title>Tips and tricks</title>
		<link rel="alternate" type="text/html" href="https://gretlwiki.econ.univpm.it/index.php?title=Tips_and_tricks&amp;diff=62"/>
		<updated>2022-12-30T10:38:24Z</updated>

		<summary type="html">&lt;p&gt;Ekkehart: new page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Step monitor ===&lt;br /&gt;
It is sometimes irritating when a calculation takes very long and nothing appears to happen. In such cases a step monitor may be useful that indicates the state of the calculations. It is a simple gimmick.&lt;br /&gt;
&lt;br /&gt;
Take, as an example, a modification of the Listing 37.1: Finding the minimum of the Rosenbrock function with the BFGSmax routine given in Gretl&#039;s user guide. The &amp;lt;code&amp;gt;printf command&amp;lt;/code&amp;gt; prints the values of x and y. The command &amp;lt;code&amp;gt;flush&amp;lt;/code&amp;gt; induces printing at each step, ending with a carriage return. To simulate a time consuming routine, a delay of .003 has been inserted by giving the command &amp;lt;code&amp;gt;sleep(.003)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Innvoke the gretl script editor (File -&amp;gt; Script files -&amp;gt;new script) and paste the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This defines the function to be maximized&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function scalar Rosenbrock( const matrix param &amp;quot;parameters&amp;quot; )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar x = param[1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scalar y = param[2]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;x =%7.4f, y =%7.4f \r&amp;quot;,x,y            # the information printed at each step&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush                                         # this induces immediate printing&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sleep(.003)                                   # this simulates a time-consuming process&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return -(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;end function&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;# This invokes the maximization routine&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;matrix theta = {0, 0} # initial values for theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;set max_verbose off&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;M = BFGSmax(&amp;amp;theta, Rosenbrock(theta) )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot; \r&amp;quot; # destroy the last step message&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;flush # flush it&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;printf &amp;quot;\ntheta: %8.4f \n&amp;quot;, theta&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the script (push the gears button or Ctrl+R). The successive estimates of x and y will be monitored. Other information can easily be monitored as well, the value of the criterion &amp;lt;code&amp;gt;-(1-x)^2 - 100 * (y - x^2)^2&amp;lt;/code&amp;gt; for instance, by simply including it in the &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; command in the Rosenbrook function.&lt;/div&gt;</summary>
		<author><name>Ekkehart</name></author>
	</entry>
</feed>