BoxCox                 package:geoR                 R Documentation

_B_o_x-_C_o_x _t_r_a_n_s_f_o_r_m_a_t_i_o_n _r_e_l_a_t_e_d _f_u_n_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Estimate parameters and plot results , computes density and random
     generation for the Box-Cox normal transformed distribution.

_U_s_a_g_e:

     boxcox.fit(data, xmat, lambda, lambda2 = FALSE, 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), ...)

     rboxcox(n, lambda, lambda2 = NULL, mean = 0, sd = 1)

     dboxcox(x, lambda, lambda2 = NULL, mean = 0, sd = 1)

_A_r_g_u_m_e_n_t_s:

    data: a vector with data.  

    xmat: a matrix of covariates. Defaults to `rep(1, length(y))'.  

  lambda: numerical value(s) of the transformation parameter lambda. 
          Used as initial value for the parameter estimation function.
          If not provided default values are assumed. If multiple
          values are passed the one with highest likelihood is used as
          initial value. 

 lambda2: numerical value(s) of the additional transformation (see
          DETAILS below). Defaults to `FALSE'. If `TRUE' this parameter
          is also estimated and the initial value is set to the
          absolute value of the minimum data. A numerical value
          provided is used as initial value. As for `lambda' multiple
          values are allowed.  

add.to.data: a constant to be added to the data.  

       n: number of observations to be generated.  

       x: a vector of quantiles (`dboxcox') or an output of
          `boxcox.fit' (`print', `plot', `lines').  

    mean: a vector of means at for the normal scale.  

      sd: a vector of standard deviations at the normal scale.  

    hist: logical indicating whether histograms are to be plotted.  

     ...: extra parameters to be passed to the minimization function
          `optim' (`boxcox.fit'), `hist' (`plot') or `curve' (`lines').            

_D_e_t_a_i_l_s:

     Denote Y the variable at the original scale. The Box-Cox
     transformation is defined by:


 Y' = log(Y) if lambda = 0 , Y' = ((Y ^ lambda) - 1)/lambda otherwise

     . 

     An additional shifting parameter lambda2 can be included in which
     case the transformation is given by: 


 Y' = log(Y + lambda2) if lambda = 0 , Y' = (((Y + lambda2) ^ lambda) - 1)/lambda otherwise

     .

     The function `rboxcox' samples Y' from the normal distribution
     using `rnorm' and backtransform the values according to the
     equations above. If necessary the back-transformation truncates
     the values such that Y' >= -1/lambda. This results in values of Y
     = 0 in the original scale. Increasing the mean and/or reducing the
     variance might help to avoid truncation.

_V_a_l_u_e:

     The functions returns the following results:

boxcox.fit: a list with estimated  parameters and results on the
          numerical minimization.  

print.boxcox.fit: print estimated parameters. No values returned.  

plot.boxcox.fit: plots 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.fit: 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 `boxcox.fit'.  

 rboxcox: a vector with simulated observations.  

 dboxcox: a vector of densities.  

     normal-bracket101bracket-normal

_A_u_t_h_o_r(_s):

     Paulo Justiniano Ribeiro Jr. Paulo.Ribeiro@est.ufpr.br, 
     Peter J. Diggle p.diggle@lancaster.ac.uk.

_R_e_f_e_r_e_n_c_e_s:

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

_S_e_e _A_l_s_o:

     The minimization function `optim', `boxcox' in the package `MASS'
     and `boxcox' in the package `car'.

_E_x_a_m_p_l_e_s:

     ## 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])
       }

