Learn R Programming

geoR (version 1.4-8)

boxcox.fit: Parameter Estimation for the Box-Cox Transformation

Description

Parameter estimation and plotting of the results for the Box-Cox transformed normal distribution.

Usage

boxcox.fit(data, xmat, lambda, lambda2 = NULL, add.to.data = 0, ...)

print.boxcox.fit(x, ...)

plot.boxcox.fit(x, hist = TRUE, data = eval(x$call$data), ...)

lines.boxcox.fit(x, data = eval(x$call$data), ...)

Arguments

data
a vector with the data.
xmat
a matrix with covariates values. Defaults to rep(1, length(y)).
lambda
numerical value(s) for the transformation parameter $\lambda$. Used as the initial value in the function for parameter estimation. If not provided default values are assumed. If multiple values are passed the one with highest likelihood i
lambda2
logical or numerical value(s) of the additional transformation (see DETAILS below). Defaults to NULL. If TRUE this parameter is also estimated and the initial value is set to the absolute value of the minimum data.
add.to.data
a constant value to be added to the data.
x
a list, typically an output of the function boxcox.fit.
hist
logical indicating whether histograms should to be plotted.
...
extra parameters to be passed to the minimization function optim (boxcox.fit), hist (plot) or

Value

  • The functions returns the following results:
  • boxcox.fita list with estimated parameters and results on the numerical minimization.
  • print.boxcox.fitprint estimated parameters. No values returned.
  • plot.boxcox.fitplots histogram of the data (optional) and the model. No values returned. This function is only valid if covariates are not included in boxcox.fit.
  • lines.boxcox.fitadds a line with the fitted model to the current plot. No values returned. This function is only valid if covariates are not included in boxcox.fit.

References

Box, G.E.P. and Cox, D.R.(1964) An analysis of transformations. JRSS B 26:211--246.

See Also

rboxcox and dboxcox for the expression and more on the Box-Cox transformation, the minimization function optim, the function boxcox in the package MASS and the function boxcox in the package car.

Examples

Run this code
## Simulating data
simul <- rboxcox(100, lambda=0.5, mean=10, sd=2)
## Finding the ML estimates
ml <- boxcox.fit(simul)
ml
## Ploting histogram and fitted model
plot(ml)
##
## Comparing models with different lambdas,
## zero  means and unit variances
curve(dboxcox(x, lambda=-1), 0, 8)
for(lambda in seq(-.5, 1.5, by=0.5))
  curve(dboxcox(x, lambda), 0, 8, add = TRUE)
##
## Another example, now estimating lambda2
##
simul <- rboxcox(100, lambda=0.5, mean=10, sd=2)
ml <- boxcox.fit(simul, lambda2 = TRUE)
ml
plot(ml)
##
## An example with a regression model
##
if(require(MASS)){
  data(trees)
  boxcox.fit(data = trees[,3], xmat = trees[,1:2])
  }

Run the code above in your browser using DataLab