Learn R Programming

desk (version 1.1.2)

bc.test: Box-Cox Test

Description

Box-Cox test for functional form. Compares a base model with non transformed endogenous variable to a model with logarithmic endogenous variable. Exogenous variables can be transformed or non-transformed. The object of test results returned by this command can be plotted using the plot() function.

Usage

bc.test(
  basemod,
  data = list(),
  exo = "same",
  sig.level = 0.05,
  details = TRUE,
  hyp = TRUE
)

Value

A list object including:

hypcharacter matrix of hypotheses (if hyp = TRUE).
resultsa data frame of basic test results.
statsadditional statistic of aux. regression.
nulldisttype of the Null distribution with its parameters.

Arguments

basemod

estimated linear model object or formula taken as the base model for comparison. Has to have a non-transformed endogenous variable.

data

if mod is a formula then the corresponding data frame has to be specified.

exo

vector or matrix of transformed exogenous variables to be used in the comparison model. If not specified the same variables from the base model are used ("same").

sig.level

significance level. Default value: sig.level = 0.05.

details

logical value indicating whether specific details about the test should be returned.

hyp

logical value indicating whether the Hypotheses should be returned.

References

Box, G.E.P. & Cox, D.R. (1964): An Analysis of Transformations. Journal of the Royal Statistical Society, Series B. 26, 211-243.

See Also

Examples

Run this code
## Box-Cox test between a semi-logarithmic model and a logarithmic model
semilogmilk.est <- ols(milk ~ log(feed), data = data.milk)
results <- bc.test(semilogmilk.est, details = TRUE)

## Plot the test results
plot(results)

## Example with transformed exogenous variables
lin.est <- ols(rent ~ mult + mem + access, data = data.comp)
A <- lin.est$data
bc.test(lin.est, exo = log(cbind(A$mult, A$mem, A$access)))

Run the code above in your browser using DataLab