bct              package:TeachingDemos              R Documentation

_B_o_x-_C_o_x _T_r_a_n_s_f_o_r_m_s

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

     Computes the Box-Cox transform of the data for a given value of
     lambda.  Includes the scaling factor.

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

     bct(y, lambda)

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

       y: Vector of data to be transformed.

  lambda: Scalar exponent for transform (1 is linear, 0 is log).

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

     'bct' computes the Box-Cox family of transforms:  y = (y\^lambda -
     1)/(lambda*gm\^(lambda-1)), where gm is the geometric mean of the
     y's. returns log(y)*gm when lambda equals 0.

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

     A vector of the same length as y with the corresponding
     transformed values.

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

     Greg Snow greg.snow@intermountainmail.org

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

     'vis.boxcox', 'vis.boxcoxu', 'boxcox' in package MASS, other
     implementations in various packages

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

     y <- rlnorm(500, 3, 2)
     par(mfrow=c(2,2))
     qqnorm(y)
     qqnorm(bct(y,1/2))
     qqnorm(bct(y,0))
     hist(bct(y,0))

     ## The function is currently defined as
     function(y,lambda){

       gm <- exp( mean( log(y) ) )

       if(lambda==0) return( log(y)*gm )
       
       yt <- (y^lambda - 1)/( lambda * gm^(lambda-1) )
       return(yt)
       }

