The %LOGTEST macro tests whether a logarithmic transformation is appropriate for modeling and forecasting a time series. The logarithmic transformation is often used for time series that show exponential growth or variability proportional to the level of the series.
The %LOGTEST macro fits an autoregressive model to a series and fits the same model to the log of the series. Both models are estimated by the maximum-likelihood method, and the maximum log-likelihood values for both autoregressive models are computed. These log-likelihood values are then expressed in terms of the original data and compared.
You can control the order of the autoregressive models. You can also difference the series and the log-transformed series before the autoregressive model is fit.
You can print the log-likelihood values and related statistics (AIC, SBC, and MSE) for the autoregressive models for the series and the log-transformed series. You can also output these statistics to a SAS data set.
The %LOGTEST macro has the following form:
The first argument, SAS-data-set, specifies the name of the SAS data set that contains the time series variable to be analyzed. The second argument, variable, specifies the time series variable name to be analyzed.
The first two arguments are required. The following options can be used with the %LOGTEST macro. Options must follow the required arguments and are separated by commas.
The result of the test is returned in the macro variable &LOGTEST
. The value of the &LOGTEST
variable is ‘LOG’ if the model fit to the log-transformed data has a larger log likelihood than the model fit to the untransformed
series. The value of the &LOGTEST
variable is ‘NONE’ if the model fit to the untransformed data has a larger log likelihood. The variable &LOGTEST
is set to ‘ERROR’ if the %LOGTEST macro is unable to compute the test due to errors.
Results are printed when the PRINT=YES option is specified. Results are stored in SAS data sets when the OUT= option is specified.
Assume that a time series is a stationary pth order autoregressive process with normally distributed white noise innovations. That is,
where is the mean of .
The log likelihood function of is
where n is the number of observations, 1 is the n-dimensional column vector of 1s, is the variance of the white noise, , and is the covariance matrix of .
On the other hand, if the log-transformed time series is a stationary pth order autoregressive process, the log-likelihood function of is
where is the mean of , , and is the covariance matrix of .
The %LOGTEST macro compares the maximum values of and and determines which is larger.
The %LOGTEST macro also computes the Akaike Information Criterion (AIC), Schwarz’s Bayesian Criterion (SBC), and residual mean squared error based on the maximum likelihood estimator for the autoregressive model. For the mean squared error, retransformation of forecasts is based on Pankratz (1983, pp. 256–258).
After differencing as specified by the DIF= option, the process is assumed to be a stationary autoregressive process. You might want to check for stationarity of the series using the %DFTEST macro. If the process is not stationary, differencing with the DIF= option is recommended. For a process with moving average terms, a large value for the AR= option might be appropriate.