Box-Cox Transformation

Toxic Agents Example

Program Listing

DATA poisons (DROP = rep);
 DO treat = 'A', 'B', 'C', 'D';
   DO poison = 1 TO 3;
     DO rep = 1 TO 4;
	   INPUT time @@;
	   OUTPUT;
	  END;
    END;
  END;
 DATALINES;
0.31 0.45 0.46 0.43 0.36 0.29 0.40 0.23 0.22 0.21 0.18 0.23 0.82
1.10 0.88 0.72 0.92 0.61 0.49 1.24 0.30 0.37 0.38 0.29 0.43 0.45
0.63 0.76 0.44 0.35 0.31 0.40 0.23 0.25 0.24 0.22 0.45 0.71 0.66
0.62 0.56 1.02 0.71 0.38 0.30 0.36 0.31 0.33
;

OPTIONS LS=76 NODATE NONUMBER NOCENTER;

TITLE1 'Box-Cox Transformation';
TITLE2 'Toxic Agents Example';

PROC TRANSREG DATA=poisons;
 TITLE3 'Use Defaults';
 MODEL BOXCOX(time) = CLASS(poison treat);
 * Default lambda = -3 to 3 by 0.25;
RUN;

ODS OUTPUT BOXCOX=bc DETAILS=det; 
ODS EXCLUDE BOXCOX; 

PROC TRANSREG DETAILS DATA=poisons;
 TITLE3 'Use Options';
 MODEL BOXCOX(time/lambda = -1.5 TO 0 BY 0.01
                   CONVENIENT) = CLASS(poison treat);
 * CONVENIENT option instructs the use of power like -1, 0, 1
   if the confidence interval includes such value;
 OUTPUT OUT=trans;
RUN;

PROC PRINT NOOBS LABEL DATA=bc(DROP=rmse); 
 TITLE3 'Confidence Interval'; 
 WHERE ci NE ' ' OR ABS(lambda - ROUND(lambda, 0.5)) < 1e-6; 
 LABEL convenient = '00'x ci = '00'x; 
RUN;
* Store values for reference lines; 
DATA _NULL_; 
   SET det; 
   IF description = 'CI Limit' 
      THEN CALL SYMPUT('vref',   formattedvalue); 
   IF description = 'Lambda Used' 
      THEN CALL SYMPUT('lambda', formattedvalue); 
   RUN; 
 
DATA _NULL_; 
   SET bc END=EOF; 
   WHERE ci NE ' '; 
   IF _N_ = 1 
      THEN CALL SYMPUT('href1', COMPRESS(PUT(lambda, BEST12.))); 
   IF ci  = '<' 
      THEN CALL SYMPUT('href2', COMPRESS(PUT(lambda, BEST12.))); 
   IF EOF 
      THEN CALL SYMPUT('href3', COMPRESS(PUT(lambda, BEST12.))); 
   RUN;

* Plot log likelihood, confidence interval; 
AXIS1 LABEL=(ANGLE=90 ROTATE=0) MINOR=NONE; 
AXIS2 MINOR=NONE; 
PROC GPLOT DATA=bc; 
   TITLE3 'Log Likelihood'; 
   PLOT loglike * lambda / VREF=&vref HREF=&href1 &href2 &href3 
                           VAXIS=AXIS1 HAXIS=AXIS2 FRAME; 
   FOOTNOTE "Confidence Interval: &href1 - &href2 - &href3, " 
            "Lambda = &lambda"; 
   SYMBOL V=NONE I=SPLINE C=BLUE; 
   RUN; 
 
   FOOTNOTE; 
   TITLE3 'RMSE'; 
   PLOT rmse * lambda / VAXIS=AXIS1 HAXIS=AXIS2 FRAME; 
   RUN; 
 
   TITLE2 'R-Square'; 
   PLOT rsquare * lambda / VAXIS=AXIS1 HAXIS=AXIS2 FRAME; 
   AXIS1 ORDER=(0 TO 1 BY 0.1) LABEL=(ANGLE=90 ROTATE=0) MINOR=NONE; 
   RUN;
QUIT;

Output Listing

Box-Cox Transformation
Toxic Agents Example
Use Defaults

The TRANSREG Procedure

     Transformation Information
          for BoxCox(time)

  Lambda      R-Square    Log Like

   -3.00          0.72     72.4832
   -2.75          0.74     79.6705
   -2.50          0.76     86.6347
   -2.25          0.78     93.2973
   -2.00          0.80     99.5388
   -1.75          0.82    105.1867
   -1.50          0.83    110.0100
   -1.25          0.84    113.7345
   -1.00 +        0.84    116.0913 *
   -0.75          0.84    116.8938 <
   -0.50          0.83    116.1055 *
   -0.25          0.81    113.8500
    0.00          0.79    110.3558
    0.25          0.76    105.8781
    0.50          0.73    100.6407
    0.75          0.69     94.8133
    1.00          0.65     88.5134
    1.25          0.61     81.8176
    1.50          0.57     74.7749
    1.75          0.53     67.4170
    2.00          0.50     59.7655
    2.25          0.46     51.8370
    2.50          0.43     43.6457
    2.75          0.41     35.2047
    3.00          0.38     26.5273

< - Best Lambda
* - Confidence Interval
+ - Convenient Lambda
Box-Cox Transformation
Toxic Agents Example
Use Defaults

The TRANSREG Procedure

     TRANSREG Univariate Algorithm Iteration History for BoxCox(time)

Iteration    Average    Maximum                Criterion
   Number     Change     Change    R-Square       Change    Note
-------------------------------------------------------------------------
        1    0.00000    0.00000     0.84048                 Converged

Algorithm converged.
Box-Cox Transformation
Toxic Agents Example
Use Options

The TRANSREG Procedure

     TRANSREG Univariate Algorithm Iteration History for BoxCox(time)

Iteration    Average    Maximum                Criterion
   Number     Change     Change    R-Square       Change    Note
-------------------------------------------------------------------------
        1    0.00000    0.00000     0.84408                 Converged

Algorithm converged.


                   Model Statement Specification Details

Type  DF Variable      Description     Value

Dep    1 BoxCox(time)  Lambda Used     -1
                       Lambda          -0.75
                       Log Likelihood  116.9
                       Conv. Lambda    -1
                       Conv. Lambda LL 116.1
                       CI Limit        115.0
                       Alpha           0.05
                       Options         Convenient Lambda Used

Ind    1 Class.poison1 Label           poison 1

Ind    1 Class.poison2 Label           poison 2

Ind    0 Class.poison3 Options         Reference Level
                       Label           poison 3

Ind    1 Class.treatA  Label           treat A

Ind    1 Class.treatB  Label           treat B

Ind    1 Class.treatC  Label           treat C

Ind    0 Class.treatD  Options         Reference Level
                       Label           treat D
Box-Cox Transformation
Toxic Agents Example
Confidence Interval

 Dependent        Lambda         R-Square    Log Like

BoxCox(time)       -1.50             0.83    110.0100
BoxCox(time)       -1.13             0.84    115.0508    *
BoxCox(time)       -1.12             0.84    115.1454    *
BoxCox(time)       -1.11             0.84    115.2376    *
BoxCox(time)       -1.10             0.84    115.3275    *
BoxCox(time)       -1.09             0.84    115.4149    *
BoxCox(time)       -1.08             0.84    115.4998    *
BoxCox(time)       -1.07             0.84    115.5824    *
BoxCox(time)       -1.06             0.84    115.6625    *
BoxCox(time)       -1.05             0.84    115.7402    *
BoxCox(time)       -1.04             0.84    115.8154    *
BoxCox(time)       -1.03             0.84    115.8881    *
BoxCox(time)       -1.02             0.84    115.9583    *
BoxCox(time)       -1.01             0.84    116.0261    *
BoxCox(time)       -1.00    +        0.84    116.0913    *
BoxCox(time)       -0.99             0.84    116.1540    *
BoxCox(time)       -0.98             0.84    116.2143    *
BoxCox(time)       -0.97             0.84    116.2720    *
BoxCox(time)       -0.96             0.84    116.3271    *
BoxCox(time)       -0.95             0.84    116.3798    *
BoxCox(time)       -0.94             0.84    116.4299    *
BoxCox(time)       -0.93             0.84    116.4774    *
BoxCox(time)       -0.92             0.84    116.5224    *
BoxCox(time)       -0.91             0.84    116.5648    *
BoxCox(time)       -0.90             0.84    116.6047    *
BoxCox(time)       -0.89             0.84    116.6420    *
BoxCox(time)       -0.88             0.84    116.6767    *
BoxCox(time)       -0.87             0.84    116.7089    *
BoxCox(time)       -0.86             0.84    116.7385    *
BoxCox(time)       -0.85             0.84    116.7655    *
BoxCox(time)       -0.84             0.84    116.7899    *
BoxCox(time)       -0.83             0.84    116.8118    *
BoxCox(time)       -0.82             0.84    116.8311    *
BoxCox(time)       -0.81             0.84    116.8478    *
BoxCox(time)       -0.80             0.84    116.8619    *
BoxCox(time)       -0.79             0.84    116.8734    *
BoxCox(time)       -0.78             0.84    116.8824    *
BoxCox(time)       -0.77             0.84    116.8888    *
BoxCox(time)       -0.76             0.84    116.8926    *
BoxCox(time)       -0.75             0.84    116.8938    <
BoxCox(time)       -0.74             0.84    116.8925    *
BoxCox(time)       -0.73             0.84    116.8886    *
BoxCox(time)       -0.72             0.84    116.8822    *
BoxCox(time)       -0.71             0.84    116.8732    *
BoxCox(time)       -0.70             0.84    116.8616    *
BoxCox(time)       -0.69             0.84    116.8475    *
BoxCox(time)       -0.68             0.84    116.8309    *
Box-Cox Transformation
Toxic Agents Example
Confidence Interval

 Dependent        Lambda         R-Square    Log Like

BoxCox(time)       -0.67             0.84    116.8117    *
BoxCox(time)       -0.66             0.84    116.7900    *
BoxCox(time)       -0.65             0.84    116.7657    *
BoxCox(time)       -0.64             0.84    116.7390    *
BoxCox(time)       -0.63             0.84    116.7098    *
BoxCox(time)       -0.62             0.84    116.6780    *
BoxCox(time)       -0.61             0.84    116.6438    *
BoxCox(time)       -0.60             0.84    116.6070    *
BoxCox(time)       -0.59             0.83    116.5678    *
BoxCox(time)       -0.58             0.83    116.5262    *
BoxCox(time)       -0.57             0.83    116.4821    *
BoxCox(time)       -0.56             0.83    116.4355    *
BoxCox(time)       -0.55             0.83    116.3865    *
BoxCox(time)       -0.54             0.83    116.3351    *
BoxCox(time)       -0.53             0.83    116.2813    *
BoxCox(time)       -0.52             0.83    116.2251    *
BoxCox(time)       -0.51             0.83    116.1665    *
BoxCox(time)       -0.50             0.83    116.1055    *
BoxCox(time)       -0.49             0.83    116.0422    *
BoxCox(time)       -0.48             0.83    115.9765    *
BoxCox(time)       -0.47             0.83    115.9085    *
BoxCox(time)       -0.46             0.83    115.8382    *
BoxCox(time)       -0.45             0.83    115.7655    *
BoxCox(time)       -0.44             0.83    115.6906    *
BoxCox(time)       -0.43             0.83    115.6133    *
BoxCox(time)       -0.42             0.83    115.5338    *
BoxCox(time)       -0.41             0.82    115.4521    *
BoxCox(time)       -0.40             0.82    115.3681    *
BoxCox(time)       -0.39             0.82    115.2819    *
BoxCox(time)       -0.38             0.82    115.1934    *
BoxCox(time)       -0.37             0.82    115.1028    *
BoxCox(time)       -0.36             0.82    115.0100    *
BoxCox(time)        0.00             0.79    110.3558

Graphical Output

(boxcox01.png here)
(boxcox02.png here)
(boxcox03.png here)