summaryAovTwoPhase {infoDecompuTE} | R Documentation |
Summarize an Theoretical Analysis of Variance Model of Two-Phase Experiments
Description
Computes the coefficients of the variance components for the expected mean squares for two-phase experiments. The function accepts a data frame of the experimental design with the structural formulae of the block and treatment factors. Two tables containing the variance components of the random effects and fixed effects are returned.
Usage
summaryAovTwoPhase(
design.df,
blk.str1,
blk.str2,
trt.str,
var.comp = NA,
blk.contr = NA,
trt.contr = NA,
table.legend = FALSE,
response = NA,
latex = FALSE,
fixed.names = NA,
decimal = FALSE,
digits = 2,
list.sep = TRUE
)
Arguments
design.df |
a data frame containing the experimental design. Requires
every column be a |
blk.str1 |
a single string of characters containing the structural formula for the block factors of the first-phase experiment using the Wilkinson-Rogers' syntax. |
blk.str2 |
a single string of characters containing the structural formula for the block factors of the second-phase experiment using the Wilkinson-Rogers' syntax. |
trt.str |
a single string of characters containing the structural formula for the treatment factors using the Wilkinson-Rogers' syntax. |
var.comp |
a vector of characters containing the variance components
of interest this allows the user to specify the variance components to be
shown on the ANOVA table. This also allows the user to specify artificial
stratum to facilitate decomposition. Default is |
blk.contr |
a list of first-phase block contrast vectors, this allows
the user to specify the contrasts for each block factor in the first phase
experiment. Note that if this argument is used, it is necessary to specify
the contrasts for every treatment factor with the same order as
|
trt.contr |
a list of treatment contrast vectors, this allows the user
to specify the contrasts for each treatment factor. Note that if this
argument is used, it is necessary to specify the contrasts for every
treatment factor with the same order as |
table.legend |
a logical allows the users to use the legend for the
variance components of the ANOVA table for a large design. Default is
|
response |
a numeric vector contains the responses from the experiment. |
latex |
a logical allows the users to output the Latex script to Latex
table. Once the Latex script is generated, it requires the user to install
and load two Latex packages: |
fixed.names |
a vector of character allows the users to modify symbols for the fixed effects for the Latex outputs. |
decimal |
a logical allows users to display the coefficients as the
decimals. Default is |
digits |
a integer indicating the number of decimal places. Default is 2, resulting in 2 decimal places. |
list.sep |
a logical allows users to present the efficiency factors
and coefficients of the fixed effects a list of separate matrices. Default
is |
Value
The values returned depends on the value of the table.legend
argument. If table.legend = FALSE
, this function will return a list
of two data frames. The first data frame contains the random effects and
the second data frame contains the fixed effects. If the
table.legend
argument is TRUE
, then it will return a list
containing two lists. The first list consists of a data frame of random
effects and a character string for the legend. The second list consists of
a data frame of fixed effects and a character string for the legend. If
response
argument is used, the random effect table will have one
extra column with of mean squares computed from the responses from the
experiment.
Author(s)
Kevin Chang
References
John J, Williams E (1987). Cyclic and computer generated Designs. Second edition. Chapman & Hall.
Nelder JA (1965b). "The Analysis of Randomized Experiments with Orthogonal Block Structure. II. Treatment Structure and the General Analysis of Variance." Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences, 283(1393), 163-178.
Wilkinson GN, Rogers CE (1973). "Symbolic Description of Factorial Models for Analysis of Variance." Applied Statistics, 22(3), 392-399.
See Also
terms
for more information on the structural
formula.
Examples
#Phase 2 experiment
design2 <- local({
Run = as.factor(rep(1:4, each = 4))
Ani = as.factor(LETTERS[c(1,2,3,4,
5,6,7,8,
3,4,1,2,
7,8,5,6)])
Sam = as.factor(as.numeric(duplicated(Ani)) + 1)
Tag = as.factor(c(114,115,116,117)[rep(1:4, 4)])
Trt = as.factor(c("healthy", "diseased")[c(1,2,1,2,
2,1,2,1,
1,2,1,2,
2,1,2,1)])
data.frame(Run, Ani, Sam, Tag, Trt, stringsAsFactors = TRUE)
})
design2
summaryAovTwoPhase(design2, blk.str1 = "Ani", blk.str2 = "Run",
trt.str = "Tag + Trt")
#Add the sample into the Phase 1 block structure
summaryAovTwoPhase(design2, blk.str1 = "Ani/Sam", blk.str2 = "Run",
trt.str = "Tag + Trt")
#Assuming there is crossing between the animals and samples
summaryAovTwoPhase(design2, blk.str1 = "Ani*Sam", blk.str2 = "Run",
trt.str = "Tag + Trt")
#Set Artificial stratum
design2$AniSet = as.factor(c(2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1))
design2
summaryAovTwoPhase(design2, blk.str1 = "Ani/Sam", blk.str2 = "AniSet/Run",
trt.str = "Tag + Trt", var.comp = c("Ani:Sam", "Ani", "Run"))
#Define traetment contrasts
TagA = rep(c(1,1,-1,-1),time = 4)
TagB = rep(c(1,-1,1,-1),time = 4)
TagC = TagA * TagB
Tag = list(TagA = TagA, TagB = TagB, TagC = TagC)
Tag
Trt = as.numeric(design2$Trt)-1.5
Trt
summaryAovTwoPhase(design2, blk.str1 = "Ani/Sam", blk.str2 = "Run",
trt.str = "Tag + Trt",
trt.contr = list(Tag = list(TagA = TagA, TagB = TagB, TagC = TagC), Trt = Trt),
table.legend = TRUE)
#Compute MS
set.seed(527)
summaryAovTwoPhase(design2, blk.str1 = "Ani/Sam", blk.str2 = "Run",
trt.str = "Tag + Trt", response = rnorm(16))$ANOVA
#Generate Latex scripts
summaryAovTwoPhase(design2, blk.str1 = "Ani/Sam", blk.str2 = "Run",
trt.str = "Tag + Trt", latex = TRUE, fixed.names = c("\\gamma", "\\tau"))
#Generate Latex scripts with MS
set.seed(527)
summaryAovTwoPhase(design2, blk.str1 = "Ani/Sam", blk.str2 = "Run",
trt.str = "Tag + Trt", response = rnorm(16), latex = TRUE,
fixed.names = c("\\gamma", "\\tau") )