Description Usage Arguments Details Value Examples
Generate an ANOVA keyout for a given treatment and design structure
1 |
trt.formula |
A one-side formula specifying the treatment structure. See details for formula specification. Response variables are ignored if included. |
des.formula |
A one-sided formula specifying the design structure. The design structure must be fully specified to the level of experimental unit. See details for information. |
data |
A data frame containing all factors and interactions included in the treatment and design formula |
Stroup (2012) has noted how the ANOVA keyout can be a powerful modeling tool (ISBN 9781439815120). The approach can also be useful in helping students to gain an intuition for the implications of various experimental designs on statistical power and the impact of replication (or lack there of) at various scales/error strata. This function therefore takes a treatment and design structure, and a data frame and produces an anova keyout, usefully ordered and grouped, with error strata and both numerator and denominator degrees of freedom. Note that where data is not yet available (because the study is hypothetical or in the design phase), the expand.grid() function can be used to quickly and easily simulate data sets.
The relevant operators are: "/" to indicate nesting, "*" to indicate crossing, and ":" to indicate an interaction (useful for factorial experiments where the experimental unit is at the level of an interaction among several factors).
Thus, for a 2-factor factorial experiment the treatment structure would be ~ A*B, whereas if the levels of the B factor are nested in A, the treatment structure would be ~ A/B.
Similarly, design structures for common (simple) designs are sepcified as follows:
CRD design: ~ A:B/R (experimental units are nested at the level of A:B interaction)
RCB design: ~ R/A:B (experimental units at the level of A:B interaction are nested in blocks)
Split-Plot RCB: ~ R/A/B
Split-Block RCB: ~R/(A*B)
A data frame containing the fixed effects, levels, numerator DF, error strata and denominator DF. For all fixed effects sharing the same experimental unit/error strata, only the last in the list will have the error term or den DF, with others shown as NA.
1 2 3 4 5 6 7 8 9 10 11 | library(agridat)
data("cox.stripsplit")
# fit the model in lme using "Dalgaard's technique":
fit = lme(fixed = yield~ soil*fert*calcium, data = cox.stripsplit,
random = list(rep = ~1, rep = pdIdent(form = ~soil-1), rep = pdIdent(form = ~ fert-1), calcium = ~1))
# denDF are wrong:
fit$fixDF$terms
# fix DF
fit$fixDF$terms = ddfm(fit, ~ rep/(fert/calcium * soil))
# denDF are correct:
fit$fixDF$terms
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.