Next: choosedef2() Up: Design Macros Help File Previous: boxcoxvec()   Contents

buildfactor()

Usage:
a <- buildfactor(jsub, dims, [,reverse:T]), integer jsub > 0, dims a
  vector of positive integers, length(dims) >= jsub



Keywords: anova, factorial
                                  Usage
fac_j <- buildfactor(j, dims) creates a factor corresponding to the
values of subscript j >= 1 for a balanced factorial design.  dims must
be a vector of positive integers with M = length(dims) >= j.

fac_j will be a factor with dims[j] levels, with N = length(fac_j) =
prod(dims), the product of the elements of dims.

fac_j may be used in an ANOVA of a balanced factorial experiment where
each case is identified by m <= M subscripts with the first changing
fastest and the last changing slowest, with subscript i running from 1
to dims[i].  When m < M, there will be N/prod(dims[run(m)])
replications.

fac_j <- buildfactor(j, dims, reverse:T), does the same except first
subscripts change slowest.  buildfactor(j, dims, reverse:T) is
equivalent to buildfactor(M+1-j, reverse(dims)).

Example:
  Cmd> dims <- vector(2,3,2,2)#for 2 x 3 x 2 in 2 reps

  Cmd> fac_1 <- buildfactor(1,dims)

  Cmd> fac_2 <- buildfactor(2,dims)

  Cmd> fac_3 <- buildfactor(3,dims)

  Cmd> print(fac_1,fac_2,fac_3,format:"1.0f")
  fac_1:
  (1) 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
  fac_2:
  (1) 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3
  fac_3:
  (1) 1 1 1 1 1 1 2 2 2 2 2 2 1 1 1 1 1 1 2 2 2 2 2 2

  Cmd> list(fac_1,fac_2,fac_3)
  fac_1           REAL   24    FACTOR with 2 levels
  fac_2           REAL   24    FACTOR with 3 levels
  fac_3           REAL   24    FACTOR with 2 levels

These factors could be used in analysis of two replicates of a 2 by 3 by
2 design in standard order, say by anova("y=fac_1+fac_2+fac_3").

  Cmd> print(buildfactor(2,dims,reverse:T),format:"1.0f")
  VECTOR:
  (1) 1 1 1 1 2 2 2 2 3 3 3 3 1 1 1 1 2 2 2 2 3 3 3 3

Compare this with fac_2 above.

                            Cross references
See also factor(), makefactor(), rep()


Gary Oehlert 2005-08-12