Full Listing |
%( expression1, expression2, ... ) — Expression evaluation function
Used to group sub-calculations in situations where a comma would be interpreted as an argument separator. For instance, in
%if( x>=0, %(y=sqrt(x),x), y=%na)
if X is non-negative, this returns X while setting Y to the square root of X. If X is negative, this returns a missing value while also setting Y to the missing value. %(expr1,expr2,…,exprn) returns the value of the final expression in the group.
Argument type: |
Most expressions. Separate multiple expressions with commas |
Returns type: |
The type returned by the final expression in the argument list |
abs(x),%abs(A) — Absolute value of a scalar or matrix
For a scalar argument, ABS returns the absolute value of the scalar. For matrix argument A, %ABS returns a matrix with the absolute values of the corresponding elements of A.
Argument type: |
Real for ABS, array of reals for %ABS |
Returns type: |
Matches the argument |
%acos(x) — Arc (inverse) cosine
Returns the inverse cosine of its argument.
Argument type: |
Real (must have \(\left| x \right| \le 1\), or returns missing value) |
Returns type: |
Real between 0 and \(\pi\) |
%allocend() — Default series workspace length
This returns the length of the default workspace length, which is usually set using the ALLOCATE or first DATA instruction.
Argument type: |
None |
Returns type: |
Integer |
%annuity(p,r,n) — Present value of an annuity
Returns the present value of an annuity with payment p, interest rate r, and term n.
Argument types: |
Real |
Returns type: |
Real |
%arg(z) — Argument of a complex number
Returns the argument of a complex number. This is \({\tan ^{ - 1}}\left( {a/b} \right)\) for \(z = a + ib\)
Argument type: |
Complex |
Returns type: |
Real |
Returns the inverse sine of its argument
Argument type: |
Real (must have \(\left| x \right| \le 1\), or returns missing value) |
Returns type: |
Real between \(-\pi/2\) and \(\pi/2\) |
%atan(x) — Arc (inverse) tangent
Returns the inverse tangent of its argument
Argument type: |
Real |
Returns type: |
Real between \(-\pi/2\) and \(\pi/2\) |
%avg(A) — Average of matrix elements
Returns the average of the elements of A. If A is symmetric, off-diagonal elements are counted only once.
Argument type: |
Real-valued array |
Returns type: |
Real |
%besselj(n,x) — Bessel function
Returns the Bessel function of the first kind, for x given order n.
Argument types: |
n is integer, x is real |
Returns type: |
Real |
%bestrep(A,w) — “Best” representation
Returns a string giving a “picture” code (for use in DISPLAY, PRINT and other output instructions) which “best” represents the values in the array A using w positions. In general, this will use all w positions. %MINIMALREP is similar but cuts the number of decimal places if they would be zeros for all numbers.
Argument types: |
A is a real-valued array, w is an integer |
Returns type: |
String |
%betainc(x,a,b) — Incomplete beta function
Returns the incomplete beta function of x given parameters a and b.
Argument types: |
Real, \(0 \le x \le 1,{\text{ }}a > 0,{\text{ }}b > 0\) |
Returns type: |
Real |
%bicdf(X,Y,rho) — Cumulative density function of bivariate standard Normal
Returns \(P(x<X,y<Y)\) for a bivariate standard Normal with correlation coefficient rho.
Argument types: |
Real |
Returns type: |
Real |
%bin(x,V) — Determine appropriate “bin” for a value
This returns an integer indicating which “bin” the value x would fall in given a vector V of boundary values defining the bins. For example,
%bin(2.5,||1.0,2.0,3.0,4.0||)
returns integer value 2, as the value 2.5 is in the range (2.0 to 3.0) for the second bin.
Argument types: |
x is real, V is a VECTOR |
Returns type: |
integer |
%binomial(n,k) — Binomial coefficient
Returns the binomial coefficient \(n(n - 1) \ldots (n - k + 1)/k!\) or its generalization to non-integers \(\frac{{\Gamma (n + 1)}}{{\Gamma (k + 1)\Gamma (n - k + 1)}}\).
Argument types: |
Real. If \(k > n\), \(n-k+1\) cannot be an integer, or the result is a missing value. |
Returns type: |
Real |
%binomialcdf(k,n,p) — Cumulative Binomial Distribution
Returns the cumulative distribution of a binomial (number of successes \(\le k\) given \(n\) trials with probability \(p\)).
Argument types: |
Non-negative integers (\(k\) and \(n\)), real \(p\) in [0,1]. |
Returns type: |
Real |
%binomialk(k,n,p) — Binomial Distribution Function
Returns the probability function for a binomial (number of successes equal to \(k\) given \(n\) trials with probability \(p\).
Argument types: |
Non-negative integers (\(k\) and \(n\)), real \(p\) in [0,1]. |
Returns type: |
Real |
%block(m,n) — Get Number of Blocks
Gives number of blocks (starting with one) when partitioning m integers into blocks of size n. For example, %block(10,5)=2, %block(11,5)=3.
Argument types: |
Integers |
Returns type: |
Integer |
%blockdiag(VR) — Create a block diagonal matrix
Returns a matrix formed by placing the elements of VR (a VECTOR of RECTANGULAR arrays) in blocks down the diagonal, with all other elements of the created matrix set to zero. Note that the matrices in VR do not have to be square. The ~\ operator (diagonal concatenation) is usually easier to use.
Argument type: |
VECTOR of RECTANGULAR |
Returns type: |
RECTANGULAR |
%blockglue(G) — Matrix concatenation
The argument is an array of RECTANGULARS. %blockglue() concatenates these in both dimensions to form a single large matrix. The ~ and ~~ operators (horizontal and vertical concatenation) are usually easier to use.
Argument type: |
Array of RECTANGULAR |
Returns type: |
RECTANGULAR |
%blocksplit(A,IX) — Matrix partitioning
Returns a RECTANGULAR of RECTANGULARs formed by splitting the input array into blocks with dimensions given by the elements of the index array IX.
Argument types: |
A is a real-valued array, IX is a VECT[INTEGER] |
Returns type: |
RECT[RECT] |
%boxcox(x,y) — Box‑Cox transformation
Returns the Box-Cox transformation of x and y, which is given by the formula: \(({x^y} - 1)/y\), or log x for y=0.
Argument types: |
Reals |
Returns type: |
Real |
%bqfactor(S,L) — Blanchard-Quah factorization
Returns the Blanchard-Quah factorization of S (covariance matrix of residuals) with L as the matrix of sums of lag coefficients. The factorization is computed as:
\(L{\left( {{L^{ - 1}}S{{L'}^{ - 1}}} \right)^{1/2}}\)
where the matrix square root is the Cholesky factorization. Note that after doing an ESTIMATE, S is available as the reserved variable %SIGMA, and L is available as %VARLAGSUMS. The function %MODELLAGSUMS can compute it for a model that has been modified.
Argument types: |
S is SYMMETRIC, L is RECTANGULAR |
Returns type: |
RECTANGULAR |
%cabs(z) — Complex absolute value
Returns the absolute value of a complex number z. The result is real.
Argument type: |
Complex |
Returns type: |
Real |
%cal(year,period) — Entry number of specified date
Returns the entry number corresponding to the specified period of the year, given the current CALENDAR setting. It is equivalent to the expression year:period. For frequencies such as daily and weekly that are not specified in periods per year, %cal(year,period) returns the entry for that “period” (day or week) of the year.
Argument types: |
Integer |
Returns type: |
Integer |
%calendar() — Save current CALENDAR setting
Returns the current CALENDAR setting, which can be saved into a variable. That variable can be used with the RECALL option on CALENDAR to reset the CALENDAR.
Argument types: |
None |
Returns type: |
VECT[INTEGER] (coded) |
%cdf(x) — Cumulative density function of standard Normal
Returns \(\Phi (x)\), where \(\Phi \) is the CDF of the standard Normal.
Argument type: |
Real |
Returns type: |
Real |
%cexp(z) — Complex exp function
Returns complex \({e^z}\).
Argument type: |
Complex |
Returns type: |
Complex |
%checkname(name) — Check for name already defined
Returns 1 if the name (as a STRING) is already in the symbol table, and 0 if it isn't. Added with version 9.1.
Argument type: |
STRING variable or literal ("....") |
Returns type: |
INTEGER |
%chisqr(x,r) — Chi-squared tail probability
Returns the tail probability of a \({\chi ^2}\) with r degrees of freedom, that is, the probability that a \({\chi ^2}\) random variable with r degrees of freedom exceeds x.
Argument types: |
Real. x must be non-negative, r must be positive |
Returns type: |
Real |
%chisqrdensity(x,r) — Chi-squared density
Returns the density at x of a \({\chi ^2}\) with r degrees of freedom
Argument types: |
Real. x must be non-negative, r must be positive |
Returns type: |
Real |
%chisqrnc(x,r,nc) — Non-central chi-squared CDF
Returns the CDF at x of a \({\chi ^2}\) with r degrees of freedom for a non-central chi-square, with non-centrality nc. Note that this is the CDF, not the tail probability.
Argument types: |
Real. x must be non-negative, r must be positive |
Returns type: |
Real |
%chisqrncdensity(x,r,nc) — Non-central chi-squared density
Returns the density at x of a non-central \({\chi ^2}\) with r degrees of freedom and noncentrality nc.
Argument types: |
Real. x must be non-negative, r must be positive |
Returns type: |
Real |
%choice(label) — Map Label to Option Choice
Allows you to specify an argument for a “choice” option on a built-in instruction by supplying the appropriate text label as the argument on %CHOICE. For example, you can select the BFGS estimation method on any applicable instruction by using METHOD=%CHOICE("BFGS"). Useful in PROCEDUREs.
Argument types: |
Label (must match a “choice” exactly) |
Returns type: |
Integer (but can only be used as the argument for a choice option) |
%chol(S) — Cholesky decomposition
Returns the Cholesky decomposition of a SYMMETRIC matrix. For a matrix S, this returns a lower-triangular RECTANGULAR array F, such that \({\bf{FF'}} = {\bf{S}}\). S must be positive semi-definite. See also the %PSDFACTOR function. This is a synonym for %DECOMP, and was added with 10.0, as a clearer name for the calculation.
Argument type: |
SYMMETRIC |
Returns type: |
RECTANGULAR |
%clock(m,n) — Modified modular division
Does a modified form of modular division, returning [(m–1) modulo n] + 1. Maps to 1,...,n.
Argument types: |
Integer |
Returns type: |
Integer |
%clog(z) — Complex natural log
Returns complex \({\log _e}z\).
Argument type: |
Complex |
Returns type: |
Complex |
%closestdate(y,m,d,dow) — Observance date (closest day of week)
Returns the number of the day within a month that is the closest occurrence of the specified day of the week (dow) to the date specified by y,m,d. For example, Martin Luther King Day is observed in the U.S. on the Monday closest to January 20th. Days of the week are handled as Monday=1 through Sunday=7, so:
compute day = %closestdate(2007,1,20,1)
returns 22, indicating the closest Monday occurs on 2007:1:22.
Argument types: |
Integer |
Returns type: |
Integer |
%closestweekday(y,m,d) — Observance date (closest Monday–Friday)
Returns the day number within the month of the weekday closest to the date specified by y,m,d. For example:
?%closestweekday(2004,7,4)
displays 5, because the closest weekday to that 4 July 2004 was July 5 (a Monday).
Argument types: |
Integer |
Returns type: |
Integer |
%cm(x) — Convert centimeters to inches
Returns the number of inches in x centimeters. Absolute sizes for graphs are provided in inches, so, for instance, a height=%cm(12.0) option will allow you to set the height to be 12 cm.
Argument type: |
Real |
Returns type: |
Real |
%cmplx(real,imag) — Complex number from real and imaginary parts
Converts two real numbers into a complex number. The first argument is the real part and the second is the imaginary part.
Argument type: |
Real |
Returns type: |
Complex |
%cols(A) — Number of columns of a matrix
Returns the number of columns in a matrix. Returns the value 1 for arrays of type VECTOR (use %rows(A) or %size(A) to get the dimension of a VECTOR)
Argument type: |
Any matrix type |
Returns type: |
Integer |
%compress(A,v) — Compress empty rows out of an array
Returns an array with the same number of columns as A, but with all rows removed for which the corresponding element of the vector v is zero. A and v must have the same number of rows.
Argument type: |
A is Rectangular or Symmetric array, v is a Vector |
Returns type: |
Same as A |
%concat(first,last) — Concatenate two labels
Concatenates two label variables. This can also be done as first+last.
Argument type: |
Labels |
Returns type: |
Labels |
Returns the complex conjugate of z.
Argument type: |
Complex |
Returns type: |
Complex |
%const(x) — Fill matrix with a constant value
In an expression A = %const(x), fills all elements of the array A with the value x. See also %FILL,%ZEROS and %ONES.
Argument type: |
Real |
Returns type: |
Matrix of reals (must be declared and dimensioned ahead of time) |
%corr(A,B) — Correlation coefficient
Computes the correlation coefficient of the two arrays.
Argument type: |
Real arrays, must have same dimensions (\(N \times 1\) and \(1 \times N\)) are considered equivalent) |
Returns type: |
Real |
%corrtocv(C,V) — Convert correlation matrix to covariance matrix
Converts a correlation matrix (C) and a vector of variances (V) into a covariance matrix.
Argument type: |
C is SYMMETRIC, V is a VECTOR with the dimension the same as C. C can also be one element smaller than V in each direction, with 1's on the diagonal assumed. |
Returns type: |
SYMMETRIC |
Returns the cosine of x, where x is in radians. If x is a matrix, transforms all elements.
Argument type: |
Real, or real-valued matrix. |
Returns type: |
Same as argument |
Returns the hyperbolic cosine of its argument \(\frac{{\exp (z) + \exp ( - z)}}{2}\)
Argument type: |
Real |
Returns type: |
Real |
Returns the cotangent of x.
Argument type: |
Real |
Returns type: |
Real |
%cov(A,B) — Covariance of two arrays
Returns the covariance of two arrays: \(\frac{1}{{NM}}\sum\limits_{ij} {\left( {{{\bf{A}}_{ij}} - {\bf{\bar A}}} \right)\left( {{{\bf{B}}_{ij}} - {\bf{\bar B}}} \right)} \)
Argument type: |
Real arrays, must have same dimensions (\(N \times 1\) and \(1 \times N\)) are considered equivalent) |
Returns type: |
Real |
Returns the CPU’s internal time in seconds. You can use this to determine the running time of a program, by comparing results of calls to %CPUTIME made at the beginning and at the end of the program.
Argument type: |
None |
Returns type: |
Integer |
Returns the cosecant of x.
Argument type: |
Real |
Returns type: |
Real |
%csqrt(z) — Complex Square root
Returns the complex square root of z.
Argument type: |
Complex |
Returns type: |
Complex |
%cvtocorr(V) — Converts a covariance matrix to correlations
Returns the correlation matrix C created from a covariance matrix V: \({{\bf{C}}_{ij}} = {{\bf{V}}_{ij}}/\sqrt {{{\bf{V}}_{ii}}{{\bf{V}}_{jj}}} \)
Argument type: |
SYMMETRIC |
Returns type: |
SYMMETRIC |
%cxadj(Z) — Complex matrix adjoint (conjugate transpose)
Returns the (conjugate transpose) adjoint of a complex matrix.
Argument type: |
Complex-valued matrix |
Returns type: |
Complex-valued matrix |
%cxdiag(Z) — Complex diagonal matrix
Returns the diagonal complex matrix from a complex vector or \(1 \times N\) rectangular.
Argument type: |
Complex valued-vector or \(1 \times N\) rectangular |
Returns type: |
Complex-valued matrix |
%cxeigdecomp(Z) — Complex eigen decompostion
Returns the eigen decomposition of a Hermitian complex matrix. The return is a VECT[CMATRIX] with two components—the first are the eigenvalues, the second the eigenvectors.
Argument type: |
Complex matrix |
Returns type: |
VECTOR of Complex arrays, with 2 elements |
%cxinv(Z) — Complex matrix inverse
Returns the complex inverse of a complex array.
Argument type: |
Complex matrix (must be \(N \times N\)) |
Returns type: |
Complex matrix |
%cxsvd(Z) — Complex singular value decomposition
Returns the singular value decomposition of a complex (m×n) matrix Z. This is a VECTOR of three complex matrices, U, W and V, where \({\bf{Z}} = {\bf{U}}{\rm{ }}diag({\bf{W}}){\rm{ }}{{\bf{V}}^*}\) (where * denotes the conjugate transpose).
U and V are column-orthonormal matrices, that is \({{\bf{U}}^*}{\bf{U}} = I,{{\bf{V}}^*}{\bf{V}} = I\). All elements of W (the singular values of Z) are real (though they’re stored as complex) and are sorted from largest to smallest. W has dimensions min(m,n) by 1; U and V are dimensioned to conform with that.
Argument type: |
Complex matrix |
Returns type: |
VECTOR of Complex arrays |
%dateandtime( ) — Date and time stamp
Returns a string with the current date and time.
Argument type: |
None |
Returns type: |
String |
%datelabel(e) — Date label for a given date/entry number
Returns the date label of entry e in the current CALENDAR scheme, formatted as RATS does on, for instance, a PRINT instruction.
Argument type: |
Integer (entry number or date expression) |
Returns type: |
String |
%day(e) — Day of month for entry e
Returns the day of the month (1–31) of entry e in the current CALENDAR scheme. Defined only if that scheme has a “year month day” format.
Argument type: |
Integer (entry number or date expression) |
Returns type: |
Integer |
%daycount(e) — Number of days covered by entry e
Returns the number of days in entry e in the current CALENDAR scheme. For instance, if the CALENDAR is set for monthly data, %DAYCOUNT(2014:11) is 30. With quarterly data, %DAYCOUNT(2010:2) is 91.
Argument type: |
Integer (entry number or date expression) |
Returns type: |
Integer |
%ddivide(A,v) — Divide columns of a matrix by vector elements
Returns the result of dividing the columns of A by corresponding elements in VECTOR v.
Argument types: |
A is RECTANGULAR or SYMMETRIC, v is a VECTOR with dimensions equal to the number of columns of A. |
Returns type: |
Matches A |
%decomp(S) — Cholesky decomposition
Returns the Cholesky decomposition of a SYMMETRIC matrix. For a matrix S, this returns a lower-triangular RECTANGULAR array F, such that \({\bf{FF'}} = {\bf{S}}\). S must be positive semi-definite. See also the %PSDFACTOR function.
Argument type: |
SYMMETRIC |
Returns type: |
RECTANGULAR |
%defined(name) — Status of procedure parameter or option
Returns the status of the specified procedure parameter or option. Returns the value 1 if a value was specified for the option or parameter when the procedure was executed (always returns 1 for options which have been assigned default values), otherwise returns a 0.
Argument type: |
Parameter or option name |
Returns type: |
Integer |
%density(x) — Standard normal density function
Standard Normal density function.
Argument type: |
Real |
Returns type: |
Real |
%det(A) — Determinant of an array
Computes the determinant of a SYMMETRIC or \(N \times N\) RECTANGULAR matrix A.
Argument type: |
SYMMETRIC or \(N \times N\) RECTANGULAR matrix |
Returns type: |
Real |
%diag(A) — Create diagonal matrix from a 1–dimensional array
Creates a square diagonal matrix from a vector. A may be either a VECTOR or an \(N \times 1\) or \(1 \times N\) RECTANGULAR.
Argument type: |
One-dimensional real-valued matrix |
Returns type: |
RECTANGULAR |
%digamma( x ) — Digamma function
Returns the digamma function of x. The digamma is the derivative of \(\log {\rm{ }}\Gamma (x)\), and is usually denoted \(\psi (x)\).
Argument type: |
Real (positive) |
Returns type: |
Real |
%dims(A) — Dimensions of a matrix
Returns the number of rows and columns in an array, as a VECTOR of integers, with the number of rows in entry 1, and the number of columns in entry 2. See also %COLS, %ROWS and %SIZE.
Argument type: |
Any matrix |
Returns type: |
VECTOR[INTEGER] |
%dlminit(A,SW,F,Z) — Generate initial conditions for a state-space DLM
This returns a full solution for the initial conditions for a state space model with the given input matrices. It returns a VECT[RECT] with first component being the (finite) covariance matrix, the second the mean, and the third the diffuse covariance matrix. %PSDINIT solves a more limited problem for strictly stationary transition matrix A.
Argument type: |
RECTANGULAR |
Returns type: |
VECTOR[RECTANGULAR] |
%dlmgfroma(A) — Transforming a state-space DLM to stationarity
This analyzes a state transition matrix A from a state-space model and produces the “G” matrix which transforms the model to its stationary states.
Argument type: |
RECTANGULAR |
Returns type: |
RECTANGULAR (could have zero dimension if A has no unit eigenvalues) |
%dmills(x) — Derivative of the inverse Mills’ ratio
Returns the derivative evaluated at x of the inverse Mills’ ratio for the normal (\(\phi {\rm{/}}\Phi \)). The inverse Mills’ ratio itself is computed by the %MILLS function.
Argument type: |
Real |
Returns type: |
Real |
%dmult(A,v) — Multiply columns of a matrix by vector elements
Returns the result of multiplying the columns of A by corresponding elements in VECTOR V.
Argument types: |
A is RECTANGULAR or SYMMETRIC, v is a VECTOR with dimensions equal to the number of columns of A. |
Returns type: |
Matches A |
Returns the "duplication matrix" which maps a vech (lower triangle) of an \(n \times n\) symmetric matrix to the equivalent vec of a full \(n \times n\) matrix by duplicating the lower triangle elements to the above diagonal locations. Note that this creates a matrix to do the mapping—it doesn't do the mapping itself. This was added with version 9.2.
Argument types: |
Integer |
Returns type: |
RECTANGULAR (dimensions \(n^2 \times n(n+1)/2\) ) |
%dnninv(n) — Inverse duplication matrix
Returns the (generalized) inverse of a duplication matrix which maps the vec of an \(n \times n\) matrix to the vech (lower triangle) of a symmetric matrix. Note that this creates a matrix to do the mapping—it doesn't do the mapping itself. This was added with version 9.2.
Argument types: |
Integer |
Returns type: |
RECTANGULAR (dimensions \(n(n+1)/2) \times n^2\) ) |
%do(i,n,m,expr) — Internal do loop
Loops over the expression beginning with \(i=n\) as long as \(i \le m\). See the descriptions of EWISE and DO for examples.
Argument types: |
i must be an integer variable, n and m are integer values or expressions, expr can be any expression |
Returns type: |
None. Should only be done as part of a more complex calculation |
%dow(year,month,day) — Day of week from expanded date
Returns the day of the week (Monday=1 through Sunday=7) for the date given by year,month,day.
Argument types: |
Integer |
Returns type: |
Integer |
%dot(A,B) — Dot product of two arrays
Returns the “dot” product of A and B.
Argument type: |
real-valued arrays. A and B must have the same dimensions (RATS considers \(N \times 1\) and \(1 \times N\) to be equivalent). |
Returns type: |
Real |
%easter(year) — Returns date of (Western) Easter Holiday
Returns the date of the Easter holiday for year in the Western Christian tradition as a number of days after March 22 (the earliest possible Easter date).
Argument type: |
Integer |
Returns type: |
Integer |
%eigdecomp(S) — Eigen decomposition of a symmetric matrix
Returns a 2-vector of RECTANGULAR arrays giving an eigen decomposition of the symmetric array S. The first array returned is the \(N \times 1\) matrix of eigenvalues, and the second is the \(N \times N\) matrix of eigenvectors (in the columns, normalized to unit length).
Argument type: |
SYMMETRIC |
Returns type: |
VECTOR of RECTANGULARs |
%eqncoeffs(equation) — Coefficients of an equation
Returns a VECTOR with the current coefficients for the specified equation. You can refer to equations by their name or handle. Use 0 as the argument to get the coefficient vector from the most recent regression.
Argument type: |
EQUATION name or handle |
Returns type: |
VECTOR |
%eqncopy(equation) — Makes a copy of an equation
Returns a copy of an equation. This is useful if you might be redefining the original equation and need to make a copy of it as it currently exists. This was added with version 9.2.
Argument type: |
EQUATION name or handle |
Returns type: |
EQUATION |
%eqndepvar(equation) — Get dependent variable of an equation
Returns the SERIES handle of the dependent variable of the specified equation. Use 0 as the argument to get the dependent variable in the most recent regression.
Argument type: |
EQUATION name or handle |
Returns type: |
Integer (SERIES handle) |
%eqngetidentity(equation) — Returns setting of “identity” tag for an equation
This returns the value of the identity tag for the equation. It returns 1 if the equation is an identity, 0 if it is not.
Argument type: |
EQUATION name or handle |
Returns type: |
Integer |
%eqnhandle(equation) — Get “handle” of an equation
Returns the integer number (handle) which can be used to represent the equation.
Argument type: |
EQUATION name or handle |
Returns type: |
Integer (EQUATION handle) |
%eqnlag(equation,lag) — Lags right hand side of an equation
Returns a copy of an equation with all right hand side variables lagged an additional lag periods.
Argument type: |
equation is an EQUATION name or handle, lag is an integer |
Returns type: |
EQUATION |
%eqnlagpoly(equation,series) — Extract lag polynomial
Extracts the lag polynomial for the selected series from an equation. Equation can be an equation name or number. Use zero to refer to the most recent regression. This returns a polynomial as a VECTOR of dimension (n+1), where n is the degree of the lag polynomial. The form of the polynomial depends upon which variable is extracted.
Argument type: |
equation is an EQUATION name or handle, series is a SERIES |
Returns type: |
VECTOR describing a polynomial |
%eqnprj(equation,t) — Compute projected values of an equation
Returns the projected (fitted) value of equation at time period t. Use 0 for equation to use the explanatory variables from the most recent regression. Use %EQNVALUE if you want the value given a set of coefficients that you supply rather than the current coefficient values of the equation.
Argument type: |
EQUATION name or handle, t is an integer (entry number) |
Returns type: |
Real |
%eqnreglabels(equation) — Get regressor labels for an equation
Returns a VECTOR[STRINGS] with the labels of the regressors (explanatory variables) in an equation, formatted as shown in regression output (e.g., series{lag} to show lags). Use 0 as the argument to get the labels for the most recent regression.
Argument type: |
EQUATION name or handle |
Returns type: |
VECT[STRINGS] |
%eqnresid(equation,t) — Residual value of equation at entry t
Returns the residual value of the equation at entry t.
Argument type: |
equation is an EQUATION name or handle, t is an integer (entry number) |
Returns type: |
Real |
%eqnrvalue(equation,t,coeffs) — Residual of equation given coefficient vector
Returns the residual value of equation at entry t, given a set of coefficient values provided by the VECTOR coeffs.
Argument type: |
equation is an EQUATION name or handle, t is an integer (entry number), coeffs is a VECTOR |
Returns type: |
Real |
%eqnserieslag(series,lag) — Create equation “bit”
Returns an EQUATION with the explanatory variable series{lag} with a coefficient of 1.0. This can be used in building or adjusting an equation.
Argument type: |
series is a SERIES name or handle, lag is an integer |
Returns type: |
EQUATION |
%eqnsetcoeffs(equation,C) — Reset coefficients of an equation
This sets the coefficients of equation to the vector C.
Argument type: |
equation is an EQUATION name or handle, C is a VECTOR |
Returns type: |
none |
%eqnsetidentity(equation,tag) — Set the “identity” tag of an equation
This sets the “identity” tag for equation. This determines whether or not the equation is treated as an identity. To turn on the tag and make the equation an identity, use the value 1 for tag. Use the value 0 to turn off the tag.
Argument type: |
equation is an EQUATION name or handle, tag is integer |
Returns type: |
none |
%eqnsetresids(equation,r) — Set the residuals for an equation
This sets the residuals for equation to be the series r.
Argument type: |
equation is an EQUATION name or handle, r is SERIES |
Returns type: |
none |
%eqnsetvariance(equation,v) — Reset variance of an equation
This sets the residual variance of equation to the value v.
Argument type: |
equation is an EQUATION name or handle, v is real |
Returns type: |
none |
%eqnsize(equation) — Number of explanatory variables in equation
Returns the number of explanatory variables in equation.
Argument type: |
EQUATION name or handle |
Returns type: |
Integer |
%eqntable(equation) — List of variables/lags in an equation
Returns a RECTANGULAR[INTEGER] array listing the explanatory variables in equation. The array has dimensions 2 × number of explanatory variables. Row one lists the series numbers of the explanatory variables, row two lists the lags. Use 0 for equation to get the table of variables in the most recent regression.
Argument type: |
EQUATION name or equation handle |
Returns type: |
2 × k RECT[INTEGER] |
%eqnvalue(equation,t,coeffs) — Value of an equation
Returns the value of the linear equation at time period t, given coefficients coeffs—a set of coefficients supplied as a VECTOR. Use 0 for equation to use the explanatory variables from the most recent regression. Use %EQNPRJ if you want the value of an equation given the current coefficient values of the equation rather than user-inputted values.
Argument type: |
equation is an EQUATION name or handle, t is an integer (entry number), coeffs is a VECTOR |
Returns type: |
Real |
%eqnvariance(equation) — Variance of an equation
Returns the variance associated with an equation (generally the residual variance from when it is estimated.)
Argument type: |
EQUATION name or equation handle |
Returns type: |
Real |
%eqnxvector(equation,t) — Extract an X(t) vector for an equation
Returns a VECTOR with the “X” variables from the equation for time period t. Use 0 for equation to pull the explanatory variables from the most recent regression.
Argument type: |
equation is an EQUATION name or EQUATION handle, t is integer |
Returns type: |
VECTOR |
%execpath() — Return path to RATS executable file
This returns the path to the directory containing the RATS executable file in use. This can be useful if you need to reference a subdirectory of that path (for compiling a procedure file, for example) or need to verify the location of the executable file.
Argument types: |
None |
Returns type: |
String |
exp(x),%exp(A) — Scalar or elementwise exponentiation function
For a scalar real x, exp(x) returns \({e^x}\). For an array A, %exp(A) returns an array B, such that \({{\bf{B}}_{ij}} = \exp \left( {{{\bf{A}}_{ij}}} \right)\).
Argument types: |
Scalar real, or array of reals |
Returns type: |
Same as argument type |
%factorial(x) — Factorial function
Returns the factorial \(x! = x(x - 1)(x - 2) \ldots 1\) or, more generally \(\Gamma \left( {x + 1} \right)\). Note that this very rapidly will overflow—in practice, you are generally better off arranging calculations to use %LNGAMMA(x+1) to compute \(\log x!\).
Argument types: |
Real. x cannot be a negative integer. |
Returns type: |
Real |
%file(fname) — Get I/O Unit from File Name
Returns an I/O unit for a given file name string. Note: function call or variable set equal to function call must be preceded by the & dereferencing character, which tells RATS to evaluate the contents of the argument, rather than treating it as a literal string. For example:
compute tempunit = %file("c:\myfiles\salesdata.xls")
data(unit=&tempunit),format=xls,org=col)
Argument type: |
String, must be valid file name (can include path) |
Returns type: |
I/O unit |
%fill(rows,cols,value) — Create constant matrix
Creates a matrix with dimensions rows by cols, with all elements set to value. See also %ones and %zeros.
Argument types: |
rows,cols are integer, value is real |
Returns type: |
RECTANGULAR |
fix(x) — Convert real to integer by truncation
Converts a real value to an integer value by eliminating the fractional part (not by rounding—use %round(x,n) for that). Note that RATS will not automatically convert reals to integers in an expression.
Argument types: |
Real |
Returns type: |
Integer |
float(n) — Convert integer to real
Explicitly converts an integer to a real.
Argument types: |
Integer |
Returns type: |
Real |
%floatingdate(y,m,dow,n) — Day of month for floating holiday
Returns the day of the month of the nth occurrence of the specified day of the week (dow, coded as Monday=1 to Sunday=7) in the year y, month m. Use a negative value of n to count from the end. %floatingdate(2010,11,4,4) is the fourth Thursday of November, 2010, while %floatingdate(2010,11,4,-1) is the final Thursday.
Argument types: |
Integer |
Returns type: |
Integer |
%frac(x) — Fractional part of a real number
Returns x–[x], where [x] is the first integer value less than x. For example, %frac(9.7) returns .7, %frac(‑9.7) returns .3.
Argument type: |
Real |
Returns type: |
Integer |
%fractiles(A,F) — Compute fractiles (quantiles)
Returns a VECTOR with fractiles (quantiles) of the elements of the array A. The list of desired quantiles are provided by the VECTOR F.
Argument type: |
A is a real-valued array, F is a VECTOR |
Returns type: |
VECTOR with the same dimension as F |
%freqend() — Number of frequency ordinates
Returns the number of ordinates set by the FREQUENCY instruction.
Argument type: |
None |
Returns type: |
Integer |
%freqsize(n) — Compute recommended number of complex ordinates
Returns the recommended number of ordinates for a FREQUENCY instruction, for n actual data points.
Argument type: |
Integer |
Returns type: |
Integer |
%ftest(x,n,m) — F-test tail probability
Returns the tail probability for an F(n,m).
Argument types: |
Real |
Returns type: |
Real |
Returns the gamma function of x. See also %LNGAMMA.
Argument types: |
Real |
Returns type: |
Real |
%gammainc(x,a) — Incomplete gamma function
Returns the incomplete gamma function of x given parameter a.
Argument types: |
Real (\(x \ge 0\), \(a > 0\) ) |
Returns type: |
Real |
%gedcdf(x,s) — CDF of the GED distribution
Returns the CDF of the GED (generalized error distribution) with shape s at x.
Argument types: |
Real |
Returns type: |
Real |
%getenv(name) — Get environment string
For a given operating system environment variable name, this returns the associated environment string. Returns a blank string if the environment variable is not defined in the operating system.
Argument types: |
String or label |
Returns type: |
String |
%gevcdf(x,k,mu,sigma) — CDF of Generalized Extreme Value
Returns the cdf of the Generalized Extreme Value distribution, for tail index k, location parameter mu, and scale parameter sigma.
Argument types: |
Real |
Returns type: |
Real |
%ginv(A) — Generalized inverse of a Matrix
Computes the generalized (Moore-Penrose) inverse of \(\bf{A}\). This is a matrix \({{\bf{A}}^ + }\) which solves \({\bf{A}}{{\bf{A}}^ + }{\bf{A}} = {\bf{A}}\) and \({{\bf{A}}^ + }{\bf{A}}{{\bf{A}}^ + } = {{\bf{A}}^ + }\). \(\bf{A}\) does not have to be square—\({{\bf{A}}^ + }\) will have the same dimensions as \({{\bf{A'}}}\).
Argument types: |
RECTANGULAR (m×n) |
Returns type: |
RECTANGULAR (n×m) |
%girfmatrix(S) — Generalized IRF Shock Matrix
Returns the shock matrix generated from a SYMMETRIC matrix that will give the "Generalized" Impulse Response Function. Each column in the output is the column in the input divided by the square root of its diagonal element (which is that column would be if it were the first column in a Cholesky factor). S must be positive semi-definite. Note that this is not a factor of S, and should not be used as the basis for calculating the decomposition of variance. This was added with 10.0.
Argument type: |
SYMMETRIC |
Returns type: |
RECTANGULAR |
%gpcdf(x,k,mu,sigma) — CDF of generalized Pareto
Returns the CDF of the Generalized Pareto distribution, for tail index k, location parameter mu, and scale parameter sigma.
Argument types: |
Real |
Returns type: |
Real |
%grparm() — Get Current Graph Label Settings
Returns a VECT[INTEGER] identifying the current font and type size settings for graph labels. Used with the RECALL option on GRPARM.
Argument type: |
None |
Returns type: |
VECT[INTEGER] (coded) |
%gsortho(A) — Gram-Schmidt orthonormalization
Returns a column-wise Gram-Schmidt orthonormalization of A
Argument type: |
RECTANGULAR |
Returns type: |
RECTANGULAR with same dimensions as A. |
%iabs(n) — Integer absolute value
Returns the absolute value of the integer n.
Argument type: |
Integer |
Returns type: |
Integer |
%identity(n) — Create identity matrix
Creates an identity matrix with dimensions n × n.
Argument type: |
Integer |
Returns type: |
RECTANGULAR |
Integer m divided by integer n, returning an integer result. Any remainder is ignored.
Argument type: |
Integer |
Returns type: |
Integer |
%if(x,y,z) — Evaluate a conditional expression
Returns y if x is non‑zero, returns z if x is zero. x must be integer or real, but y and z can be any expressions as long as they are matching types. Often used in SET instructions with x as a logical expression (that is, if x is true, return y, otherwise return z). Example
set bigx = %if(x>=.5,1.0,-1.0)
Argument type: |
x is a logical expression or scalar (zero = false, non-zero = true); y,z = Any matching types |
Returns type: |
Type of y and z |
%imag(z) — Imaginary part of complex number
Returns the imaginary part of a complex number z.
Argument type: |
Complex |
Returns type: |
Real |
%imax(m,n) — Maximum of two integers
Returns the maximum of the two integer arguments.
Argument types: |
Integer |
Returns type: |
Integer |
%imin(m,n) — Minimum of two integers
Returns the minimum of the two integer arguments.
Argument types: |
Integer |
Returns type: |
Integer |
%index(V) — Sorting index for a VECTOR
Returns a VECTOR[INTEGERS] which gives the sorting index for the vector V; that is, a VECT[INT] such that V(%INDEX(V(i))) would sort V into increasing order.
Argument type: |
VECTOR or \(N \times 1\) Rectangular |
Returns type: |
VECTOR[INTEGER] |
%indiv(t) — Individual within a panel set
When a panel data CALENDAR is set, this returns the number of the individual of which entry t is a part.
Argument type: |
Integer |
Returns type: |
Integer |
%innerxx(A) — Inner cross product
Returns \(\bf{A}'\bf{A}\) for the matrix A. See also %OUTERXX.
Argument types: |
Real-valued matrix |
Returns type: |
SYMMETRIC |
%instlist() — List of instruments
Returns the current list of instruments as a regressor list (a VECTOR[INTEGER] array). %INSTTABLE returns the same information, but in the form of a \(2 \times n\) array.
Argument types: |
None |
Returns type: |
VECT[INTEGER] coded information |
%insttable() — Table of instruments
Returns the table (a \(2 \times n\) array of integers) for the current list of instruments. Each column in the return array represents one series{lag} pair, with the series in the first row and lag in the second.
Argument types: |
None |
Returns type: |
RECT[INTEGER] coded information |
%instxvector(t) — Extract an X(t) for the instrument set
Returns a VECTOR with the current instruments for time period t.
Argument types: |
Integer |
Returns type: |
VECTOR |
Returns the inverse of the non-singular matrix A. A can be SYMMETRIC or \(N \times N\) RECTANGULAR. See %GINV for generalized inverses.
Argument type: |
Symmetric or square rectangular matrix |
Returns type: |
Same form as A |
%invchisqr(p,r) — Inverse chi-squared tail probability
Returns the argument x for which the tail probability of a chi-square distribution with r degrees of freedom is p. In particular, %chisqr(%invchisqr(p,r),r)=p
Argument type: |
Real \(0 < p < 1,{\text{ }}r > 0\) |
Returns type: |
Real |
%invchisqrnc(p,r,nc) — Inverse CDF non-central chi-squared
Returns the argument x for which the CDF of a non-central chi-square distribution with r degrees of freedom and non-centrality nc is p. In particular, %chisqrnc(%invchisqrnc(p,r,nc),r,nc)=p
Argument type: |
Real \(0 < p < 1,{\text{ }}r > 0\) |
Returns type: |
Real |
%invftest(p,n,m) — Inverse F-test tail probability
Returns the value x for which the tail probability of an F with n and m degrees of freedom is p. In particular, %ftest(%invftest(p,n,m),n,m)=p.
Argument type: |
Real \(0 \le p \le 1{\text{; }}n,m > 0\) |
Returns type: |
Real |
%invged(p,c) — Inverse CDF of GED
Returns the inverse CDF of the generalized error distribution (GED) with shape parameter c (and variance 1).
Argument type: |
Real \(0 \le p \le 1{\text{, }}c > 0\) |
Returns type: |
Real |
%invgev(p,k,mu,sigma) — Inverse CDF of Generalized Extreme Value
Returns the inverse CDF of the Generalized Extreme Value distribution, for probability p, tail index k, location parameter mu, and scale parameter sigma.
Argument types: |
Real |
Returns type: |
Real |
%invgp(p,k,mu,sigma) — Inverse CDF of the generalized Pareto
Returns the inverse CDF of the Generalized Pareto distribution, for probability p, tail index k, location parameter mu, and scale parameter sigma.
Argument types: |
Real |
Returns type: |
Real |
%invnormal(p) — Inverse normal distribution
Returns the x for which the CDF of a standard Normal distribution is p. In particular, %cdf(%invnormal(p))=p
Argument type: |
Real, \(0 < p < 1\) |
Returns type: |
Real |
%invtcdf(p,r) — Inverse CDF of the t distribution
Returns the inverse CDF of the t distribution, for the probability p and degrees of freedom r.
Argument type: |
Real \(0 < p < 1\text{, }r > 0\) |
Returns type: |
Real |
%invttest(p,r) — Inverse t test
Returns the x for which the two-tailed probability of a t distribution with r degrees of freedom is p. In particular, %ttest(%invttest(p,r),r)=p
Argument type: |
Real \(0 < p < 1\text{, }r > 0\) |
Returns type: |
Real |
%invztest(p) — Inverse two-tailed normal test
Returns the x for which the two-tailed probability of a Normal distribution is p. In particular, %ztest(%invztest(p))=p. This was added with RATS 10.0.
Argument type: |
Real \(0 < p < 1\text{, }r > 0\) |
Returns type: |
Real |
%irfflatten(irf) — Flatten Impulse Responses
Takes a RECT[SERIES] of impulse responses and "flattens" it into the proper form for saving as an element in the %%RESPONSES array. This was added with RATS 10.1.
Argument type: |
RECT[SERIES] |
Returns type: |
RECT |
%isimpson(X,F) — Numerical integral by Simpson’s Rule
Returns a numerical integral computed using Simpson’s Rule. X is the vector of grid points (which should be equally spaced in increasing order) and F is a corresponding vector of function values.
Argument type: |
VECTORs (should be same dimension) |
Returns type: |
Real |
%itrapezoid(X,F) — Numerical integral by Trapezoidal Rule
Returns a numerical integral computed using the trapezoidal rule. X is the vector of grid points (in increasing order, not necessarily equally spaced) and F is a corresponding vector of function values.
Argument type: |
VECTORs (should be same dimension) |
Returns type: |
Real |
%julian(e) — Number of days from Jan 1, 0001 C.E.
Returns the number of days from a (theoretical) Jan 1, 0001 to (the final day in) entry e in the current CALENDAR scheme. This is the RATS julian date.
Argument type: |
Integer (entry number or date expression) |
Returns type: |
Integer |
%julianfromcoded(x,codeformat) — Translation of numerically coded date (10.0)
Returns the RATS julian date corresponding to the value x, where the date is coded numerically according to the string codeformat. For instance, if dates are coded as numbers with digits yyyymmdd, then you would use %julianfromcoded(x,"yyyymmdd").
Argument type: |
Real,string |
Returns type: |
Integer |
%julianfromymd(y,m,d) — Julian date for specified date
Returns the RATS julian date (number of days since January 1st, 0001, acting as if the Gregorian calendar extends back) for the date y:m:d.
Argument types: |
Integers |
Returns type: |
Integer |
%keys(hash) — Get keys from hash table of strings
Hash variables are an aggregate variable type where the elements stored in the hash are referenced by character strings, or “keys”. This function returns a list of the keys (strings) stored in the hash variable.
Argument types: |
HASH |
Returns type: |
VECTOR[STRINGS] |
%knn(n) — Transposition operator
Returns the transposition operator which maps a vec of an \(n \times n\) matrix to vec of its transpose. Note that this creates a matrix to do the mapping—it doesn't do the mapping itself. This was added with version 9.2.
Argument types: |
Integer |
Returns type: |
RECTANGULAR (dimensions \(n^2 \times n^2\) ) |
%kroneker(A,B) — Kroneker product of two arrays
Returns the Kroneker product of arrays A and B. For A(m,n) and B(p,q), this computes an \(mp \times nq\) matrix \({\bf{A}} \otimes {\bf{B}}\).
Argument types: |
Any real-valued matrices |
Returns type: |
RECTANGULAR |
%kronid(A,B) — Kroneker identity function
Computes \(\left( {{\bf{A}} \otimes I} \right){\bf{B}}\). A must be a square matrix; the first dimension of B must be a multiple of the dimension of A.
Argument types: |
A must be SYMMETRIC or square RECTANGULAR matrix, B can be any matrix with first dimension a multiple of the dimension of A. |
Returns type: |
RECTANGULAR |
%kronmult(A,B,C) — Specialized Kroneker multiplication
Computes \(\left( {{\bf{A}} \otimes {\bf{B}}} \right){\bf{C}}\) where \(\left( {{\bf{A}} \otimes {\bf{B}}} \right)\) is the Kroneker product of A and B.
Argument types: |
Any real-valued matrices with compatible dimensions |
Returns type: |
RECTANGULAR |
Returns the label of series with the name or handle s.
Argument type: |
Series name or handle |
Returns type: |
LABEL |
%label(variable) — Get label of a series or other variable
Returns the label attached to the specified variable (that is, the name of the specified series, equation, etc.). Unlike %L, if you use a series number, you must use a type modifier to tell RATS that you want the label of a series.
Argument type: |
Variable name (not quoted) or series handle. |
Returns type: |
LABEL |
Returns the leftmost n characters of the string s.
Argument type: |
s is a string or label, n is integer |
Returns type: |
String |
%lnbeta(a,b) — Natural log of the beta function
Returns the natural log of the beta function B(a,b).
Argument types: |
Real, non-negative |
Returns type: |
Real |
%lngamma(x) — Natural log of the Gamma function
Returns the natural log of \(\Gamma (x)\).
Argument types: |
Real, non-negative |
Returns type: |
Real |
%lnlogistic(x) — Natural log of the logistic CDF
Returns \(\log \left( {\exp (x)/(1 + \exp (x)} \right)\), that is, the log of the logistic CDF.
Argument types: |
Real |
Returns type: |
Real |
Returns the "elimination matrix" which maps a vec of an \(n \times n\) matrix to the equivalent vech (lower triangle) by eliminating the above diagonal elements. Note that this creates a matrix to do the mapping—it doesn't do the mapping itself. This was added with version 9.2.
Argument types: |
Integer |
Returns type: |
RECTANGULAR (dimensions \(n(n+1)/2) \times n^2 \) ) |
%lnnx(n) — Elimination matrix for below diagonal
Returns the "elimination matrix" which maps a vec of an \(n \times n\) matrix to the equivalent vech (lower triangle) by eliminating the elements at and above the diagonal. Note that this creates a matrix to do the mapping—it doesn't do the mapping itself. This was added with version 9.2.
Argument types: |
Integer |
Returns type: |
RECTANGULAR (dimensions \(n(n - 1)/2{\rm{ }} \times {\rm{ }}n^2 \) ) |
log(x),%log(A) — Natural log function
Returns the natural log. If applied to a matrix A, returns B such that \({{\bf{B}}_{ij}} = {\log _e}{{\bf{A}}_{ij}}\)
Argument types: |
Real, or any real-valued array |
Returns type: |
Matches the argument |
%logbetadensity(x,α,β) — Log Density of Beta distribution
Returns the log density of the beta density for x, given \(\alpha\) and \(\beta\).
Argument types: |
Reals |
Returns type: |
Real |
%logcdf(v,x) — Natural log of the normal CDF
Returns \(log \,\Phi \left( {x/\sqrt v } \right)\) where v is the variance, and \(\Phi \) is the normal CDF.
Argument types: |
Reals |
Returns type: |
Real |
%logconcdensity(\({\hat \Sigma }\),T) — Log concentrated MV normal density
Returns the log concentrated density for a (multivariate) normal with covariance matrix \({\hat \Sigma }\) and number of observations T:
\( - \frac{{Tk}}{2}\left( {\log (2\pi ) + 1} \right) - \frac{T}{2}\log \left| {\hat \Sigma } \right|\)
Argument types: |
\({\hat \Sigma }\) is \(k \times k\) SYMMETRIC (or single real), T is integer |
Returns type: |
Real |
%logdensity(A,v) — Log multivariate normal density
Returns the log density for a (multivariate) normal with covariance matrix A evaluated at the deviations from mean of v:
\( - \frac{1}{2}\left( {k\log \pi + \log \left| {\bf{A}} \right| + {\bf{v'}}{{\bf{A}}^{ - 1}}{\bf{v}}} \right)\)
Argument types: |
A is \(k \times k\) SYMMETRIC, v is a VECTOR (or 1-dimensional RECTANGULAR) |
Returns type: |
Real |
%logdensitycv(\({\Sigma }\),\({\hat \Sigma }\),T) — Log multivariate normal density
Returns the log of multivariate normal density as a function of \({\Sigma }\),\({\hat \Sigma }\) , and the number of observations (T):
\( - \frac{{Tk}}{2}\log (2\pi ) - \frac{T}{2}\log \left| {\hat \Sigma } \right| - \frac{T}{2}{\Sigma ^{ - 1}}\hat \Sigma \)
Argument types: |
\({\Sigma }\) and \({\hat \Sigma }\) are \(k \times k\) SYMMETRIC (or scalar reals), T is an integer |
Returns type: |
Real |
%logdensitydiag(V,u) — Log multivariate normal density with diagonal covariance
Similar to %LOGDENSITY except that the covariance matrix is diagonal, and V is a vector with the diagonal elements.
Argument types: |
Both VECTOR of the same dimension |
Returns type: |
Real |
%logdetxx(S) — Log determinant of a symmetric matrix
Returns \({\rm{log}}\left| {\bf{S}} \right|\) for a symmetric matrix S.
Argument types: |
SYMMETRIC |
Returns type: |
Real |
%logdirichlet(x,d) — Log Density of Dirichlet
Returns the log density of a Dirichlet density. x and d must have the same dimensions, the d’s must be positive, and the x’s must sum to one.
Argument types: |
VECTORs, must be of the same dimension. |
Returns type: |
Real |
%loggammadensity(x,c,b) — Log Gamma density
Returns the log density evaluated at x, for a gamma distribution with shape parameter c and scale b.
Argument types: |
Reals. c and b must be positive |
Returns type: |
Real |
%loggeddensity(x,c,v) — Log GED density
Returns the log density evaluated at x, for a GED (generalized error distribution) with shape parameter c and variance v. This can be used for either univariate or multivariate GED distributions. Note that the scale parameter for the distribution is determined indirectly from the shape and the variance.
Argument types: |
For univariate GED, both real and must be positive. For multivariate GED, x must be an \(n \times 1\) VECTOR and v a positive-definite \(n \times n\) SYMMETRIC. |
Returns type: |
Real |
%loggevdensity(x,k,mu,sigma) — Log GEV density
Returns the log of the density function for the Generalized Extreme Value distribution for x, given tail index k, location parameter mu, and scale parameter sigma.
Argument types: |
Reals |
Returns type: |
Real |
%loggpdensity(x,k,mu,sigma) — Log General Pareto density
Returns the log of the density function for the generalized Pareto distribution for x, given tail index k, location parameter mu, and scale parameter sigma.
Argument types: |
Reals |
Returns type: |
Real |
%loginvchisqrdensity(x,degrees,scale) — Log density of scaled inverse chi-squared
Returns the log density at x for the scaled inverse chi-squared with degrees of freedom degrees and scale value scale. This was added with version 9.1.
Argument types: |
Real, all positive |
Returns type: |
Real |
%loginvgammadensity(x,a,b) — Log density of inverse gamma
Returns the log density at x for the inverse gamma with shape a and scale b. This was added with version 9.1.
Argument types: |
Real, all positive |
Returns type: |
Real |
%logistic(x,b) — Logistic function
Returns the logistic function: \(1/\left( {1 + b{e^{ - x}}} \right)\). This is “safeguarded” to avoid overflows.
Argument type: |
Reals |
Returns type: |
Real |
%lognegbin(x,r,p) — Log of the negative binomial density
Returns the log of the negative binomial density of x given r and p.
Argument type: |
Reals |
Returns type: |
Real |
%logpoissonk(mean,k) — Log of Poisson probability
Returns the log of \(P(x = k|m = mean)\) for a Poisson process with the mean given by mean.
Argument type: |
Reals |
Returns type: |
Real |
%logtdensity(V,U,nu) — Log Multivariate t density
Returns the log of the multivariate t-density with nu degrees of freedom and covariance matrix V, evaluated at the vector of deviations from the mean U. Note that V is the covariance matrix of the t distribution itself, not of the underlying multivariate Normal on which it is based.
Argument type: |
V is SYMMETRIC, U is VECTOR (same dimension as V), nu is a positive-valued real. (V and U can also both be reals to evaluate the univariate log density). |
Returns type: |
Real |
%logtdensitystd(V,U,nu) — Log Multivariate t density
Returns the log of the standardized multivariate t-density with nu degrees of freedom and covariance matrix V, evaluated at the vector of deviations from the mean U. This is equivalent to: %logtdensity(v*nu/(nu-2),u,nu)
Argument type: |
V is SYMMETRIC, U is VECTOR (same dimension as V), nu is a positive-valued real. (V and U can also both be reals to evaluate the univariate log density). |
Returns type: |
Real |
%ltinv(L) — Lower triangular inverse
For a packed matrix L, this returns the inverse of the lower-triangular portion.
Argument type: |
PACKED matrix of reals |
Returns type: |
PACKED matrix of reals |
%ltouterxx(L) — Lower triangular outer product
For a packed matrix L, this returns the SYMMETRIC \(\mathbf{L}\mathbf{L}'\)
Argument type: |
PACKED matrix of reals |
Returns type: |
SYMMETRIC matrix of reals |
%matpeek(A,coords) — Extracting entries from a sparse matrix
Returns a VECTOR formed from extracting from the matrix A the row,column elements from the \(2 \times m\) RECT[INTEGER] coords in the matrix A.
Argument type: |
A is RECTANGULAR, coords a \(2 \times m\) RECT[INTEGER] |
Returns type: |
VECTOR (dimension m) |
%matpoke(A,coords,v) — Filling entries in a sparse matrix
Copies data from the VECTOR v (dimension m) to the row,column pairs elements specified by the \(2 \times m\) RECT[INTEGER] coords. The remaining entries of A are unaffected.
Argument type: |
A is RECTANGULAR, coords a \(2 \times m\) RECT[INTEGER], V is VECTOR |
Returns type: |
RECTANGULAR (returns modified A) |
%max(x,y) — Maximum of two reals
Returns the maximum of two real values, x and y.
Argument type: |
Real |
Returns type: |
Real |
%maxindex(V) — Location of maximum value in a VECTOR
Returns the element number at which the maximum value of a VECTOR is attained.
Argument type: |
VECTOR |
Returns type: |
Integer |
%maxvalue(A) — Get maximum value of an array
Returns the maximum value of the array A. Use %minvalue to get the minimum value.
Argument type: |
Real-valued array |
Returns type: |
Real |
%mid(s,m,n) — Middle substring
Returns the n characters from the string s starting at position m. (Count positions beginning at 1). If \(n \le 0\), all characters from position m on are included.
Argument type: |
s is a string or label, m and n are integers |
Returns type: |
String |
%mills(x) — Inverse Mills’ ratio
Returns the inverse Mills’ ratio for a normal (\(\phi /\Phi \)) evaluated at x.
Argument type: |
Real |
Returns type: |
Real |
%min(x,y) — Minimum of two reals
Returns the minimum of two real values, x and y.
Argument types: |
Reals |
Returns type: |
Real |
%minimalrep(A,w) — Determines “minimal” representation
Returns a string giving a “picture” code for use by PRINT, DISPLAY or other output instructions which provides the “minimal” representation for the elements of A using at most w positions. This will be shorter than the representation given by %BESTREP if all elements of A can be shown to their full precision with only a few decimal places.
Argument types: |
A is a real-valued matrix, w a positive integer |
Returns type: |
String |
%minindex(V) — Location of minimum value in a VECTOR
Returns the element number at which the minimum value of a VECTOR is attained.
Argument types: |
VECTOR |
Returns type: |
Integer |
%minus(A) — Negative (“minus”) values of an array
Returns negative elements of array, with positive values replaced with zeros: \({{\bf{B}}_{ij}} = \min ({{\bf{A}}_{ij}},0)\). %plus is the similar function which takes plus values.
Argument types: |
Real or real Array |
Returns type: |
Same as argument |
%minvalue(A) — Get minimum value of an array
Returns the minimum value of the array A. Use %maxvalue to get the maximum value.
Argument type: |
Real-valued array |
Returns type: |
Real |
Returns the remainder from dividing m by n (integer arithmetic). See also %CLOCK(m,n) which does modulo arithmetic but returns values between 1 and n.
Argument type: |
Integer |
Returns type: |
Integer |
%modelalpha(M) — Error correction loadings for a MODEL
Returns the matrix of loadings on the error correction terms in a model that includes them. This was added with version 9.2.
Argument type: |
MODEL |
Returns type: |
N x r matrix |
%modelcompanion(M) — Companion matrix for a MODEL
Returns the companion matrix for a model. The model must only include linear equations—the function will not work if the model includes non-linear formulas.
Argument type: |
MODEL |
Returns type: |
N x N matrix |
%modeldepvars(M) — Get dependent variables from a MODEL
Returns a VECTOR[INTEGER] which gives the series handles for the dependent variables of the equations or formulas in a model.
Argument type: |
MODEL |
Returns type: |
VECT[INTEGER] of series handles |
%modeleqn(M,n) — Get equation from a MODEL
Returns a copy of the equation at position n in model M.
Argument type: |
M is a MODEL, n an integer |
Returns type: |
EQUATION |
%modelfind(M,s) — Locate an equation in a MODEL
Returns the position in model M of the equation or formula which has the series s as its dependent variable. Returns 0 if there is none.
Argument types: |
M is a MODEL, s a SERIES |
Returns type: |
Integer |
%modelgetcoeffs(M) — Get coefficients from a MODEL
Returns a RECTANGULAR with the coefficients from the equations of model M. Each column of the output array will have the coefficients from a different equation.
Argument types: |
MODEL |
Returns type: |
RECTANGULAR |
%modelgetvcv(M) — Get covariance matrix from a MODEL
Retrieves the covariance matrix stored with model M.
Argument types: |
MODEL |
Returns type: |
SYMMETRIC |
%modellagmatrix(M,k) — Lagged Dependent Variable Coefficents for a MODEL
This returns the \(N \times N\) matrix of the coefficients for lag k of the dependent variables of model M (usually a VAR model). If the model has error correction terms, this returns the coefficients on the lagged differences in the error correction form.
Argument types: |
M is a MODEL, k is an integer |
Returns type: |
\(N \times N\) RECTANGULAR |
%modellagsums(M) — Lag sums for a VAR MODEL
Computes the lag sums for a VAR model M. This is the matrix \(I - \sum\limits_{s = 1}^p {{\Phi _s}} \) where \({{\Phi _s}}\) is the matrix of VAR coefficients for lag s. For a model with error correction terms, it returns the lag sums for the differenced variables in the error correction form.
Argument type: |
MODEL |
Returns type: |
\(N \times N\) RECTANGULAR |
%modellabel(M,i) — Label of dependent variable in a MODEL
Returns the label of the dependent variable of the equation or formula at position i in model M.
Argument types: |
M is a MODEL, i is an integer |
Returns type: |
LABEL |
%modellargestroot(M) — Dominant root of MODEL
Returns the absolute value of the largest root of the companion matrix of model M.
Argument type: |
MODEL |
Returns type: |
Real |
%modelpoke(M,i,equation) — Replace an equation in a MODEL
This replaces the equation at position i in model M with equation.
Argument types: |
M is a MODEL, i is an integer, equation is an EQUATION |
Returns type: |
MODEL |
%modelsetcoeffs(M,C) — Set coefficients from a MODEL
Sets the coefficients of (all the) equations of a model M. The coefficients are taken from the array C, with the coefficients for equation i in the model being taken from column i of C.
Argument types: |
M is a MODEL, C is RECTANGULAR |
Returns type: |
None |
%modelsetvcv(M,S) — Set covariance matrix of a MODEL
Sets S as the residual covariance matrix of model M.
Argument types: |
M is a MODEL, S is SYMMETRIC |
Returns type: |
None |
%modelsize(M) — Number of equations in a MODEL
Returns the number of equations or formulas in model M.
Argument types: |
MODEL |
Returns type: |
Integer |
%modelsubstect(M) — Substitute out error correction terms in MODEL
Substitutes the error-correction terms out of model M, producing a model written in terms of the original variables only.
Argument types: |
MODEL |
Returns type: |
MODEL |
%month(e) — Month number (1–12) of entry e
Returns the month corresponding to entry e in the current CALENDAR scheme, where 1 is January, 2 is February, etc.
Argument types: |
Integer |
Returns type: |
Integer |
%mqform(A,B) — Matrix quadratic form operation
Returns \({\bf{B'AB}}\).
Argument type: |
\(\bf{A}\) must be \(N \times N\) RECTANGULAR or SYMMETRIC; \(\bf{B}\) can be any array that allows the \({\bf{B'AB}}\) operation, given the dimension of \(\bf{A}\). |
Returns type: |
SYMMETRIC if \(\bf{A}\) is SYMMETRIC, otherwise RECTANGULAR |
%mqformdiag(A,B) — Diagonal of matrix quadratic form
Returns a VECTOR containing the diagonal elements of \({\bf{B'AB}}\).
Argument type: |
\(\bf{A}\) must be \(N \times N\) RECTANGULAR or SYMMETRIC; \(\bf{B}\) can be any array that allows the \({\bf{B'AB}}\) operation, given the dimension of \(\bf{A}\). |
Returns type: |
VECTOR |
%mscalar(x) — Create a scalar matrix
Creates a scalar matrix equal to the identity matrix times the value x. You can only use this in an expression such as A=%MSCALAR(x), where \(\bf{A}\) is an \(N \times N\) matrix which has already been declared and dimensioned.
Argument type: |
RECTANGULAR |
Returns type: |
SYMMETRIC or RECTANGULAR |
%mspexpand(P) — Markov switching probability function reparameterization
Takes the reduced size \((N−1) \times N\) matrix of Markov switching transition probabilities P (parameterized that way for estimation purposes) and expands it to a full \(N \times N\) matrix. This is the inverse of %MSPREDUCE.
Argument type: |
RECTANGULAR |
Returns type: |
RECTANGULAR |
%mspreduce(P) — Markov switching probability function reparameterization
Takes a full size \(N \times N\) matrix of Markov switching transition probabilities P and reduces it to the \((N−1) \times N\) matrix of free parameters. This is the inverse of %MSPEXPAND.
Argument type: |
RECTANGULAR |
Returns type: |
RECTANGULAR |
%negbin(x,r,p) — Negative binomial density
Returns the negative binomial density (generalized to real-valued parameters).
Argument type: |
Reals (all non-negative) |
Returns type: |
Real |
%noprec(x) — Tests for loss of precision
Returns 1 or 0 depending upon whether x is “machine-zero”.
Argument type: |
Real |
Returns type: |
Real (0 or 1 value) |
%normsqr(A) — Squared norm of a matrix
Returns the sum of squared elements of A.
Argument types: |
Real-valued array |
Returns type: |
Real |
%nullspace(A) — Orthonormal basis for null space
Returns an orthonormal matrix \(\bf{A}^ \bot \) which forms a basis for the null space of A. %NULLSPACE is similar to %PERP, but it does not assume that the input matrix has full rank in its smaller dimension. As a result, the dimensions of the output matrix will depend upon the rank of A, not just upon its dimensions.
Argument types: |
RECTANGULAR |
Returns type: |
RECTANGULAR |
%nyblomtest(x,p) — Nyblom fluctuations distribution
Returns the (approximate) tail probability at x of a standard Nyblom (1989) fluctuations test with p components. This is computed using a saddlepoint approximation, and should be quite accurate in the tails.
Argument types: |
x is a non-negative real, p is a positive integer |
Returns type: |
Real |
%ones(rows,cols) — Create a matrix of ones
Returns a matrix with dimensions rows × cols , with all elements equal to one.
Argument types: |
Integers |
Returns type: |
Rectangular of Reals |
%outerxx(A) — Outer cross product
Returns \({\bf{AA'}}\) for the matrix A. Use %INNERXX(A) to get \({\bf{A'A}}\).
Argument type: |
Real-valued array |
Returns type: |
SYMMETRIC |
%ovcheck(x) — Checks for potential overflow
Returns a missing value if x is so large as to probably be the result of an unstable calculation. This will typically force the parameters generating a function evaluation to be rejected as out-of-range. If x is a “normal” number, %OVCHECK returns x.
Argument type: |
Real |
Returns type: |
Real (either x or missing value) |
%panelobs( ) — Size of panel data time dimension
Returns the number of periods per individual for panel data as was set on the CALENDAR instruction.
Argument type: |
None |
Returns type: |
Integer |
%panelsize() — Number of Individuals in Panel Set
Returns the number of individuals given the current CALENDAR(PANELOBS=...) setting and total number of observations. %PANELOBS() gives the number of time periods.
Argument type: |
None |
Returns type: |
Integer |
%parmset( ) — Returns the default PARMSET
This returns the current default parameter set.
Argument type: |
None |
Returns type: |
PARMSET |
%parmslabels(P) — Extract parameters from a PARMSET
Returns a VECTOR[STRINGS] with the labels of the variables in parameter set P.
Argument type: |
PARMSET |
Returns type: |
VECTOR[STRINGS] |
%parmspeek(P) — Extract parameters from a PARMSET
Returns the parameters from PARMSET P as a VECTOR.
Argument type: |
PARMSET |
Returns type: |
VECTOR |
%parmspoke(P,v) — Put vector into a PARMSET
Resets the parameters in PARMSET P from the vector v.
Argument type: |
P is a PARMSET, v is a VECTOR |
Returns type: |
VECTOR (returns v) |
%patchmat(Base,Source) — Replace NA’s in a matrix
Returns the matrix formed by patching over (replacing) any NA’s in the Base matrix with the corresponding entries from the Source matrix. Base and Source must have conforming dimensions.
Argument type: |
Any real-valued matrices (must have same dimensions) |
Returns type: |
Matrix of same type/dimensions as Base |
%patchzero(Base) — Replace NA’s in a matrix with zeros
Returns the matrix formed by patching over (replacing) any NA’s in the Base matrix with zeros.
Argument type: |
Any real-valued matrix |
Returns type: |
Matrix of same type/dimensions as Base |
%payment(a,r,n) — Required payments for an annuity
Returns the required payment for an annuity with principal a, interest rate r, and term n (a, r, and n are real values).
Argument type: |
Reals |
Returns type: |
Real |
%period(e) — Period within a panel set
For entry e in the current CALENDAR scheme returns the time period within either the individual (for panel data) or the day (for intra‑day data), or year for other date schemes.
Argument type: |
Integer (entry number or date expression) |
Returns type: |
Integer |
Returns an orthonormal matrix \({{\bf{A}}^ \bot }\) which forms a basis for the null space of \({\bf{A}}\). If \(m > n\) (that is, \({\bf{A}}\) has more rows than columns), this is a basis for the left null space, so \({{\bf{A}}^ \bot }^\prime {\bf{A}}{\rm{ = 0}}\). \({{\bf{A}}^ \bot }\) is \(m \times (m - n)\). If \(m < n\), it will be a basis for the right null space, \({\bf{A}}{{\bf{A}}^ \bot } = 0\), with \({{\bf{A}}^ \bot }\) being \(n \times (n - m)\).
Argument types: |
Rectangular array |
Returns type: |
Rectangular array |
%plus(A) — Non-negative (“plus”) values of an array
Returns positive elements of array, with negative values replaced with zeros: \({B_{ij}} = \max ({A_{ij}},0)\). Use %minus to get the minus version.
Argument types: |
Real or real Array |
Returns type: |
Same as argument |
%poisson(mean,k) — Cumulative Poisson probability
Returns \(P(x \le {\rm{k}}|\mu = {\rm{mean}})\) for a Poisson process with mean given by mean.
Argument types: |
Reals |
Returns type: |
Reals |
%poissonk(mean,k) — Poisson probability
Returns \(P(x = {\rm{k}}|\mu = {\rm{mean}})\) for a Poisson process with mean given by mean.
Argument types: |
Reals |
Returns type: |
Reals |
%polyadd(V1,V2) — Add two polynomials
Adds two polynomials, represented by the vectors V1 and V2, where an n+1 vector V represents an n-degree polynomial, in the form \({\bf{V}}{\rm{(1) + }}{\bf{V}}{\rm{(2)}}{x^1}{\rm{ + }} \ldots {\rm{ + }}{\bf{V}}{\rm{(n + 1)}}{x^n}\).
Argument types: |
VECTORS representing polynomials |
Returns type: |
VECTOR representing a polynomial |
%polycxroots(V) — Complex roots of a polynomial
Returns all roots of a polynomial represented as described under %POLYADD.
Argument types: |
VECTOR representing polynomial |
Returns type: |
VECTOR[COMPLEX] with the roots |
%polydiv(V1,V2,d) — Divide two polynomials
Divides polynomial V1 by polynomial V2 (where V1 and V2 are represented by VECTORS) up to degree d.
Argument types: |
V1 and V2 are VECTORS representing polynomials, d is an integer |
Returns type: |
VECTOR representing a polynomial |
%polymult(V1,V2) — Multiply two polynomials
Multiplies two polynomials, represented by the vectors V1 and V2.
Argument types: |
VECTORS representing polynomials |
Returns type: |
VECTOR representing a polynomial |
%polyroots(V) — Roots of a polynomial
Returns all real roots of a polynomial represented by the vector V.
Argument types: |
VECTOR representing polynomial |
Returns type: |
VECTOR with the roots. Note that it could have dimension 0. |
%polysub(V1,V2) — Subtract two polynomials
Subtracts two polynomials, represented by the vectors V1 and V2.
Argument types: |
VECTORS representing polynomials |
Returns type: |
VECTOR representing a polynomial |
%polyvalue(V,x) — Evaluate a polynomial
Returns the value of a polynomial (represented by the vector V) for a given value of x.
Argument types: |
V is a VECTOR representing a polynomial, x is real |
Returns type: |
Real |
%psddiag(S,B) — Diagonalizing a symmetric matrix
For the positive semi-definite SYMMETRIC S, returns a lower triangular matrix L such that \({\bf{LSL'}}\) is diagonal with 1’s and 0’s on the diagonal. B is used to determine when a calculation has produced a zero (to machine precision). If S is full rank, %PSDDIAG(S,B) will give \({\bf{LSL'}} = {\bf{I}}\).
Argument types: |
Symmetric (both should be positive semi-definite) |
Returns type: |
Rectangular |
%psdfactor(A,IX) — Factoring symmetric matrix
Returns the Cholesky factor of the positive semi-definite SYMMETRIC A with ordering given by the index list in the VECTOR[INTEGER]IX. The function %DECOMP(A) is equivalent to %PSDFACTOR(A,||1,2,...,n||)
Argument types: |
A is SYMMETRIC; IX is a VECT[INTEGER] |
Returns type: |
RECTANGULAR |
%psdinit(A,W) — Stationary covariance matrix
Returns a SYMMETRIC matrix V such that \({\bf{AVA'}} + {\bf{W}} = {\bf{V}}\). This is the stationary covariance matrix for a state-space model. %DLMINIT can solve a generalized problem with unit roots in the transition matrix A.
Argument types: |
A is \(N \times N\) Rectangular; W is \(N \times N\) Symmetric |
Returns type: |
SYMMETRIC |
%psubmat(A,startrow,startcol,B) — Copy values into an array
Copies information in matrix B into matrix A, starting at (startrow,startcol) of A. Copied values overwrite any existing values in the affected entries of A. A must be sufficiently large to allow all entries in B to be copied into existing dimensions of A.
Argument types: |
A and B are matrices, startrow and startcol are integers |
Returns type: |
None |
%psubvec(VA,position,VB) — Copy values into a vector
Puts the information in vector VB into vector VA, beginning at entry position of VA. The copied values will overwrite any existing values in the affected entries of VA. Note that VA must be sufficiently large enough to allow all entries of VB to be copied into the existing dimensions of VA.
Argument types: |
VA and VB are VECTORs, position is an integer |
Returns type: |
None |
%pt(V,t,X) — Filling a matrix of series
V is an array of SERIES, X should be an array of reals of the same size and shape. The elements at entry t of the series in V are filled with the corresponding values of vector X.
Argument types: |
V is an array of SERIES, t an integer, X an array of reals |
Returns type: |
None |
%qform(A,B) — Evaluate a quadratic form
Returns \({\bf{B'AB}}\), where B is either a VECTOR or an \(N \times 1\) or \(1 \times N\) RECTANGULAR array.
Argument types: |
A is a square matrix, B a VECTOR or 1-dimensional matrix. |
Returns type: |
Real |
%qformd(A,B) — Evaluate a quadratic form with a diagonal matrix
Returns \(\sum\limits_i {{A_i}B_i^2} \) where A and B are either conforming VECTORS or \(N \times 1\) or \(1 \times N\) RECTANGULAR arrays.
Argument types: |
Both VECTOR or 1-dimensional matrices. |
Returns type: |
Real |
%qformdpdf(D,x) — PDF of a diagonal quadratic form
Returns \(P({\bf{e'De}} < x)\) where D is a diagonal matrix (represented by a VECTOR).
Argument types: |
D is a VECTOR (diagonal elements of a matrix), x is real |
Returns type: |
Real |
%qforminv(S,v) — Inverse quadratic form
Returns \({\rm{v'}}{{\rm{S}}^{ - 1}}{\rm{v}}\)where S is positive semi-definite symmetric.
Argument types: |
S is SYMMETRIC, v is VECTOR |
Returns type: |
Real |
%qformpdf(A,x) — PDF of a quadratic form
Computes \(P({\bf{e'Ae}} < x)\) for a quadratic form in Normal(0,1) variables, where A is SYMMETRIC and e is i.i.d. This can be used for ratios of quadratic forms as well, since \(P({\bf{eAe}}/{\bf{eBe}} < x) = P({\bf{e'}}({\bf{A}} - x{\bf{B}}){\bf{e}} < 0)\).
Argument types: |
A is SYMMETRIC, x is real |
Returns type: |
Real |
%qrdecomp(A) — QR decomposition
Returns a VECTOR[RECTANGULAR] with two elements, the Q and R, respectively, of \({\bf{QR}} = {\bf{A}}\), where Q is orthonormal (\({\bf{QQ'}} = I\)) and R is upper triangular.
Argument types: |
Rectangular array, usually square but can have more rows and columns. |
Returns type: |
2-element Vector of Rectangular arrays, with Q as the first element and R the second. |
Returns draws from a Normal distribution with mean zero and standard deviation x. If you use this in an expression where the left side of the expression is an array that has already been declared and dimensioned (A=%RAN(1.0)), this will fill all elements of the array with random draws. Otherwise, it returns a single real value.
Argument types: |
Real |
Returns type: |
Real or array of reals, depending on context of expression. |
%ranbeta(a,b) — Random beta draw
Returns draws from a Beta distribution with shape parameters a and b. If you use this in an expression where the left side of the expression is an array that has already been declared and dimensioned (A=%RANBETA(3.0,5.0)), this will fill all elements of the array with random draws. Otherwise, it returns a single real value.
Argument types: |
Real. Both must be positive |
Returns type: |
Real or array of reals, depending on context of expression. |
%ranbranch(P) — Random selection of a branch
Returns a random integer from {1,..,dim(P)} where the elements of P are the (unscaled) probabilities of the choices.
Argument type: |
Array of reals |
Returns type: |
Integer |
%ranchisqr(nu) — Random chi-squared draw
Returns draws from a chi-squared distribution with nu degrees of freedom. If you use this in an expression where the left side of the expression is an array that has already been declared and dimensioned (A=%RANCHISQR(10)), this will fill all elements of the array with random draws. Otherwise, it returns a single real value.
Argument types: |
Real. nu>0 |
Returns type: |
Real or array of reals, depending on context of expression. |
%rancombo(n,k) — Random combination
Returns a VECTOR[INTEGER] which is a random combination (draw without replacement) of k items from {1,...,n}.
Argument types: |
n and k are integers, both positive |
Returns type: |
VECT[INTEGER] with dimension k |
%randirichlet(C) — Random Dirichlet
Returns a draw from a Dirichlet distribution. The Dirichlet is a generalization of the beta distribution. C is an n-vector of positive shape parameters. The return is an n-vector of probabilities (positive values summing to one).
Argument types: |
VECTOR of positive numbers |
Returns type: |
VECTOR with the same dimension as C |
%ranflip(p) — Random draw from Bernoulli distribution
Returns random draws (zeros or ones) from a Bernoulli distribution with probability p. If you use this in an expression where the left side of the expression is an array that has already been declared and dimensioned (A=%RANFLIP(0.6)), this will fill all elements of the array with random draws. Otherwise, it returns a single draw.
Argument types: |
Real, between 0 and 1 |
Returns type: |
Real or array of reals, depending on context of expression. |
Returns draws from a gamma distribution with shape parameter r. If you use this in an expression where the left side of the expression is an array that has already been declared and dimensioned (A=%RANGAMMA(10.0)), this will fill all elements of the array with random draws. Otherwise, it returns a single real value.
Argument types: |
Real. r>0 |
Returns type: |
Real or array of reals, depending on context of expression. |
%rangrid(X,F) — Random draw from approximate distribution
Returns a random draw from a distribution approximated by the grid. X is the vector of grid points (in increasing order, not necessarily equally spaced) and F is a corresponding vector of (relative) densities.
Argument types: |
VECTORs (should be same dimension) |
Returns type: |
Real |
%raninteger(l,u) — Random integer
Returns an integer drawn randomly from \([l,u]\).
Argument types: |
Integer |
Returns type: |
Integer |
%ranks(A) — Ranks of the elements of an array
Returns an array with the same size and type as A with the ranks of the corresponding elements of A. Ranks are in increasing order beginning with 1. Ties are assigned the average of the covered ranks.
Argument type: |
Real array |
Returns type: |
Real array matching the argument |
%ranlogkernel() — Log kernel density from recent draw
Returns the log kernel density from the most recent draw of random numbers.
Argument types: |
None |
Returns type: |
Real |
%ranlognormal(mean,sd) — Draws from log Normal density
Returns draws from a log Normal distribution with mean mean and standard deviation sd. (Note that these are moments of the log Normal itself, not of the underlying Normal density). If you use this in an expression where the left side of the expression is an array that has already been declared and dimensioned (A=%RANLOGNORMAL(1.0,0.5)), this will fill all elements of the array with random draws. Otherwise, it returns a single real value. This was added with Version 9.1.
Argument types: |
Real |
Returns type: |
Real or array of reals, depending on context of expression |
%ranmat(m,n) — Rectangular matrix of random normal draws
Returns an \(m \times n\) matrix of random draws from a standard Normal(0,1) distribution.
Argument types: |
Integer |
Returns type: |
\(m \times n\) RECTANGULAR |
%ranmvkron(FS,FX) — Draw from multivariate Normal regression
Returns a draw from a multivariate Normal regression. Inputs are a factor of the regression \(\Sigma\) matrix (FS) and a factor of the \({\left( {{\bf{X'X}}} \right)^{ - 1}}\) matrix (FX).
Argument types: |
FS is \(N \times N\), FX is \(k \times k\) |
Returns type: |
\(N \times k\) RECTANGULAR |
%ranmvkroncmom(C,H,P,M) — MV normal regression, CMOM variant
Returns a draw from a multivariate Normal regression given a cross-moment matrix C, regression precision matrix (H), prior precision matrix (P) and prior mean (M).
Argument types: |
C is SYMMETRIC, H is SYMMETRIC, P is SYMMETRIC, M is a vector with the stacked coefficients, or a RECTANGULAR with equation coefficients in columns. |
Returns type: |
Matrix matching the structure of M. |
%ranmvnormal(F) — Draw from random multivariate Normal
Returns a draw from a multivariate Normal with mean 0 and covariance matrix \({\bf{FF'}}\), that is, the argument provides a factor of the covariance matrix.
Argument types: |
square RECTANGULAR |
Returns type: |
VECTOR with the same number of rows as F. |
%ranmvpost(P1,M1,P2,M2) — Draw from a MV Normal posterior
Returns a draw from a multivariate Normal posterior combining multivariate Normals, with the given precisions (P1 and P2) and means (M1 and M2).
Argument types: |
P1 and P2 are SYMMETRIC, M1 and M2 are VECTOR. The dimensions need to match. |
Returns type: |
VECTOR with the dimensions of the M's. |
%ranmvpostcmom(C,h,P,M) — MV Normal posterior, CMOM variant
Returns a draw from a multivariate Normal posterior combining multivariate Normals, given a cross-moment matrix C, a regression precision (h), prior precision matrix (P) and prior mean (M).
Argument types: |
C is SYMMETRIC, h is real, P is SYMMETRIC, M is VECTOR |
Returns type: |
VECTOR with the dimensions of M. |
%ranmvposthb(H,Hb) — Draw from a MV Normal posterior
Returns a draw from a multivariate Normal posterior given precision matrix H and precision times mean vector Hb. (In many applications, it's easier to compute Hb than the mean itself).
Argument types: |
H is SYMMETRIC, Hb a VECTOR with the same dimension. |
Returns type: |
VECTOR with the same dimension as Hb. |
%ranmvt(F,nu) — Random draw from multivariate t
Returns a random draw from a multivariate t distribution, where nu is the degrees of freedom and F is a factor of the covariance matrix (the covariance matrix is \({\bf{FF'}}\)).
Argument types: |
F is a rectangular array, nu real |
Returns type: |
SYMMETRIC with the dimensions of F |
%ranpermute(n) — Random permutation
Returns a VECTOR[INTEGER] which is a random permutation (reordering) of {1,...,n}.
Argument types: |
Integer |
Returns type: |
VECTOR[INTEGER] of dimension n |
Returns random signs (only values +1 and -1) drawn with equal probability. If you use this in an expression where the left side of the expression is an array that has already been declared and dimensioned (A=%RANSIGN(10.0)), this will fill all elements of the array with random draws. Otherwise, it returns a single real value.
Argument types: |
None |
Returns type: |
Real or array of reals, depending on context of expression. |
%ransphere(n) — Random draw on the unit sphere
Returns a draw made uniformly from the unit sphere in n dimensions.
Argument types: |
Integer |
Returns type: |
VECTOR of dimension n |
%ransvksc(u,mean,var) — Draws for log variance in stochastic volatility model
Returns a draw from the posterior for the log variance generated by combining a normal on the log variance (from adjoining observations) with an inverse gamma of the variance itself (from the observation). This is a step in a Gibbs sampling algorithm where the variance is drawn for a specific entry conditional on the variances at all other entries. It is based upon the rejection method of Kim, Shepard and Chib(1998) with refinements to provide better behavior. u is the residual, assumed to be distributed N(0,h). Conditioning on adjacent observations gives a Normal distribution for log h, where mean is the mean and var is the variance of that distribution. Note that these are moments of the log Normal, not of the underlying Normal density, and note again that it returns a draw for the log of the variance. This was added with Version 9.1.
Argument types: |
Real |
Returns type: |
Real |
%rant(d) — Random draw from Student t distribution
Returns a random draw from a t distribution with d degrees of freedom.
Argument types: |
Real |
Returns type: |
Real, unless in the specific form A=%RANT(D), where A is a real array with dimensions already set, in which case a joint multivariate t draw is placed into the elements of A. |
%rantruncate(mu,sig,lower,upper) — Random draw from truncated Normal
Returns a draw from a Normal with mean mu and standard deviation sig truncated to the interval [lower,upper]. lower or upper can be %NA to indicate an interval unbounded in that direction. If you use this in an expression where the left side of the expression is an array that has already been declared and dimensioned (A=%RANTRUNCATE(...)), this will fill all elements of the array with random draws. Otherwise, it returns a single real value.
Argument types: |
Real |
Returns type: |
Real or array of reals, depending on context of expression. |
%ranwishart(n,r) — Random Wishart matrix
Returns a draw from a \(n \times n\) Wishart distribution with identity covariance matrix and shape parameter r.
Argument types: |
n is integer, r is a positive real number greater than n |
Returns type: |
SYMMETRIC |
%ranwishartf(F,r) — Random Wishart with given covariance matrix
Returns a draw from a Wishart distribution with covariance matrix \({\bf{F'F}}\) and shape parameter r.
Argument types: |
F is Rectangular, r is a positive real number greater than dim(F) |
Returns type: |
SYMMETRIC |
%ranwisharti(F,r) — Random inverse Wishart
Returns a draw from an inverse Wishart distribution with covariance matrix \({\bf{F'F}}\) and shape parameter r.
Argument types: |
F is Rectangular, r is a positive real number greater than dim(F) |
Returns type: |
SYMMETRIC |
%ratsversion() — Get version number of RATS
This returns the version number of the copy of RATS you are using.
Argument type: |
None |
Returns type: |
Real |
%real(z) — Get real part of complex number
Returns the real part of a complex number z.
Argument type: |
Complex |
Returns type: |
Real |
%regend() — Return regression ending entry
Returns the ending entry/date of the most recently completed regression or estimation.
Argument type: |
None |
Returns type: |
Integer |
%reglabels() — Get regression labels
Returns a VECTOR[STRINGS] with the output labels from the regressors or non-linear parameters from the most recent estimation.
Argument types: |
None |
Returns type: |
VECTOR[STRINGS] |
%reglist() — Get regressor list
Returns the regressor list from the most recent regression as a coded VECT[INTEGER]. You can use %RLADDONE and related functions to modify the regressor list.
Argument types: |
None |
Returns type: |
Regressor list (coded VECT[INTEGER]) |
%regload(R) — Reload saved regression
Loads into memory from R a regression saved using %REGSAVE(). Subsequent instructions such as TEST, other hypothesis test operations, and PRJ will apply to this regression.
Argument type: |
VECT[INTEGER] (with coded information from %REGSAVE()) |
Returns type: |
None |
%regsave() — Save a regression
Saves the most recent regression, as a coded VECT[INTEGER].
Argument type: |
None |
Returns type: |
VECT[INTEGER] (with coded information) |
%regsetrange(start,end) — Reset regression range information
Sets the recoverable regression range (used by %REGSTART() and %REGEND()) to the start and end values.
Argument type: |
Integer |
Returns type: |
None |
%regstart() — Return regression starting entry
Returns the starting entry/date of the most recently completed regression or estimation.
Argument type: |
None |
Returns type: |
Integer |
%regtable() — Returns the "table" for the most recent regression
Returns a RECTANGULAR[INTEGER] array listing the explanatory variables in the most recent regression. The array has dimensions 2 × number of explanatory variables. Row one lists the series numbers of the explanatory variables, row two lists the lags. Use 0 for equation to get the table of variables in the most recent regression.
Argument type: |
None |
Returns type: |
\(2 \times k\) RECT[INTEGER] |
%reshape(A,r,c) — Change the dimensions of an array
Returns the contents of A with dimensions changed (usually from rectangular to vector or vice versa). r and c provide the number of rows and columns, respectively, in the new array. See also %VEC and %VECTORECT.
Argument types: |
A is an array, r and c are integers |
Returns type: |
\(r \times c\) RECTANGULAR |
Returns the rightmost n characters from the string s. Use the %MID function to get the rightmost characters from a known position within the string.
Argument types: |
s is a string or label, n is integer |
Returns type: |
String |
%rladdlag(R,S,L) — Add a lagged regressor to a regressor list
Adds lag L of series S to an existing regressor list R. See also %RLADDONE.
Argument types: |
R is a regressor list (coded VECT[INTEGER]), S is a SERIES, and L is an integer lag number |
Returns type: |
Regressor list (coded VECT[INTEGER]) |
%rladdlaglist(R,S,list) — Add list of lags to a regressor list
Adds the lags included in list for series S to regressor list R. This is identical to %RLADDLAG(), except list is a list of lag numbers (as a VECT[INTEGER]), rather than a single lag.
Argument types: |
R is a regressor list (coded VECT[INTEGER]), S is a SERIES, and list is a VECT[INTEGER] with a list of lags. |
Returns type: |
Regressor list (coded VECT[INTEGER]) |
%rladdone(R,S) — Add a regressor to a regressor list
Adds a series S (unlagged) to existing regressor list R.
Argument types: |
R is a regressor list (coded VECT[INTEGER]), S is a SERIES |
Returns type: |
Regressor list (coded VECT[INTEGER]) |
%rlconcat(R1,R2) — Concatenate two regressor lists
Concatenates two regressor lists into a single list.
Argument types: |
Regressor lists (coded VECT[INTEGER]) |
Returns type: |
Regressor list (coded VECT[INTEGER]) |
%rlcount(R) — Number of regressors in list
Returns the total number of variables in a regressor list once lag fields are expanded.
Argument type: |
Regressor list (coded VECT[INTEGER]) |
Returns type: |
Integer |
%rlempty( ) — Empty Regressor List
Returns an empty regressor list; this is identical to a VEC[INT] with dimension 0.
Argument types: |
None |
Returns type: |
Regressor list (coded as an empty VECT[INTEGER]) |
%rlfromeqn(eqn) — Get a regressor list from an equation
Returns the regressor list from created from the explanatory variables in EQUATIONeqn.
Argument types: |
EQUATION |
Returns type: |
Regressor list (coded as a VECT[INTEGER]) |
%rlfromtable(table) — Get a regressor list from a regression table
Returns a regressor list from a regression table (such as generated by %EQNTABLE or %INSTTABLE).
Argument types: |
table is a regression table—a \(2 \times n\) RECT[INTEGER] where each column in the array represents one series{lag} pair, with the |
Returns type: |
Regressor list (coded as a VECT[INTEGER]) |
%rlverify(R) — Verify a regressor list
Verifies that R forms a valid regressor list. Useful when creating your own regressor lists or modifying existing regressor lists.
Argument type: |
Regressor list (coded VECT[INTEGER]) |
Returns type: |
Integer: 1 if a regressor list is good, 0 if not. |
Returns x rounded to n decimal places. Negative values of n round to positive powers of 10, that is, %round(1536,-2)=1500.
Argument type: |
x is real, n is integer |
Returns type: |
Real |
%rows(A) — Number of rows in a matrix
Returns the number of rows in a matrix A.
Argument type: |
Any type of matrix |
Returns type: |
Integer |
%rsscmom(C,V) — Residual sum of squares from a cross product
This returns the residual sum of squares given a (properly structured) cross moment matrix C and a coefficient vector V.
Argument type: |
C is SYMMETRIC \((K + 1) \times (K + 1)\) , V is VECTOR (\(K\)) where \(K\) is the number of regressors. |
Returns type: |
Real |
Returns the series handle for the series whose name is the label L. If such a series doesn’t yet exist, it will be created. For instance,
SET %S("TREND"+I) = T^I
will, if I is 2, create series TREND2 as a squared trend.
Argument types: |
Label variable or expression |
Returns type: |
Series handle (integer) |
%scalar(A) — Get first element of a matrix
Returns A(1,1) (or A(1) for a VECTOR).
Argument types: |
A can be any real-valued array |
Returns type: |
Real |
%scol(S,col) — Series from Column in Array of Series
Returns a VECTOR[INTEGER] with the series handles for a column of a matrix of SERIES.
Argument types: |
S is an array of SERIES, col is an integer |
Returns type: |
VECTOR[INTEGER] with series handles |
Returns the secant of x.
Argument type: |
Real |
Returns type: |
Real |
%selseries() — Return series selected in the Series List
Returns a VECT[INTEGER] with the handles of the series currently selected in the Series List window.
Argument type: |
None |
Returns type: |
VECTOR[INTEGER] of series handles |
%seq(m,n) — Creates an Integer Sequence
Returns a VECTOR[INTEGER] with the sequence from m to n which can be in either order.
Argument types: |
integers |
Returns type: |
VECTOR[INTEGER] |
%seqa(start,incr,n) — Creates a Vector with a Real-Valued Sequence
Returns a VECTOR of dimension n filled with the sequence starting with start and incremented by incr for each subsequent entry. See also %SEQRANGE.
Argument types: |
lower and upper are reals, n an integer |
Returns type: |
VECTOR |
%seqrange(lower,upper,n) — Creates a Vector with a Real-Valued Sequence
Returns a VECTOR of dimension n filled with a sequence of constant-magnitude increments from lower to upper. See also %SEQA.
Argument types: |
lower and upper are reals, n an integer |
Returns type: |
VECTOR |
%seriesentry(series,entry) — Panel data series entry references
When working with panel data, references to a series entry in a SET or FRML command will return “NA” (missing value code) if the entry referenced is in a different individual than the entry being set or evaluated—this is done to prevent lag computations from “lagging across” individuals. If you want the actual value of the series entry, regardless of whether it is in the current individual, use %seriesentry(series,entry) rather than just series(entry).
Argument types: |
series is a SERIES, entry an integer (entry number) |
Returns type: |
Real |
%sigmacmom(C,B) — Sum of squared error matrix from cross product
This returns the matrix with the sum of squared multivariate errors from a multivariate regression (same explanatory variables in each), given a (properly structured) cross moment matrix C and a coefficient matrix B.
Argument types: |
C is SYMMETRIC \((K + N) \times (K + N)\). B is RECTANGULAR \(N \times K\), where N is the number of equations and K is the number of coefficients per equation. |
Returns type: |
Symmetric \(N \times N\) |
Returns 1 if x is positive, –1 if it’s negative and 0 if it’s zero.
Argument type: |
Real |
Returns type: |
Real |
Returns the sine of x, where x is in radians. If x is a matrix, transforms each element.
Argument type: |
Real, or real-valued matrix. |
Returns type: |
Same as argument |
Returns the hyperbolic sine of its argument:\(\left( {\exp (x) - \exp ( - x)} \right)/2\)
Argument type: |
Real |
Returns type: |
Real |
Returns the total number of elements in an array
Argument types: |
Any matrix of any data type |
Returns type: |
Integer |
%skewnn(n) — Skew-symmetric mapping matrix
Returns a matrix operator which will maps the vech of an \((n - 1) \times (n - 1)\) lower triangle to the vec of an \(n \times n\) skew-symmetric matrix which has the lower triangle below its diagonal, and minus the transpose of the lower triangle above its diagonal. Note that this creates a matrix to do the mapping—it doesn't do the mapping itself. This was added with version 9.2.
Argument types: |
Integer |
Returns type: |
RECTANGULAR (dimensions \({n^2} \times n(n - 1)/2\)) |
%slike(template) — Series Handles by Template
Returns a VECT[INTEGER] of the series handles matching a name template.
Argument types: |
label or string, supports # or * as wildcards |
Returns type: |
VECTOR[INTEGER] of series handles |
%solve(A,b) — Solves linear equations
Returns solution x of Ax = b. A is an \(N \times N\) real matrix, b is an N-element vector.
Argument types: |
A is a square matrix (RECTANGULAR or SYMMETRIC), b is a vector |
Returns type: |
Vector |
Returns an array which has the same size and shape as A, but with the elements of A sorted in increasing order. If A is RECTANGULAR, the sorted values are stored by columns.
Argument types: |
Real-value matrix of any form |
Returns type: |
Matrix with the same dimensions and form as A |
%sortc(A,c) — Sort on a column
Returns a copy of array A sorted based upon the values in column c. This normally sorts in increasing order. Make c negative to sort on a column in decreasing order.
Argument types: |
A is RECTANGULAR, c is an integer |
Returns type: |
Rectangular |
%sortcl(A,list) — Sort on multiple columns
Returns a copy of array A sorted on the values of the columns in the list. list should be a VECTOR[INTEGER], or an “in-line matrix” of the form ||col1,...,coln||. The first column listed is the primary key, the others are used in order to break ties. Use the negative of a column number to have that column sort in decreasing order.
Argument types: |
A is RECTANGULAR, list is VECT[INTEGER] |
Returns type: |
Rectangular |
sqrt(x),%sqrt(A) — Square root function
Square root function. For %SQRT, this returns an array with the same dimensions and type as A with each element replaced by its square root. For SQRT, it's the square root.
Argument types: |
Real or Real array |
Returns type: |
Real or an array of the same type and dimension as A |
%srow(S,row) — Series from Row in Array of Series
Returns a VECTOR[INTEGER] with the series handles for a row of a matrix of SERIES.
Argument types: |
S is an array of SERIES, row is an integer |
Returns type: |
VECTOR[INTEGER] with series handles |
%stereo(V) — Stereo projection
Returns the conversion of a general \(n-1\) element vector to an n vector on the unit sphere using the stereo projection.
Argument types: |
Vector |
Returns type: |
Vector (dimension one greater than V) |
%strcmp(s1,s2) — Compare two strings
Compares two strings. Returns 0 if they are identical, 1 if s1>s2 in lexicographical order, and –1 if s1<s2. Note that the return for equal strings is 0, not 1.
Argument types: |
Strings |
Returns type: |
Integer |
%strcmpnc(s1,s2) — Compare two strings disregarding case
Compares two strings without regard to case. Returns 0 if they are identical, 1 if s1>s2 in lexicographical order, and –1 if s1<s2. Note that the return for equal strings is 0, not 1.
Argument types: |
Strings |
Returns type: |
Integer |
%strescape(s,chars,escape) - Escape special characters
Returns a copy of s with any character from chars escaped by prefixing with escape. For instance, %strescape("US$Exch","$","\") will return the string "US\$Exch"
Argument types: |
Strings |
Returns type: |
String |
%strfind(s,f) - Find substring
Searchs string s for string f, returning the position in s if found and zero otherwise.
Argument types: |
Strings |
Returns type: |
Integer |
%string(n) — Convert integer value to a string
Returns the character string corresponding to the integer n (for instance, %STRING(110) returns "110").
Argument type: |
Integer |
Returns type: |
String |
%strlen(s) — Returns the length of a string
Returns the length (number of characters) of the string s.
Argument type: |
String |
Returns type: |
Integer |
%strlower(s) — Convert string to lower case
Returns a copy of the string s with all characters in lower case.
Argument type: |
String |
Returns type: |
String |
%strmatch(s,pattern) — Test string for pattern match
Tests the string s for a match with pattern, returning 1 for a match and 0 for a failure to match. The pattern can include the following “wildcard” characters: * for matching 0 or more characters, ? for matching exactly one character, # for matching exactly one digit. Any other character must be an exact match (case is ignored for letters). For example, the pattern "*###" matches any string ending with three digits.
Argument types: |
Strings |
Returns type: |
Integer |
%strrep(s,n) — Repeats a string
Returns a string that consists of the input string s repeated n times.
Argument types: |
String, integer |
Returns type: |
String |
Returns a copy of a string with leading and trailing spaces and quotes removed.
Argument type: |
String |
Returns type: |
String |
%strupper(s) — Convert string to upper case
Returns a copy of the string s with all characters in upper case.
Argument type: |
String |
Returns type: |
String |
%strval(x,pc) — String showing a numerical value
This returns a string that displays the real value x in the picture code pc. For instance, %strval(11.9,"*.##") will return the string 11.90.
Argument types: |
Real, string |
Returns type: |
String |
%sum(A) — Sum of array elements
Returns the sum of all elements in the array A. For SYMMETRIC arrays, it computes the sum of the lower triangle only. This can also be applied to SERIES variables, in which case the sum will be computed over the defined range of the series, or the range set by an SMPL instruction. Any missing observations will be omitted from the computation.
Argument type: |
Real array or SERIES |
Returns type: |
Real |
%sumc(A) — Sums columns of an array
This computes the sums of each column in an array. For an \(M \times N\) array, this returns an \(N \times 1\) array where element j contains the sum of all the elements in column j of the array A. Any missing observations will be omitted from the computation.
Argument types: |
RECTANGULAR, can be any dimensions |
Returns type: |
Vector with dimension equal to columns of A |
%sumr(A) — Sums rows of an array
This computes the sums of each row in an array. For an \(M \times N\) array, this returns an \(M \times 1\) array where element i contains the sum of all the elements in row i of the array A. Any missing observations will be omitted from the computation.
Argument types: |
RECTANGULAR, can be any dimensions |
Returns type: |
Vector with dimension equal to rows of A |
%svdecomp(A) — Singular Value Decomposition
Returns a VECTOR[RECTANGULAR] with three elements, the U, W and V, respectively, of \({\bf{A}} = {\bf{U}}[diag({\bf{W}})]{\bf{V'}}\), where U and V are column orthonormal, and W is the vector of diagonal elements in the SVD. The singular values will be sorted in descending order.
Argument types: |
RECTANGULAR, can be any dimensions |
Returns type: |
VECT[RECTANGULAR], with three elements in the vector |
%sweep(A,k) — Sweep function of a matrix
Returns the result of sweeping matrix A on pivot k. A must be a square RECT or SYMM array. k is any integer from 1 to N. A is an \(N \times N\) matrix.
Argument types: |
A is SYMMETRIC or square RECTANGULAR, k is integer |
Returns type: |
Square RECTANGULAR (even if A is SYMMETRIC) |
%sweeplist(A,list) — Sweep function of a matrix
Returns the result of sweeping matrix A on the pivots given by the VECTOR[INTEGER] list. The sweep function is described with %SWEEP.
Argument types: |
A is SYMMETRIC or square RECTANGULAR, list is VECTOR[INTEGER] |
Returns type: |
Square RECTANGULAR (even if A is SYMMETRIC) |
%sweeptop(A,k) — Sweep function of a matrix
Returns the result of sweeping matrix A on all pivots 1,...,k. The sweep function is described under %SWEEP.
Argument types: |
A is SYMMETRIC or square RECTANGULAR, k is integer |
Returns type: |
Square RECTANGULAR (even if A is SYMMETRIC) |
%symmcol(n) — Get column number from packed position
Returns the column number corresponding to element n in a packed symmetric or packed lower triangular matrix.
Argument type: |
Integer (≥1) |
Returns type: |
Integer |
%symmpos(row,col) — Get position of row,col in packed array
Returns the position in a packed symmetric or lower triangular matrix for a given row and column in the unpacked matrix.
Argument type: |
Integer (≥1) |
Returns type: |
Integer |
%symmrow(n) — Get row number from packed position
Returns the row number corresponding to element n in a packed symmetric matrix or lower triangular matrix.
Argument type: |
Integer (≥1) |
Returns type: |
Integer |
%tablediff(table1,table2) — Find differences in tables
Finds the difference between two tables, returning a table with all variables from table1 which are not in table2.
Argument types: |
Regression tables (\(2 \times n\) RECT[INTEGER]) |
Returns type: |
Regression table |
%tableextract(table, list) — Extract subtable
Returns a subtable with the items in the listed positions of the argument table. list would usually be generated using %TABLEFINDALL or %TABLEFINDMISS.
Argument types: |
table is a regression table (\(2 \times n\) RECT[INTEGER]) list is s VECT[INTEGER] with positions |
Returns type: |
regression table |
%tablefind(table,series,lag) — Locate a single variable in a table
For series series and lag lag, this locates the requested variable (series{lag}) in regression table table. It returns the position of the variable, or zero if it’s not present.
Argument types: |
table is a regression table (\(2 \times n\) RECT[INTEGER]) series is a SERIES, lag is an integer lag number |
Returns type: |
VECTOR[INTEGER]. Could be dimension 0. |
%tablefindall(table1,table2) — Locate variables in a table
Locates in table1 the series,lag pairs from table2. It returns a VECTOR[INTEGER] with the positions of the regressors in table1 that also appeared in table2.
Argument types: |
Regression tables (\(2 \times n\) RECT[INTEGER]) |
Returns type: |
VECTOR[INTEGER] (position numbers) |
%tablefindlags(table,s) — Locate lags of a series in a table
Returns the list of lags of series s which appear in table.
Argument types: |
table is a regression table (\(2 \times n\) RECT[INTEGER]) s is a SERIES |
Returns type: |
VECTOR[INTEGER]. Could be dimension 0. |
%tablefindmiss(table1,table2) — Locates variables missing from table
Returns a VECTOR[INTEGER] which shows the positions of variables in table1 that are not also in table2.
Argument types: |
Regression tables (\(2 \times n\) RECT[INTEGER]) |
Returns type: |
VECTOR[INTEGER] |
%tablefromrl(R) — Create table from regressor list
Creates a regressor table from a regressor list.
Argument type: |
Regressor list (VECT[INTEGER]) |
Returns type: |
Regression table (\(2 \times n\) RECT[INTEGER]) |
%tablemerge(table1,table2) — Merge two regressor tables
Merges two regression tables into a single regression table. Duplicates are included just once.
Argument types: |
Regression tables (\(2 \times n\) RECT[INTEGER]) |
Returns type: |
Regression table |
%tableunique(table) — Locate series in table
Returns a table which includes just one entry for each series which appears in table, showing only lag zero (no matter which lags appear in the table).
Argument type: |
Regression table (\(2 \times n\) RECT[INTEGER]) |
Returns type: |
Regression table |
Returns the tangent of x, where x is in radians. If applied to a matrix, all elements are transformed.
Argument type: |
Real or real-valued matrix |
Returns type: |
Same as argument |
Returns the hyperbolic tangent of its argument:
\(\frac{{\exp (x) - \exp ( - x)}}{{\exp (x) + \exp ( - x)}}\)
Argument types: |
Real |
Returns type: |
Real |
%tcdf(x,d) — CDF for t distribution
Returns the CDF at x for a t distribution, with degrees of freedom d.
Argument types: |
Real. d must be positive |
Returns type: |
Real |
%tcdfnc(x,d,nc) — CDF for non-central t distribution
Returns the CDF at x for a non-central t distribution, with degrees of freedom d, and non-centrality parameter nc.
Argument types: |
Real. d must be positive |
Returns type: |
Real |
Returns the density function at x for a t distribution with d degrees of freedom.
Argument types: |
Real. d must be positive |
Returns type: |
Real |
%tdensitync(x,d,nc) — Non-central t density
Returns the density function at x for a non-central t distribution, with degrees of freedom d, and non-centrality parameter nc.
Argument types: |
Real. d must be positive |
Returns type: |
Real |
%testdiff(base,test) — Test difference of two arrays
Returns the convergence criterion used by the non-linear estimation instructions applied to the VECTOR's base and test. The formula is:
\(\mathop {\max }\limits_i \left\{ {\,\min \left[ {\left| {\frac{{tes{t_i} - bas{e_i}}}{{bas{e_i}}}} \right|,\left| {tes{t_i} - bas{e_i}} \right|} \right]} \right\}\)
Argument type: |
Real vectors of same dimension |
Returns type: |
Real |
Returns the entry number in the current CALENDAR scheme which covers today’s date (that is, the system date of the computer at run time).
Argument type: |
None |
Returns type: |
Integer |
Returns the transpose of matrix A.
Argument type: |
Real \(M \times N\) Array |
Returns type: |
Real \(N \times M\) Array |
Returns the trace of a SYMMETRIC or \(N \times N\) matrix A.
Argument type: |
Symmetric or square Rectangular array |
Returns type: |
Real |
%tradeday(e,dow) — Number of trading day occurrences
Returns the number of occurrences of weekday dow (Monday=1, Tuesday=2, …, Sunday=7) in entry e in the current CALENDAR scheme. For instance, January 2010 started on a Friday, and so has five of each of Friday, Saturday and Sunday, and four of the other days. With a monthly calendar, %TRADEDAY(2010:1,1) (number of Mondays) is 4 while %TRADEDAY(2010:1,5) (number of Fridays) is 5.
Argument types: |
Integer |
Returns type: |
Integer |
%trigamma(x) — Trigamma function
Returns the trigamma function of x. The trigamma is the second derivative of \(\log {\rm{ }}\Gamma (x)\), and is usually denoted \(\psi '(x)\). (\(\psi (x)\) is the digamma function).
Argument types: |
Real (positive) |
Returns type: |
Real |
Returns \(\left| x \right|\) if y is positive, \(-\left| x \right|\) if y is negative, 0 if y is zero.
Argument types: |
Real |
Returns type: |
Real |
%ttest(x,r) — Two-tailed t test
Returns the two‑tailed probability of a t with r degrees of freedom, that is, the probability that a t-distributed random variable with r degrees of freedom exceeds x in absolute value.
Argument types: |
Real |
Returns type: |
Real |
%uniform(l,u) — Random draw from a uniform distribution
Returns a random draw from a uniform distribution ranging from (the real values) l to u. If you use this in an expression where the target of an assignment is an array (that is, something like A=%UNIFORM(0.0,1.0)), this will fill all elements of the array with (independent) random draws. Otherwise, it returns a single real value.
Argument types: |
Real |
Returns type: |
Array of reals or single real value, depending on the target. |
Returns the unit circle value \(\exp (ix)\).
Argument type: |
Real |
Returns type: |
Complex |
%unit2(n,T) — Unit circle value for \(2\pi (n-1)/T\)
Returns the unit circle value \(\exp \left( {2\pi i(n - 1)/T} \right)\).
Argument type: |
Integers |
Returns type: |
Complex |
%unitfn(unit) — Get file name for I/O unit
Returns the filename associated with the I/O unit whose name is given by the string unit. For example, if you have done
open data mydata.xls
then %unitfn("data") would return "mydata.xls".
Argument type: |
String (unit name) |
Returns type: |
String |
%unitfnext(unit) — Get extension of file name for I/O unit
Returns the extension (characters after the last period) of the filename associated with the I/O unit whose name is given by the string unit. For example, if you have done
open data mydata.xls
then %unitfnext("data") would return "xls".
Argument type: |
String (unit name) |
Returns type: |
String |
%unitfnpath(unit) — Get path of file for I/O unit
Returns the path name (not including the filename) of the file associated with the I/O unit whose name is given by the string unit. For example, if you have done
open data c:\rats\projects\mydata.xls
then %unitfnpath("data") would return "c:\rats\projects".
Argument type: |
String (unit name) |
Returns type: |
String |
%unitfnroot(unit) — Get root name of file for I/O unit
Returns the main part of the filename, not including the last period or any extension, for the file associated with the I/O unit whose name is given by the string unit. For example, if you have done
open data mydata.xls
then %unitfnroot("data") would return "mydata".
Argument type: |
String (unit name) |
Returns type: |
String |
%unitv(n,i) — Generating a unit vector
This generates the ith unit n-vector—a vector with n elements, with element i set to one, and the other elements set to zero.
Argument types: |
Integer |
Returns type: |
Vector |
%valid( x ) — Check for valid (non-missing) value
Returns a value of 1 if and only if (all elements of) x are not the system missing value (%NA). In all other cases, it returns a zero. Use it to test for missing values. If applied to a matrix, all elements must be valid to get a 1 return value.
Argument type: |
Real or Real-valued matrix |
Returns type: |
Real |
Returns the value of a number coded into the string s. %value("13.5") is the real number 13.5.
Argument type: |
String |
Returns type: |
Real |
%vec(A) — Vectorizing an array
Returns a VECTOR containing the values of array A. If A is RECTANGULAR, A is stripped out by columns; if SYMMETRIC or PACKED, by the rows of the lower triangle.
Argument type: |
Any array of reals |
Returns type: |
VECTOR |
%vech(S) — Vectorizing a SYMMETRIC
Returns a VECTOR containing the values of array S. If S is SYMMETRIC or PACKED, the target is created by running through the the rows of the lower triangle. (This is actually the same as %VEC, but since stringing out a symmetric matrix by lower triangle is generally referred to as a "vech" operation, we've added a function by that name).
Argument type: |
Any array of reals |
Returns type: |
VECTOR |
%vectorect(V,r) — Create a RECTANGULAR from a Vector
Reformats the values of the vector V into a RECTANGULAR with r rows. Elements 1 through r of V go into column 1 of the output array, elements r+1 through 2r go into column 2, and so on. This is the “inverse” of the %VEC function applied to a RECTANGULAR array with r rows.
Argument type: |
VECTOR |
Returns type: |
RECTANGULAR |
%vectosymm(V,r) — Create a SYMMETRIC from a Vector
Reformats the values of the vector V into a SYMMETRIC with r rows, filling the symmetric array row by row. This is the “inverse” of the %VEC function applied to a SYMMETRIC with r rows.
Argument type: |
VECTOR |
Returns type: |
SYMMETRIC |
%weekday(e) — Day of week of entry e
Returns the day of the week (1=Monday through 7=Sunday) of entry e in the current CALENDAR scheme.
Argument type: |
Integer (entry number or date expression) |
Returns type: |
Integer |
%wfractiles(A,W,F) — Compute fractiles
Returns a VECTOR with fractiles (quantiles) of the elements of the array A with (un-normalized) weights provided by W. W needs to have the same shape as A. The list of desired fractiles are provided by the VECTOR F.
Argument types: |
A and W are real arrays, F is a Vector |
Returns type: |
Vector with dimensions of F |
%xcol(A,i) — Extract column of a matrix
Extracts column i from matrix A.
Argument types: |
A is a (real-valued) matrix, i is an integer |
Returns type: |
Real matrix (\(N \times 1\)) |
%xdiag(A) — Extract diagonal from a matrix
Extracts the diagonal from matrix A.
Argument types: |
A is a (real-valued) matrix |
Returns type: |
Real matrix (\(N \times 1\)) |
Extracts row i from matrix A.
Argument types: |
A is a (real-valued) matrix, i is an integer |
Returns type: |
Real matrix (\(1 \times N\)) |
%xsubmat(A,startrow,endrow,startcol,endcol) — Extract a matrix
This extracts an \(M \times N\) rectangular matrix from matrix A. For example, to extract the upper-left \(4 \times 4\) elements of A, you would use %xsubmat(A,1,4,1,4).
Argument types: |
A is a (real-valued) matrix, others are integers |
Returns type: |
Real matrix |
%xsubvec(V,startrow,endrow) — Extract a vector
Extracts elements startrow through endrow of vector V.
Argument types: |
V is a Vector, startrow and endrow are integers |
Returns type: |
Real matrix |
%xt(V,t) — Extract from an array of SERIES
From an array of SERIES, it extracts the entries t of the component series to form an array with the same size and shape as V.
Argument types: |
V is an array of SERIES, t is an integer. |
Returns type: |
Real matrix (same dimensions for reals as V is for SERIES) |
Returns the calendar year corresponding to entry e in the current CALENDAR scheme.
Argument type: |
Integer |
Returns type: |
Integer |
%ymdaycount(y,m) — Number of days in specified year/month
Returns the number of days in month m of year y. For example, %ymdaycount(2012,9) returns 30: the number of days in September, 2012.
Argument types: |
Integers |
Returns type: |
Integer |
%ymddow(y,m,d) — Day of week for specified date
Returns the day of the the week (1=Monday,...,7=Sunday) for the date y:m:d. For example, %ymddow(2012,9,1) returns 6, as September 1st, 2012 is a Saturday.
Argument types: |
Integers |
Returns type: |
Integer |
%ymdjulian(y,m,d) — Julian date for specified date
Returns the Julian date (number of days since January 1st, 0001, acting as if the Gregorian calendar extends back) for the date y:m:d.
Argument types: |
Integers |
Returns type: |
Integer |
%zeros(rows,cols) — Create a zero matrix
Returns a matrix with dimensions rows × cols, with all elements equal to zero.
Argument types: |
Integers |
Returns type: |
Rectangular of Reals |
%zlag(t,x) — Transfer function for lag
Returns \(\exp \left( { - i2\pi (t - 1)x/N} \right)\) where N is the number of frequencies set on the FREQUENCY instruction. As t runs from 1 to N, this gives the appropriate Fourier transform for the lag operator \(L^x\).
Argument types: |
Integer (t) and real (x) |
Returns type: |
Complex |
%ztest(x) — Two-tailed standard normal probability
Returns the two‑tailed probability for Standard Normal, that is, the probability that a Normally distributed random variable exceeds x in absolute value.
Argument type: |
Real |
Returns type: |
Real |
Copyright © 2025 Thomas A. Doan