Frequently Asked Questions about SHAZAM
This FAQ accompanies the latest version of SHAZAM. Some answers may not apply to earlier versions of SHAZAM. Section 1: Working with it Q1.1: How do I get help? Q1.2: How do I get examples of SHAZAM command files? Q1.3: How do I produce and print graphs? Q1.4: What are the limits on problem size? Section 2: Using Windows SHAZAM Q2.1: Problems with loading a data set in repeated runs. Section 3: Some SHAZAM tricks Q3.1: Getting the minimum of more than 2 variables. Q3.2: Getting the inverse of the NCDF. Q3.3: How to sort with 2 sort variables. Q3.4: How to compute skewness and kurtosis statistics. Q3.5: Problem with READ / LIST FORMAT
Q3.6: Problem with GENR INDEX=INDEX/INDEX(3)
Q3.7: Problem with character strings in DO-loops Q3.8: Last line in data file or command file not read ! Q3.9: Problem with scalar variables in TEST or
RESTRICT commands.
Q3.10: Is there a command to compute factorials (that is, n!) ? Q3.11: How to compute row and column totals of a matrix ? Q3.12: How to include dummy variables in Box-Cox regression Q3.13: How to calculate the normal pdf Q3.14: Problem with divide by zero messages when calculating a matrix Hadamard product Q3.15: How can a coefficient be restricted to the interval ( - 1,0) ?
Q3.16: How can a 12-period moving average by calculated ? Section 4: Numerical problems Q4.1: Why are random numbers different for different SHAZAM versions ? Q4.2: ARIMA estimation results different from other packages. Section 5: Technical Questions Q5.1: For NL , what is the
meaning of GTRANSPOSE*INVERSE(H)*G STATISTIC ?
Q5.2: For the MATRIX command,
what algorithm is used to calculate eigenvalues and eigenvectors ?
Q5.3: What solution method is used for solving nonlinear systems of equations ? Q1.1: How do I get help?
Q1.2: How do I get examples of SHAZAM command files?
Q1.3: How do I produce and print graphs?SHAZAM has an interface to the gnuplot package. The Professional Edition integrates Graph creation, editing and manipulation using menus and dialogs. Because Gnuplot is a command-driven interactive plotting program both the Standard and Professional editions of SHAZAM allow full access to all Gnuplot commands for full customization of your Graphs. Return to TopQ1.4: What are the limits on problem size?SHAZAM sets defaults for memory limits and variable size limits. These can be changed with thePAR and SIZE commands so that there
is no effective limit on problem size.
SHAZAM also sets a default for the command line length. This can be
changed with the SET COMLEN= command.
Return to Top Q2.1: Problems with loading a data set in repeated runs.With Windows SHAZAM Versions 9 and 10 theREAD command
loads the data set starting at the first record of the data file
(that is, the REWIND option is the default).
This ensures that, in a Windows session, the data set will be re-loaded
in repeated runs of a SHAZAM program.
In previous versions of SHAZAM, the READ command
set the NOREWIND option as the default.
If multiple READ commands are used to load data
sequentially from a data file, then the NOREWIND option
must be specified.
Return to Top Q3.1: Getting the minimum of more than 2 variables.Suppose you have variablesX1, X2, X3, X4 and you would
like to obtain the minimum in the variable VARMIN .
You can do this with the SHAZAM command:
GENR VARMIN=MIN(X1,MIN(X2,MIN(X3,X4)))
Return to Top Q3.2: Getting the inverse of the NCDF.To obtain the inverse of the NCDF and save the result in the variable X use the command:GENR P=1-P DISTRIB P / INV TYPE=NORMAL CRIT=XReturn to Top Q3.3: How to sort with 2 sort variables.TheSORT command in SHAZAM implements a fast sort algorithm. You can
sort on two variables by the following method. Suppose your data set
has variables A, B, C and D and the first sort variable is A and the
second sort variable is B. Suppose that B never has values that exceed
1000. Then, the data set can be sorted by constructing a sort variable
as follows:
GENR SORTVAR=A*1000+B SORT SORTVAR A B C DReturn to Top Q3.4: How to compute skewness and kurtosis statistics.Suppose you have a variable X. You can get skewness and kurtosis with the command:OLS X / GF
The GF option is generally intended to produce test statistics on the
estimated residuals of the OLS regression. But when a single variable
is specified you will get summary statistics for this variable.
Note that the computations of skewness and excess kurtosis incorporate
small sample adjustments and so the formula may be slightly different
from formula given in some textbooks.
Return to Top Q3.5 Problem with READ / LIST FORMATThe first character is often interpreted as a carriage control character when output is printed to an output file. If aFORMAT
command is used that does not allow for a blank as the first character
then the data listing may appear with the first character missing.
To avoid this the following method should be used to get a data listing
of data that is read with the READ command.
FORMAT(A8,2F10.2) READ(filename) name var2 var3 / FORMAT FORMAT(1X,A8,2F10.2) PRINT name var2 var3 / FORMATInstead of the LIST option on the READ command the PRINT command is used
following the READ command. The FORMAT command is altered to start with
a blank space.
Return to Top Q3.6 Problem with GENR INDEX=INDEX/INDEX(3)This example comes from Tim Coelli. Suppose that a price index series is available in the variableINDEX and the base year is to be
set at period 3. The following command will give incorrect results.
GENR INDEX=INDEX/INDEX(3)
With the above command SHAZAM does a "dynamic calculation".
SHAZAM computes:
1) INDEX(1) = INDEX(1) / INDEX(3) 2) INDEX(2) = INDEX(2) / INDEX(3) 3) INDEX(3) = INDEX(3) / INDEX(3) = 1 4) INDEX(4) = INDEX(4) / INDEX(3) (BUT INDEX(3) IS NOW 1 !) = INDEX(4) 5) INDEX(5) = INDEX(5) ETC.To keep the calculation "static" the left hand side variable should be a new variable as in the following command: GENR PRICE=INDEX/INDEX(3)
Return to Top Q3.7 Problem with character strings in DO-loopsCharacter string names cannot be referenced with a DO-loop index. This is shown in the next list of SHAZAM commands.
Q3.8: Last line in data file or command file not read !There must be a hard return at the end of a file - otherwise SHAZAM may not recognize the last line. When an excel file is saved as a text file the return character may be placed at the end of the final line. Therefore a text editor must be used to add another return and place the cursor below the final line. Return to TopQ3.9: Problem with scalar variables in TEST or RESTRICT commands.Use theGEN1 command to generate scalar variables for use in TEST or
RESTRICT commands. If the GENR command is used to create constants
then a syntax error may result when this variable is used in a
TEST or RESTRICT command. For example, the following commands can be used:
GEN1 A=-1 OLS CONSUME INCOME PRICE TEST INCOME=A*PRICEReturn to Top Q3.10: Is there a command to compute factorials (that is, n!) ?An example of calculating factorials is available. This should be used with caution since as n increases the value for n! rapidly becomes extremely large. Return to TopQ3.11: How to compute row and column totals of a matrix ?You can use theSTAT command with the
SUMS= option to compute row and
column totals of a matrix. This is shown in the commands below.
Q3.12: How to include dummy variables in Box-Cox regression0-1 dummy variables may not work in Box-Cox regression that is implemented with theBOX command.
The easy solution is to redefine the dummy variables away
from 0-1 to 1-2 or 1-e.
Return to Top Q3.13: How to calculate the normal pdfThe probability density function for a standard normal random variable is: The followingGENR command can be used:
GENR PDF=EXP(-X**2/2)/SQRT(2*$PI)
To make the order of priority clear, an alternative command is:
GENR PDF2=EXP(-(X**2)/2)/SQRT(2*$PI)
To avoid programming errors when using the GENR
command the recommended method for calculating the normal pdf is
to use the DISTRIB command. The
PDF= option is used to save the pdf in the variable
specified. This is shown as follows.
SET NOOUTPUT DISTRIB X / TYPE=NORMAL PDF=NPDFReturn to Top Q3.14: Problem with divide by zero messages when calculating a matrix Hadamard productBefore theMATRIX command add the following commands:
SET MISSVALU=0 SET NOWARN NOWARNMISSAn example is shown below.
Q3.15: How can a coefficient be restricted to the interval (-1,0) ?With nonlinear least squares, a logit transformation can be used to force a coefficient to be in the (0,1) interval. That is, the coefficient can be expressed as: 1 / (1 + exp(b)) This is shown in the example below. A linear regression equation is considered. The coefficient on the price variable is restricted to be negative and between -1 and 0.
Q3.16: How can a 12-period moving average by calculated ?TheSMOOTH command in SHAZAM can generate
moving averages. An example is below.
DO -loop for obtaining
a moving average.
Q4.1: Why are random numbers different for different SHAZAM versions ?Different compilers may be used to make different SHAZAM versions for various operating systems and therefore, the random numbers generated by SHAZAM will be different. To guarantee the same random numbers in a repeat run of an installed version of SHAZAM, use the commandSET RANFIX at the start of the
SHAZAM command file.
Alternatively, to ensure the same random numbers in various
runs of SHAZAM, first save a set of random numbers to a data file
and then load the random numbers from the file with a
READ command.
Return to Top Q4.2: ARIMA estimation results different from other packages.The estimation of ARIMA models requires nonlinear algorithms and so there may be numerical differences in results reported by SHAZAM and other packages. The following differences should be noted when comparing results from SHAZAM and RATS.Algorithm Differences
Reporting Differences
Q5.1: For NL, what is the meaning of GTRANSPOSE*INVERSE(H)*G STATISTIC ?This statistic has 2 purposes:
Q5.2: For the
A
description of the algorithm
is available.
Return to Top |
SAMPLE 1 1 * Define the system of 2 equations FX1: X1**2 + 3*X1*X2 - 22 FX2: X2**2 + 2*X1*X2 - 21 * Solve the 2 equations NL 2 / NCOEF=2 SOLVE EQ [FX1] EQ [FX2] COEF X1 1 X2 1 END * Repeat using the MINFUNC option NL 1 / NCOEF=2 MINFUNC EQ ([FX1])**2 + ([FX2])**2 COEF X1 1 X2 1 END STOP |