**[R] boxcox** -- Box-Cox regression models

__Syntax__

**boxcox** *depvar* [*indepvars*] [*if*] [*in*] [*weight*] [**,** *options*]

*options* Description
-------------------------------------------------------------------------
Model
__nocons__**tant** suppress constant term
**model(**__lhs__**only)** left-hand-side Box-Cox model; the default
**model(**__rhs__**only)** right-hand-side Box-Cox model
**model(**__lam__**bda)** both sides Box-Cox model with same parameter
**model(theta)** both sides Box-Cox model with different parameters
__notr__**ans(***varlist***)** do not transform specified independent variables

Reporting
__l__**evel(***#***)** set confidence level; default is **level(95)**
**lrtest** perform likelihood-ratio test

Maximization
__nolo__**g** suppress full-model iteration log
**nologlr** suppress restricted-model **lrtest** iteration log
*maximize_options* control the maximization process; seldom used
-------------------------------------------------------------------------
*depvar* and *indepvars* may contain time-series operators; see tsvarlist.
**bootstrap**, **by**, **jackknife**, **rolling**, **statsby**, and **xi** are allowed; see
prefix.
Weights are not allowed with the **bootstrap** prefix.
**fweight**s and **iweight**s are allowed; see weight.
See **[R] boxcox postestimation** for features available after estimation.

__Menu__

**Statistics > Linear models and related > Box-Cox regression**

__Description__

**boxcox** finds the maximum likelihood estimates of the parameters of the
Box-Cox transform, the coefficients on the independent variables, and the
standard deviation of the normally distributed errors. Any *depvar* or
*indepvars* to be transformed must be strictly positive. Options can be
used to control which variables remain untransformed.

__Options__

+-------+
----+ Model +------------------------------------------------------------

**noconstant**; see **[R] estimation options**.

**model(lhsonly**|**rhsonly**|**lambda**|**theta)** specifies which of the four models to
fit.

**model(lhsonly)** applies the Box-Cox transform to *depvar* only.
**model(lhsonly)** is the default.

**model(rhsonly)** applies the transform to the *indepvars* only.

**model(lambda)** applies the transform to both *depvar* and *indepvars*, and
they are transformed by the same parameter.

**model(theta)** applies the transform to both *depvar* and *indepvars*, but
this time, each side is transformed by a separate parameter.

**notrans(***varlist***)** specifies that the variables in *varlist* not be
transformed when included in the model. You can specify
**notrans(***varlist***)** with **model(lhsonly)**, but the results will be the
same as specifying the variables in *varlist* in *indepvars*.

+-----------+
----+ Reporting +--------------------------------------------------------

**level(***#***)**; see **[R] estimation options**.

**lrtest** specifies that a likelihood-ratio test of significance be
performed and reported for each independent variable.

+--------------+
----+ Maximization +-----------------------------------------------------

**nolog** suppresses the iteration log when fitting the full model.

**nologlr** suppresses the iteration log when fitting the restricted models
required by the **lrtest** option.

*maximize_options*: __iter__**ate(***#***)** and **from(***init_specs***)**; see **[R] maximize**.

Model Initial value specification
---------------------------------------
**lhsonly** **from(***#_t***, copy)**
**rhsonly** **from(***#_l***, copy)**
**lambda** **from(***#_l***, copy)**
**theta** **from(***#_l #_t***, copy)**
---------------------------------------

__Examples__

Setup
**. sysuse auto**

Apply Box-Cox transform to **mpg**
**. boxcox mpg weight price**

Same as above, but include **foreign** as an independent variable that has
not been transformed
**. boxcox mpg weight price, notrans(foreign)**

Apply Box-Cox transform to **weight** and **price**
**. boxcox mpg weight price, model(rhsonly)**

Use the same parameter to transform **mpg**, **weight**, and **price**
**. boxcox mpg weight price, model(lambda)**

Use a different parameter to transform **mpg** than that used to transform
**weight** and **price**
**. boxcox mpg weight price, model(theta)**

__Stored results__

**boxcox** stores the following in **e()**:

Scalars
**e(N)** number of observations
**e(ll)** log likelihood
**e(chi2)** LR statistic of full vs. comparison
**e(df_m)** full model degrees of freedom
**e(ll0)** log likelihood of the restricted model
**e(df_r)** restricted model degrees of freedom
**e(ll_t1)** log likelihood of model lambda = theta = 1
**e(chi2_t1)** LR of lambda = theta = 1 vs. full model
**e(p_t1)** p-value of lambda = theta = 1 vs. full model
**e(ll_tm1)** log likelihood of model lambda = theta = -1
**e(chi2_tm1)** LR of lambda = theta = -1 vs. full model
**e(p_tm1)** p-value of lambda = theta = -1 vs. full model
**e(ll_t0)** log likelihood of model lambda = theta = 0
**e(chi2_t0)** LR of lambda = theta = 0 vs. full model
**e(p_t0)** p-value of lambda = theta = 0 vs. full model
**e(rank)** rank of **e(V)**
**e(ic)** number of iterations
**e(rc)** return code

Macros
**e(cmd)** **boxcox**
**e(cmdline)** command as typed
**e(depvar)** name of dependent variable
**e(model)** **lhsonly**, **rhsonly**, **lambda**, or **theta**
**e(wtype)** weight type
**e(wexp)** weight expression
**e(ntrans)** **yes** if untransformed *indepvars*
**e(chi2type)** **LR**; type of model chi-squared test
**e(lrtest)** **lrtest**, if requested
**e(properties)** **b V**
**e(predict)** program used to implement **predict**
**e(marginsnotok)** predictions disallowed by **margins**

Matrices
**e(b)** coefficient vector
**e(V)** variance-covariance matrix of the estimators
(see note below)
**e(pm)** p-values for LR tests on *indepvars*
**e(df)** degrees of freedom of LR tests on *indepvars*
**e(chi2m)** LR statistics for tests on *indepvars*

Functions
**e(sample)** marks estimation sample

**e(V)** contains all zeros, except for the elements that correspond to the
parameters of the Box-Cox transform.