Next: Graphics Macros Help File Up: Design Macros Help File Previous: typeIIIss()   Contents


varcomp(model,randomvars [,marg:T] [,restrict:F] [,nonhier:T]),
  CHARACTER scalar model, CHARACTER vector randomvars
varcomp(emsResult), emsResult a structure returned by ems() with keep:T.

Keywords: anova, analysis, random effects, factorial
varcomp(model, randomvars) computes the "ANOVA" estimates of the
variances of random effects in mixed effects analysis of variance as
well as estimates of their standard errors.  model is a CHARACTER scalar
or a quoted string specifying an ANOVA model and randomvars is a
CHARACTER vector of the names of some or all of the factors in the
model.  You can also use keyword phrases marg:T, restrict:F and
nonhier:T exactly as for macro ems().

varcomp(emsResult), where emsResult is computed as ems(model,
randomvars, keep:T) does the same.

The estimates are linear combinations of mean squares for random
effects.  They are unbiased but may be negative.

The value of varcomp() is a matrix with one row for each random term and
two columns giving the estimated variance component and its standard

varcomp(model, randomvars, marg:T) and varcomp(emsResult, marg:T) do the
same but use linear combinations of "marginal" EMS, that is the EMS for
each term is computed after adjusting for all other terms in the model.

varcomp() assumes that the EMS for random terms have no contributions from
fixed factors.  This is true for balanced data and may be guaranteed in
general by using marg:T.

Example.  Three populations, all crosses between 4 males and 4 females
in each population with six offspring from each mating randomly assigned
to three environments.  Male and female are random.  First the simple

  Cmd> anova("y=(pop+m.pop+f.pop+m.f.pop)*env")
  Model used is y=(pop+m.pop+f.pop+m.f.pop)*env
                  DF           SS           MS
  CONSTANT         1       5.4299       5.4299
  pop              2       2091.4       1045.7
  pop.m            9        112.5         12.5
  pop.f            9       370.02       41.113
  pop.m.f         27       56.774       2.1027
  env              2       206.15       103.08
  pop.env          4      0.16527     0.041316
  pop.m.env       18       3.4185      0.18992
  pop.f.env       18       8.2354      0.45752
  pop.m.f.env     54       17.117      0.31698
  ERROR1         144       30.448      0.21144

Now compute the expected mean squares, and keep the ems() output.

  Cmd> emsstuff<-ems("y=(pop+m.pop+f.pop+m.f.pop)*env",vector("m","f"),
  EMS(CONSTANT) = V(ERROR1) + 6V(pop.m.f) + 24V(pop.f) + 24V(pop.m) +
  EMS(pop) = V(ERROR1) + 6V(pop.m.f) + 24V(pop.f) + 24V(pop.m) + 96Q(pop)
  EMS(pop.m) = V(ERROR1) + 6V(pop.m.f) + 24V(pop.m)
  EMS(pop.f) = V(ERROR1) + 6V(pop.m.f) + 24V(pop.f)
  EMS(pop.m.f) = V(ERROR1) + 6V(pop.m.f)
  EMS(env) = V(ERROR1) + 2V(pop.m.f.env) + 8V(pop.f.env) +
     8V(pop.m.env) + 96Q(env)
  EMS(pop.env) = V(ERROR1) + 2V(pop.m.f.env) + 8V(pop.f.env) +
     8V(pop.m.env) + 32Q(pop.env)
  EMS(pop.m.env) = V(ERROR1) + 2V(pop.m.f.env) + 8V(pop.m.env)
  EMS(pop.f.env) = V(ERROR1) + 2V(pop.m.f.env) + 8V(pop.f.env)
  EMS(pop.m.f.env) = V(ERROR1) + 2V(pop.m.f.env)

From the EMS, we see than (MS(pop.m.f.env)-MS(ERROR1))/2 is an unbiased
estimate of V(m.f.env); here, we have (.31698 - .21144)/2 = .05277.
Similarly, (MS(pop.f.env)-MS(pop.m.f.env))/8 is an unbiased estimate of
V(f.env); here we have (.45752 - .31698)/8 = .01757.  varcomp()
automates these calculations, as well as providing the standard error.

  Cmd> varcomp(emsstuff)
                 Estimate           SE
  pop.m           0.43323      0.24668
  pop.f            1.6254      0.80788
  pop.m.f         0.31521     0.095472
  pop.m.env     -0.015883     0.010989
  pop.f.env      0.017568     0.020532
  pop.m.f.env    0.052766     0.032948
  ERROR1          0.21144     0.024919

Note that variance component estimates can be negative; varcomp() does
not truncate the estimates at 0.  We would get the same output from the
following command.

   Cmd> varcomp("y=(pop+m.pop+f.pop+m.f.pop)*env",vector("m","f"))

See also ems(), mixed().

Gary Oehlert 2003-01-15