*
* YuleLags computes an information criterion for various lags of AR processes
* using the Yule-Walker estimates based upon the sample covariances. The Yule-Walker
* algorithm is particularly good in this setting, because all the sums of
* squares can be derived from a single matrix operation.
*
* Syntax:
*
* @yulelags( options ) series start end
*
* Parameters:
*
* series series to analyze
* start end range of series to use (by default, the maximum possible)
*
* Options:
* maxlags=maximum number of lags to consider [25]
* type=[aic]/bic
*
proc yulelags series start end
type series series
type integer start end
*
option integer maxlags 25
option choice type 1 aic bic
*
local series xc
local symm cxx
local vect cxy ic z
local rect s
local real rss fiddle
local integer i maxl
*
* Compute the needed covariances
*
corr(number=maxlags+1,covariances,noprint) series / xc
*
* Use T/2 as the maximum lags if user provides nothing
*
compute maxl=maxlags
if %nobs/2