Commands and macros
How can I easily save and run commands?
Example question: Is there an easier way to save and run a set of commands than copying into a text document and pasting one by one into the Command interface?
Yes, if you have a particular sequence of commands you want to run again, then perhaps the easiest thing is to put them in a macro. From the File menu, select New Macro. In the window that appears you can type your commands. Nothing will happen until you press the Execute button at the bottom. When you press the button, all the commands will be carried out. Most commands can be put into a macro in exactly the same way as you enter them in the Command interface window (there are a few exceptions). The macro can be saved at any time by selecting Save Macro or Save Macro as from the File menu (while the macro window is the active window). It is also possible to have open several macros at once.
For more information on macros, see pp 82-84 of the Command Manual.
When I work with MLwiN using the various windows, is there any way to record the commands that will do the same thing?
Example question: Is there any way I can capture from the Equations window what I am setting up directly into a macro? The re-modelling in the Equations window is time consuming, and if I could obtain this in a macro, I could simply edit some of the macro commands.
Yes, you can. The easiest way to do this is to open the Command interface window (Data Manipulation Command interface) and deselect the User check box at the top. Now when you set up or make changes to your model in the Equations window the corresponding commands will appear in the Command interface window. Note that the corresponding commands will also appear when you use any other window: this does not only apply to the Equations window. Make sure you have the MLwiN command manual handy for interpreting the syntax: MLwiN will sometimes also issue some commands that you don't need and this can cause problems ( see here for an example of how to pick out the commands you want). The Command manual has not been updated recently however, so see also the Manual supplement for version 2.10 which documents commands for the new features in version 2.10 and also in section 8.4 includes some commands which work with version 2.02 as well as version 2.10 (note that not all the commands in this section work with version 2.02; if you are using version 2.02 you will need to experiment to see which work with this version). See also the MCMC manual, which includes some examples of writing and using macros which provide useful tips that apply in a more general context than just MCMC estimation.
I copied commands generated by MLwiN when I was using the GUI and pasted them into a macro, but when I ran the macro I got an error message
To see output in the Output window, you need to turn echoing on. This can be done by putting the line 'echo 1' at the top of your macro, or by typing 'echo 1' in the Command interface window before you start running macros (it only needs to be typed once per session, but it doesn't matter if you type it more times or if it is produced by a macro every time it is run). Note that the 'print' command will not do anything unless echoing is on.
Yes, you can simply run the old macros under the new window system. However, MLwiN has modified some commands from MLn and included several new commands. Some toggle commands in MLn now have a parameter option to specify the exact mode, such as EXPL which is now EXPL 1 (or 0), START which is now START 1 (or 0), LOGO which is now LOGO 1 (or 0), etc. Therefore if an error message occurs in MLwiN when running a MLn macro, check the online help of MLwiN by looking for the Command **** (the command name) on which the error occurred to find the correct syntax. See also missing data web site
A number of new commands were introduced between versions 1.2 and 2.02, but unfortunately we do not have a list of exactly which ones these were. (Also a small number of commands do not work in exactly the same way in newer compared to older versions: for example some commands, e.g. EXPL, require a 1 after them in newer versions but not older versions). The majority of commands, however, should be identical in 1.2 and 2.02. Please also note that in version 1.2 the default number of worksheet columns was lower and therefore the model estimates are not stored in c1090 to c1100 as in version 2.02 but in earlier columns.
(See also the FAQ When I work with MLwiN using the various windows, is there any way to record the commands that will do the same thing?)
Yes, it certainly is. You have two possibilities: you can call MLwiN itself (in which case the GUI window will pop up), or you can use mlnscript, which will run an MLwiN macro for you without opening the GUI and send output to the terminal window that you called it from. Details of how to do this in Windows can be found in the Manual Supplement (Section 8.5); mlnscript is not mentioned but works in the same way as calling MLwiN except that you replace mlwin by mlnscript. Note that (i) if MLwiN is not in your PATH you will need to include the full path to the MLwiN or mlnscript executable (ii) the "<worksheet name>" is optional and so you will probably want to omit it if you are running a macro that opens a worksheet or simulates data. An example command line for running a macro named "mcmcrun.txt", stored in the root of your "M:" drive would be:
"C:\Program Files (x86)\MLwiN v2.35\i386\mlwin" /run "M:\mcmcrun.txt"
Details for installing MLwiN on Linux or Mac OS X are provided on this page: http://www.bristol.ac.uk/cmm/software/mlwin/features/sysreq.html#unix. However, if you only want to use mlnscript and not MLwiN, then you don’t need Wine; you just need the version of mlnscript native to your OS (which can be requested from http://www.cmm.bris.ac.uk/clients/softwaredownload/) and this can then be run in exactly the same way as on Windows (e.g. mlnscript --run mcmcrun.txt, provided that mlnscript is executable and on your path; if it’s not on your path then replace mlnscript by the full path to mlnscript)
- How can I specify a binomial response model using a macro?
- What is the command for specifying the denominator when fitting a binomial or multinomial model?
- Running MCMC from a macro doesn't appear to work
- Where are the time series macros?
- I can't get the LOGOn command to work
- I get an error message asking me to 'generate unique ID codes'. How do I do this?