*! version 1.0.1 12sep2023

Title

xtloglin -- robust Lagrange multiplier test of linear and log-linear models
against Box-Cox alternatives after regress or xtreg

Syntax

xtloglin,
null(model)
[negative
notrobust
robust
cluster(varname)]

Description

xtloglin implements a Lagrange multiplier test for testing the null of linear and log-linear regression models
against Box-Cox alternatives. The test can be run after regress or xtreg and is based on a non-linear instrumental
variables estimator of the Box-Cox model proposed by Amemiya and Powell (1981). For further details, please see Vincent, D. (2023, September)

Options

null(linear|log) specifies the linear or log-linear model to be tested under the null. This must correspond to the model that has been estimated.

negative used for testing the linear model when the dependent variable contains zero or negative values. This invokes the transformation
proposed by MacKinnon and Magee (1990). This can also be used when the dependent variable is strictly positive.

notrobust computes the test-statistic under the assumption that the error terms are independent and homoskedastic.

robust computes the test-statistic that is robust to arbitrary forms of heteroskedasticity provided that the error terms are independent.

cluster(clustvar) computes the test-statistic that is robust to heteroskedasticity and correlation within clusters, provided that the
errors are independent across clusters. The variable clustvar specifies which cluster (group) each observation belongs to.

Remarks

xtloglin defaults to the version of the test-statistic, that corresponds to the assumptions made about the covariance structure of the errors in
vce(), when the regression being tested is estimated. Specifying notrobust, robust or cluster() will override this.

Remarks

xtloglin tests the suitability of the model that has been fitted. For testing the linear model against the Box-Cox alternative, one must first estimate a
regression that explains the levels of the dependent variable and then specify model(linear). For testing the log-linear model, a regression that
explains the log-transformed outcomes must be fitted and model(log) specified.

As the Box-Cox transformation is not defined for negative outcomes, an alternative method is required for testing the suitability of the linear model
in such cases. Note that this should not be an issue when testing the log-linear model, as only positive observations can be log-transformed. The approach
taken in xtloglin is to use the transformation suggested by MacKinnon & Magee (1990), which is defined for both positive and negative values. This
is implemented by including the option negative together with model(linear).

Technical Note

The Box-Cox regression first introduced by Box and Cox (1964), assumes that for some value of the transformation parameter lambda, the transformed dependent
variable is a linear function of the explanatory variables. This nests both the linear and log-linear models as special cases, making it possible to
test the suitability of these functional forms.

The test is based on a non-linear instrumental variables estimator, which is consistent for arbitrary error term distributions. Under the null restriction, the
coefficient estimates on the explanatory variables are identical to those after regress and xtreg. The first, second, third and fourth powers of the
fitted values are then generated and used in the test-statistic as additional instruments to identify the transformation parameter.

Examples

. sysuse auto,clear

Linear model

. reg mpg weight length displacement, robust

. xtloglin, null(linear)

Robust LM test of linear and log-linear functional forms
H0: linear dependent variable
H1: Box-Cox transformation

LM-chi2(1) = 4.725
Prob > LM = 0.0297

Error Variance: robust

Log-linear model

. gen l_mpg=log(mpg)

. qui reg l_mpg weight length displacement, robust

. xtloglin, null(log)

Robust LM test of linear and log-linear functional forms
H0: log dependent variable
H1: Box-Cox transformation

LM-chi2(1) = 0.454
Prob > LM = 0.5004

Error Variance: robust

References

Amemiya, T., & Powell, J. L. (1981).
A comparison of the Box-Cox maximum likelihood estimator and the non-linear two-stage least squares estimator. Journal of Econometrics, 17(3), 351-381.

Box, G. E., & Cox, D. R. (1964).
An analysis of transformations. Journal of the Royal Statistical Society Series B: Statistical Methodology, 26(2), 211-243.

MacKinnon, J. G., & Magee, L. (1990).
Transforming the dependent variable in regression models. International Economic Review, 315-339.

Vincent, D. (2023, September).
A robust test for linear and log-linear models against Box-Cox alternatives. In London Stata Conference 2023 Stata Users Group.

Author

This command was written by David Vincent (dvincent@dveconometrics.co.uk).
Comments and suggestions are welcome.