Next: buildfactor() Up: Design Macros Help File Previous: allaliases2()   Contents

# boxcoxvec()

Usage:
 boxcoxvec(Model [,powers:pow]), CHARACTER scalar Model, REAL vector pow boxcoxvec(rhs_model,y[,powers:pow]), CHARACTER scalar rhs_model, REAL vectors y and pow.

Keywords: ANOVA, analysis
boxcoxvec(Model, powers:Pow), where Model is a CHARACTER scalar
specifying a GLM model of the form "y = Rhs", computes the error SS for
y transformed to the boxcox powers given in Pow.  Example: Model =
"yield = x + a + b", where response yield is a REAL vector, x is a
variate and a and b are factors.  For this model Rhs is "x + a + b".

Any factors or variates in Rhs must have the same length as y.  In the
example, x, a, and b must all be the same length as yield.

If powers:Pow is omitted, the default is Pow = run(-1,2,.25)

For each power P in Pow, the model "{boxcox(y,P)} = RHS" is fit using
anova() and the error SS is saved.  The value returned by boxcoxvec()
is structure(power:Pow, SS:Ss), where Pow and Ss are vectors of powers
and error sums of squares.

boxcoxvec(Rhs,y [,powers:Pow]), where Rhs is a quoted string or
CHARACTER, does the same as boxcoxvec("y = Rhs" [,powers:Pow]).  This
somewhat clumsier usage is maintained for backward compatibility.

A power that minimizes the error SS may be chosen to transform the data
for analysis.

Examples:
Cmd> y <- rnorm(20);ey <- exp(y)
NOTE: random number seeds set to 59622139 and 172924584

Cmd> a <- factor(rep(run(5),4))

Cmd> boxcoxvec("ey = a")  # default powers; or boxcoxvec("a", ey)
component: power
(1)           -1        -0.75         -0.5        -0.25            0
(6)         0.25          0.5         0.75            1         1.25
(11)          1.5         1.75            2
component: SS
(1)       179.93       72.889       34.971       21.487       17.979
(6)       20.624       31.191       58.929       131.81       332.94
(11)       915.71         2673       8140.8

Cmd> boxcoxvec("ey = a",powers:run(-.25,.25,1/16))#explore powers ~= 0
component: power
(1)        -0.25      -0.1875       -0.125      -0.0625            0
(6)       0.0625        0.125       0.1875         0.25
component: SS
(1)       21.487       19.938       18.875       18.236       17.979
(6)       18.083       18.544        19.38       20.624

Cmd> lineplot(boxcoxvec("ey = a"),title:"Resid SS vs Powers")#graph it