Allin Cottrell schrieb:
> We could do this by providing three functions, e.g.,
>
> acy(y, p)
> pacf(y, p)
> xcf(x, y, p)
>
> where x and y are series and p is the maximum lag. It would
> be possible to combine acf and pacf into one function by using
> a third boolean parameter to distinguish the cases...
I have no strong opinions here, but for heavy-duty
number-crunching in simulations I guess it would be better to
only calculate the results that are really needed to save cpu
time. So no automatic returning of both ACF and PACF unless it
is explicitly requested.
Also, I would be in favor of not introducing too many new
function names for the sake of finding quickly what you want in
the function documentation. So I think having one function, say
'acf' (but there may be better names), with a parameter that
determines whether you want the standard acf, or pacf, or
cross-correlation.
In general I would suggest to have only one data argument which
must be either a series, or a list of series, or a matrix...

For now, in CVS, we have a compromise between what I originally
had in mind and what Sven suggested. I agree that it's good to
avoid excessive proliferation of function names, but on the other
hand I find heavily overloaded functions kind of confusing.
Result: two functions, acf() (which also does pacf, see below) and
a separate xcf().
I also agree that it's nice to support as many relevant data types
as possible, but such flexibility is complex to arrange so at
present it's more limited than Sven indicated. That is,
* acf has 2 required arguments: the first can be a series or a
matrix, the second, p, must be a scalar (lag order). In addition
it has a third optional argument: the word "partial", or any
leading portion thereof (just "p" will do), to get the PACF.
If the first arg is a series, returns a p-vector; if it's a
matrix, returns a p x m matrix where m is the number of columns in
the input matrix (i.e. each column is taken as a series).
examples/tests:
open data9-7 -q
corrgm PRIME 12 -q
matrix a = acf(PRIME, 12) # series input
a
matrix x = {PRIME}
a = acf(x, 12) # matrix input
a
corrgm UNEMP 12 -q
x = {PRIME,UNEMP} # two-col matrix input
a = acf(x, 12)
a
a = acf(x, 12, partial)
a
* xcf has three required arguments: the first two may be series
or matrices (column vectors only), but must be of the same type.
The third scalar argument is the lag order, p. Output is a column
vector of length 2*p + 1.
open data9-7 -q
xcorrgm PRIME UNEMP 6 -q
a = xcf(PRIME, UNEMP, 6)
a
matrix x = {PRIME}
matrix y = {UNEMP}
a = xcf(x, y, 6)
a
Allin.