This package "BoxCoxFuncForm" has two related features: 

1. Provide a specification or goodness-of-fit test assessing two OLS
specifications, one where the dependent variable y and the set of
regressors in X are left unchanged (levels), and one where logs of
y and X are taken. (LevelLogTest)

2. Estimate by Maximum Likelihood the optimal Box-Cox transformations
of the dependent
and/or independent X variables of a regression.
A special case of this is to determine the optimal transformation 
parameter of a single variable (which is internally regressed on 
nothing but a constant term). (BoxCoxForm)

The Box-Cox transformation for some positive-valued variable x and a
parameter q is defined as `(x^q - 1) / q`, or `log(x)` for `q = 0`.

(If a series contains negative values, no transformation can be applied.
The decision of whether or not it makes sense to shift the variable to the
positive region somehow depends on the context and is left to the user.) 

# LevelLogTest()

## Arguments:

1. series (y), dependent variable (untransformed)
2. list (X), regressors
3. list (Z), untouched regressors (default null)
4. int (verbosity), switch whether to print out something (default: 1)

Variables in regressor set Z are not transformed, e.g. constant or
dummies, or others chosen by the user.

## Returns:

A 2x2 matrix with two columns, where:
the 1st col is for the log specification as H0, 
the 2nd for the linear spec.

Each column holds:

1. the test statistic which is chi2-distributed with 1 d.o.f.,
2. the p-value. 

The regressors X are treated like y, whereas Z are always taken as is.
Variables unsuitable for transformation are automatically moved to Z,
after printing a warning message.
The tests are LM-type tests based on double-length artificial regressions
which implicitly have the best Box-Cox transformations as the alternative.

Reference: 
Testing Linear and Loglinear Regressions against Box-Cox Alternatives;
Russell Davidson and James G. MacKinnon;
The Canadian Journal of Economics (Revue canadienne d'Economique), Vol. 18, No. 3 (Aug., 1985), pp. 499-517; Wiley (on behalf of the Canadian Economics Association);
Stable URL: https://www.jstor.org/stable/135016

# BoxCoxForm()

## Arguments:

1. series (y), dependent variable (untransformed)
2. list (X), regressors (default null)
3. list (Z), untouched regressors (default null)
4. int modeltype, 1,2 or 3 (see below, default 1)
5. matrix fixedlapsi, specify fixed trafo values (default null)
6. int verbosity, 0: silent, 1: standard (default), 2: also ML iterations.
7. bool derivative, use analytical derivatives? (default TRUE/1)

Estimates the best of different Box-Cox transformations with ML methods.
A constant term will always be added, no matter if it is in Z or not.

Regressor lists X and Z can both be omitted, which implies an analysis of
the single series y, so a straightforward call like `BoxCoxForm(y)` is possible.

In the general model the dependent variable is transformed with a
different parameter lambda than the psi parameter for the X regressors
(modeltype 1, default).
Modeltype 2 means that the same transformation parameter is imposed for
both y and X. Finally, in modeltype 3 only the members of X are transformed.
(The case where only y is transformed can be achieved by leaving X empty
and putting all regressors into Z.)

If you want to fix instead of estimating the transformation parameters 
for y -lambda- or X -psi-, then specify 'fixedlapsi' accordingly, e.g.
as `{0, NA}` to apply lambda=0 (log transform) and leave psi unrestricted.

(If derivative==FALSE (0), then the analytical derivatives for the ML estimation
are ignored and numerical approximations are used, mainly for numerical testing
purposes.)

## Returns:

A bundle with the contents of gretl's `$model` bundle for the best-fitting
model, and in addition this bundle holds a 3x2 vector named "best"
with:

1. the optimal lambda (LHS) with std. error in row 1,
2. the optimal psi (RHS-X) with std. error in row 2, 
3. corresponding log-likelihood in position 3,1 (and nothing in 3,2).

Notice that the best model is just an OLS regression with the transformed
variables. It ignores the fact that the transformation was itself
estimated. Interpret the standard errors and statistical inference with
caution. There are examples with real-world data where seemingly
significant coefficients turn out insignificant when assessed in a joint
estimation approach. It is planned for a future version of this package to
provide inference (standard errors) based on joint estimation as well.

# Changelog:

- July 2024: public release 0.5, modernize the internals and require gretl 
2020c because of that; enable the single-series case for BoxCoxForm(x);
update the help text and switch to markdown.

- October 2018: initial public release 0.3, change interface, bugfixes

- October 2018: no pulic release 0.2, switch to DLR and ML

- September 2018: no public release 0.1
