Saving script objects

When you estimate a model using point-and-click, the model results are displayed in a separate window, offering menus which let you perform tests, draw graphs, save data from the model, and so on. Ordinarily, when you estimate a model using a script you just get a non-interactive printout of the results. You can, however, arrange for models estimated in a script to be "captured", so that you can examine them interactively when the script is finished. Here is an example of the syntax for achieving this effect:


      Model1 <- ols Ct 0 Yt

That is, you type a name for the model to be saved under, then a back-pointing "assignment arrow", then the model command. You may use names that have embedded spaces if you like, but such names must always be wrapped in double quotes:


      "Model 1" <- ols Ct 0 Yt

Models saved in this way will appear as icons in the gretl session window (see the Section called The "session" concept) after the script is executed. In addition, you can arrange to have a named model displayed (in its own window) automatically as follows:


      Model1.show

Again, if the name contains spaces it must be quoted:


      "Model 1".show

The same facility can be used for graphs. For example the following will create a plot of Ct against Yt, save it under the name "CrossPlot" (it will appear under this name in the session icon window), and have it displayed:


      CrossPlot <- gnuplot Ct Yt
      CrossPlot.show

You can also save the output from selected commands as named pieces of text (again, these will appear in the session icon window, from where you can open them later). For example this command sends the output from an augmented Dickey–Fuller test to a "text object" named ADF1 and displays it in a window:


      ADF1 <- adf 2 x1
      ADF1.show

Objects saved in this way (whether models, graphs or pieces of text output) can be destroyed using the command .free appended to the name of the object, as in ADF1.free.