| ROBERT PRICE |
ETSUBoxcox.mac:
gmacro
etsuBOXCOX
# <<<< ETSU version of Box Cox Method >>>>
#
note
note last updated: 01-24-2001
note
note running macro etsuBOXCOX.mac
#
# minitab macro from www.stat.wisc.edu/~yuyun/boxcox/box.MAC
#
# original Filename: box.MAC
#
# Minitab Box-Cox Transformation Macro, written by Yuyun Jessie Yang, 1998
# Theory is based on Draper&Smith(1998) "Applied Regression Analysis", 3rd
# edition, Chapter 13.
#
# USES THE GEOMETRIC MEAN!!!
#
## Do not consider missing data.
#
#----------------------------------------------------------------
#
## Need to input the following before running this macro:
#
## c1(1) = number of predictors, excluding the constant term
## c2 through c(c1(1)+1) columns = the predictor columns
## c102=responses, must be entirely positive
## c200=values of lambda's. e.g. -1., -.8, -.6, ..., .6, .8, 1.
#
#----------------------------------------------------------------
#
## In addition to the above, the following are also reserved for
## calculation/output:
## k1-k11, c103-c104, c201-c202 where
## c201=residual sum of squares,
## k11=upper bound which determine the CI for lambda
#
# to run macro:
#
# turn on "enable commands"
# type at the prompt MTB> %etsuBOXCOX
#
## Suggest to clear these variables before input new lambda's:
## c200-c202
## because, eg. if the second time you choose less lambda values, it will
## only alter partial column of c200, which causes errors.
#
#
let k1 = c1(1)
let k100 = k1 + 1
#
name k1='k' k2='n'
#
let k2=count(c102) # number of observations(responses)
let k3=count(c200) # number of lambda values
#
name c200='lambda' c201='RSS' c103='lnY'
let c200=sort(c200)
let c103=loge(c102) # loge(Y's)
let k5=expo(sum(c103)/k2) # k5=geometric mean
#
print k2
print k3
name k5='geometric-mean'
print k5
#
# brief controls amount of output.
# try "1" instead of original "0"
#brief 0
brief 1
#
do k4=1:k3
# oh not used?
# oh=0
#
#
print k4
#
let k6=c200(k4) # do one lambda
#
print k6
#
if k6=0
let c104=k5*c103 # V, see draper&smith
regress c104 k1 c2-ck100;
mse k7.
let k8=('n'-'k'-1)*k7
let c200(k4)=0 # set lambda=0
let c201(k4)=k8 # input RSS, i.e. S(lambda,V)
else
let c104=((c102**k6)-1)/(k6*(k5**(k6-1))) # V again
regress c104 k1 c2-ck100;
mse k7.
let k8=('n'-'k'-1)*k7
let c201(k4)=k8
endif
enddo
# now find the upper bound
brief 1
# length of text in command
#minimum of the values in c201 put into k9 # find smallest RSS
minimum c201 k9 # find smallest RSS
#
# length of text in command
#invcdf for values in .95 put into k10; # get 95% chi value
invcdf .95 k10; # get 95% chi value
#
# length of command
# chisquare v=1.
chisquare 1.
#
let k11=k9*expo(k10/k2) # the bound
#
print k2
print k10
print k9
print k11
#
set c202
k3(k11)
end
name k11='upbound'
plot 'RSS'*'lambda' c202*'lambda';
overlay;
connect;
type 1;
title 'An Approximate 95% Confidence Interval for Lambda';
axis 2;
label 'Residual Sum of Square';
axis 1;
label 'Lambda Values'.
Note
Note ** The approximate 95% Confidence Interval for lambda consists
Note ** of those lambda values where RSS is less than
print k11
Note
Note ** Lambda Values and corresponding Residual Sum of Squares **
print 'lambda' 'RSS'
#
note -----------------------------
note macro etsuBOXCOX has finished
note -----------------------------
note
#
endmacro
Return to Price's home
page