4.3 Using built-in functions in Micro…t
4.3.1 Function ABS
Absolute value function. For example,
Y = 2 + 3 ABS(X)
4.3.2 Function COS
The cosine function. Example:
Y = 2 + 3:5 COS(5 + 2 X)
4.3.3 Function CPHI
This is the cumulative standard normal function so that CPHI(X) represents the integral between minus in…nity to X of the standard normal distribution. For examples,
Y = CPHI(0:0) returns the value of 0.5 for Y,
Y = CPHI(W + 2 (Z1=Z2))
…rst computes the expression inside the brackets, and then returns the values of the integral of the standard normal distribution from minus in…nity to W + 2 (Z1=Z2).
4.3.4 Function CSUM
This function, when applied to a variable X, calculates the cumulative sum of X. For example, if X = (6; 2; 1; 3; 1), then typing the formula
Y = CSUM(X)
will result in Y = (6; 8; 7; 10; 11):
The argument X can itself be a function of other variables as in the following example: Y = CSUM((z (SUM(z)=SUM(1))2)
Here SUM( ) is the function SUM described below. See Section 4.3.29.
Warning: Before using this command you need to make sure that there are no missing values in the variable X.
4.3.5 Function EXP
This function takes the exponential of the expression that follows in the brackets. For example,
Y = 2 + 3:4 EXP(1:5 + 4:4 X) The general form of EXP( ) is given by
EXP(x) = 1 + x + x2=2! + x3=3! + ::::
Demo Version
For an academic or a commercial version
contact Oxford University Press
4.3.6 Function GDL
This is the geometric distributed lag function and has the form
Y = GDL(X; )
It computes Y as
SIM Y = Y ( 1) + X
over the sample in which it is in e¤ect. is the parameter of the distributed lag function, and SIM is the SIM command (see Section 4.4.25). The initial value is set equal to the value of X at the start of the selected sample period. For example, suppose you wish to compute geometric distributed lag of X over the period 1950-1980, with = 0:8, you need to type
SAMPLE 1950 1980; Y = GDL(X; 0:8) The value of Y in 1950 will be set equal to the value of X in 1950.
Warning: Before using this command you need to make sure that there are no missing values in the variable X.
4.3.7 Function HPF
This function has the form
Y = HPF(X; )
and runs the variable X through a Hodrick-Prescott (HP) …lter using the parameter . In this function X is a vector, and is a non-negative scalar (a vector with all its elements equal to 0). This …lter is used extensively in the real business cycle literature as a de-trending procedure (see Hodrick and Prescott 1997)
The choice of depends on the frequency of the time series, X. For quarterly observations Hodrick and Prescott set = 1; 600. The argument X could also be speci…ed to be a function of other variables in the variable list. Harvey and Jaeger (1993)show that for = 1; 600 the transfer function for the HP …lter peaks around 30:14 quarters (approximately 7.5 years). This suggests using the value of = 7 for annual observations, and = 126; 400 for monthly observations.1 But, in general, the optimal choice of will depend on the particular time series under consideration.
For example, suppose U SGN P contains quarterly observations on US aggregate output. The trend series (in logarithms) are given by
Y T = HPF(LOG(U SGN P ); 1600)
To compute the …ltered, or de-trended, series you need to type
Y D = LOG(U SGN P ) Y T
1
We are grateful to Micheal Binder for the estimates of in the case of annual and monthly observations.
Demo Version
For an academic or a commercial version
contact Oxford University Press
4.3.8 Function INVNORM
This function computes the inverse of the cumulative standard normal distribution, so that for a given probability p, Y =INVNORM(p) computes Y such that the area under the standard normal curve between minus in…nity to Y is equal to p:
Y = INVNORM(0:975)
In this example, Y will be set to 1:9600, the 95 per cent critical value of the standard normal distribution. Note that 0 < p < 1.
4.3.9 Function LOG
The function takes logarithm to the base e (natural logarithm) of the expression that follows in brackets. For example
Y = 2:4 + 3:5 LOG(X + 3)
For negative or zero values of X, this function returns missing values.
4.3.10 Function MAX
This function has the form
Y = MAX(X; Z)
and places the maximum of X and Z in Y . For example, if X = (1; 7; 2; 3; 6) and Z = (6; 2; 1; 3; 1), then Y will be set to (6; 7; 2; 3; 6).
4.3.11 Function MAV
This function has the form
Y = MAV(X; p)
and places the pth order moving-average of the variable X in Y , namely
Yt=
1
p(Xt+ Xt 1+ ::: + Xt p+1)
Variable X could be any of the variables on the workspace or a function of them. If p is not an integer Micro…t chooses the nearest integer to p in order to carry out its computations. If p is negative this function returns a missing value (a blank …eld).
4.3.12 Function MEAN
This function, when applied to a variable X, calculates the mean of X over the speci…ed sample period. For example,
SAMPLE1970 1995; Y = (X MEAN(X))
Demo Version
For an academic or a commercial version
contact Oxford University Press
generates deviations of variable X from its mean computed over the sample period 1970-1995, inclusive.
Note that the value of MEAN(X) will be set to missing if one or more values of X are missing over the speci…ed sample period.
4.3.13 Function MIN
This function has the form
Y = MIN(X; Z)
and places the minimum of X and Z in Y . The arguments X and Z themselves could be functions of other variables, as in the following example:
y = MIN((G1=G2) + 1; (H1=H2) 1)
4.3.14 Function NORMAL
This function can be used to generate independent standardized normal variates (i.e. with zero means and unit variances). The function should be used in the form of NORMAL(j) within a formula, where j represents the ‘seed’ for the quasi-random numbers generated, and it must be an integer in the range 0 < j < 32000. By changing the value of j, di¤erent quasi-random number series can be generated. Examples of the use of this function are:
X = NORMAL(1); Y = 2 + 3:5 NORMAL(124) + Z
Warning: The function UNIFORM and NORMAL must not be used in SIM or SIMBcommands!
4.3.15 Function ORDER
This function has the form
Y = ORDER(X; Z)
and orders X according to the sorting implied by Z, where Z is sorted in an ascending order. The results is placed in Y . For example, if X = (1; 7; 2; 3; 6) and Z = (6; 2; 1; 3; 1), then Y will be set to (2; 6; 7; 3; 1).
Clearly, as in the case of other functions, the arguments of the function, namely X and Z, could themselves be functions of other variables.
4.3.16 Function PHI
This function gives the ordinates of the standard normal distribution for the expression that follows in brackets. For example,
Y = 0:5 (1=PHI(0)) ^2
Demo Version
For an academic or a commercial version
contact Oxford University Press
Y = PHI(1)
Z = PHI(1 + 0:5 W ) The general formula for the P HI function is given by
PHI(X) = ((2 )^( 0:5)) EXP( 0:5 X^2)
where EXP is the exponential function (see Section 4.3.5), and =3.14159.
4.3.17 Function PTTEST
This function has the form
T = PTTEST(Y; X)
and returns the Pesaran and Timmermann (1992) statistic for a non-parametric test of association between the variables Y and X. Under the null hypothesis that X and Y are distributed independently, PTTEST(X; Y ) has a standard normal distribution in large samples. For example, for a two-sided test, the hypothesis that Y and X are statistically independent will be rejected if PTTEST is larger than 1.96 in absolute value.
4.3.18 Function RANK
This function, when applied to a variable X, gives the ranks associated with the elements of X, when X is sorted in an ascending order. For example, if X = (6; 2; 1; 3; 1) then typing the formula
Y = RANK(X)
will give Y = (5; 3; 1; 4; 2).
4.3.19 Function RATE
This function has the form
P IZ = RATE(Z)
It computes the percentage rate of change of Z and places the result in P IZ. More speci…- cally, P IZ will be computed as
P IZ = 100 (Z Z( 1))=Z( 1)
with its initial value set to blank.
An alternative approximate method of computing rate of change in a variable would be to use changes in logarithms, namely
P IZX = 100 (LOG(Z=Z( 1))
Demo Version
For an academic or a commercial version
contact Oxford University Press
It is easily seen that both approximations are reasonably close to one another for values of P IZ and P IZX around 20 per cent or less.
The argument of this function, namely Z, can itself be a function of other variables, as in the following example
Y = RATE(W + U=V )
4.3.20 Function REC_MAX
This function, when applied to a variable X, returns for each observation j the maximum value of X over the interval that goes from the start of the sample to the jth observation. For example, if X = (2; 1; 3; 0; 4), then typing
Y = REC_MAX(X)
will return Y = (2; 2; 3; 3; 4).
Warning: Before using this command you need to make sure that there are no missing values in the variable X.
4.3.21 Function REC_MIN
This function, applied to a variable X, returns for each observation j the minimum value of X over the interval from the start of the sample to the jth observation. If, for example, X = (2; 1; 3; 0; 4), then typing
Y = REC_MIN(X)
will set Y = (2; 1; 1; 0; 0).
Warning: Before using this command you need to make sure that there are no missing values in the variable X.
4.3.22 Function ROLL_MAX
This function has the form
Y = ROLL_MAX(X; h)
where h is the window length. It returns the maximum value of X over successive rolling periods of a …xed length. For each observation j, this function computes the maximum value of X over the interval that goes from the (j h)th to the jth observation. The …rst h 1 observations are set to missing. If for example X = (2; 1; 3; 0; 4; 3), then
Y = ROLL_MAX(X; 2)
will set Y = ( ; 2; 3; 3; 4; 4).
Warning: Before using this command you need to make sure that there are no missing values in the variable X.
Demo Version
For an academic or a commercial version
contact Oxford University Press
4.3.23 Function ROLL_MIN
This function takes the form
Y = ROLL_MIN(X; h)
It returns, for each observation j, the minimum value of X over the sample from the (j h)th to the jth observation, with the …rst h 1 observations set to missing. If, for example, X = (2; 1; 3; 0; 4; 3), then
Y = ROLL_MIN(X; 2) will set Y = ( ; 1; 1; 0; 0; 3).
Warning: Before using this command you need to make sure that there are no missing values in the variable X.
4.3.24 Function SIGN
This function, when applied to a variable X, returns the value of 1 when X is positive and 0 when X is zero or negative. For example, if X = (3; 4; 2; 0; 1:5), then typing
Y = SIGN(X) will return Y = (1; 0; 1; 0; 1). Another example is
Y = SIGN(X 2)
which will return Y = (1; 0; 0; 0; 0):
4.3.25 Function SIN
This function takes sine of the expression that follows in the brackets. For example, Y = 2 + 3 SIN(5 + 7 X)
4.3.26 Function SORT
This function, when applied to a variable X, will sort X in an ascending order. For example, if X = (6; 2; 1; 3; 1) then typing
Y = SORT(X) will set Y = ( 1; 1; 2; 3; 6), while
Z = SORT( X)
will sort X in descending order in Z so that Z = (6; 3; 2; 1; 1): In the example
Y = SORT(2 + w=z)
the expression 2 + w=z will be …rst computed, and the resultant expression will be sorted in Y as above.
Demo Version
For an academic or a commercial version
contact Oxford University Press
4.3.27 Function SQRT
This function takes the square-root of the expression that follows in brackets. For example:
Y = 3 + 5 SQRT(X)
For negative values of X, this function returns the missing values.
4.3.28 Function STD
This function, when applied to a variable X, calculates the standard deviation of X over the speci…ed sample period. For example,
SAMPLE1970 1995;
Z = (X MEAN(X))=STD(X)
places the standardized values of X over the period 1970-1995 (inclusive) in the variable Z. Warning: The value of STD(X) will be set to missing (blank) if one or more values of X are missing over the speci…ed sample period.
4.3.29 Function SUM
This function …rst calculates the expression speci…ed within closed brackets immediately following it, and then computes the sum of the elements of the result over the relevant sample period. Examples of the use of this function are:
SAMPLE 1960 1970; XBAR = SUM(X)=SUM(1);
XD = X XBAR; Y BAR = SUM(Y )=SUM(1); Y D = Y Y BAR; BY X = SUM(XD Y D)=SUM(XD XD)
In the above examples, SUM(X) is a vector with all its elements equal to the sum of the elements of X over the period 1960-70. SUM(1) is equal to the number of observations in the sample period (namely, 11). XBAR is, therefore, equal to the arithmetic mean of X, computed over the speci…ed sample period. XD and Y D are deviations of X and Y from their respective means and BY X is the ordinary least squares (OLS) estimates of the coe¢ cients of X in the regression of Y on X (including an intercept term).
4.3.30 Function UNIFORM
This function can be used to generate independent random numbers from a uniform distrib- ution within the range 0 and 1. The function should be used in the form of UNIFORM(j) within a formula, where j represents the ‘seed’ for the quasi-random numbers generated, and must be an integer in the range 0 < j < 32000. By changing the value of j, di¤erent quasi-random number series can be generated.
Examples of the use of this function are:
Demo Version
For an academic or a commercial version
contact Oxford University Press
X = UNIFORM(1)
Y = 2 + 3:5 UNIFORM(124) + Z
Warning: The functions UNIFORM and NORMAL must not be used in SIM or SIMBcommands!