| boxcoxfit | R Documentation |
Parameter estimation and plotting of the results for the Box-Cox transformed normal distribution.
boxcoxfit(object, xmat, lambda, lambda2 = NULL, add.to.data = 0, ...)
## S3 method for class 'boxcoxfit'
print(x, ...)
## S3 method for class 'boxcoxfit'
plot(x, hist = TRUE, data = eval(x$call$object), ...)
## S3 method for class 'boxcoxfit'
lines(x, data = eval(x$call$object), ...)
object |
a vector with the data. |
xmat |
a matrix with covariates values. Defaults to |
lambda |
numerical value(s) for the transformation parameter
|
lambda2 |
logical or numerical value(s) of the additional transformation
(see DETAILS below). Defaults to |
add.to.data |
a constant value to be added to the data. |
x |
a list, typically an output of the function
|
hist |
logical indicating whether histograms should to be plotted. |
data |
data values. |
... |
extra parameters to be passed to the minimization
function |
The functions returns the following results:
boxcoxfit |
a list with estimated parameters and results on the numerical minimization. |
print.boxcoxfit |
print estimated parameters. No values returned. |
plot.boxcoxfit |
plots histogram of the data (optional) and
the model. No values returned. This function is only valid if
covariates are not included in |
lines.boxcoxfit |
adds a line with the fitted model to the
current plot. No values returned. This function is only valid if
covariates are not included in |
Paulo Justiniano Ribeiro Jr. paulojus@leg.ufpr.br,
Peter J. Diggle p.diggle@lancaster.ac.uk.
Box, G.E.P. and Cox, D.R.(1964) An analysis of transformations. JRSS B 26:211–246.
rboxcox and dboxcox for the
expression and more on the Box-Cox transformation.
Parameter(s) are estimated using the minimization function optim.
Other packages have BoxCox related functions such as boxcox in the package MASS and
the function box.cox in the package ‘car’.
set.seed(384)
## Simulating data
simul <- rboxcox(100, lambda=0.5, mean=10, sd=2)
## Finding the ML estimates
ml <- boxcoxfit(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 <- boxcoxfit(simul, lambda2 = TRUE)
ml
plot(ml)
##
## An example with a regression model
##
boxcoxfit(object = trees[,3], xmat = trees[,1:2])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.