Description Usage Arguments Value Author(s) References See Also Examples
View source: R/summaryAovTwoPhase.R
Computes the coefficients of the variance components for the expected mean squares for twophase 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.
1 2 3 4 
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 firstphase experiment using the WilkinsonRogers' syntax. 
blk.str2 
a single string of characters containing the structural formula for the block factors of the secondphase experiment using the WilkinsonRogers' syntax. 
trt.str 
a single string of characters containing the structural formula for the treatment factors using the WilkinsonRogers' 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 firstphase 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 
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.
Kevin Chang
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), 163178.
Wilkinson GN, Rogers CE (1973). "Symbolic Description of Factorial Models for Analysis of Variance." Applied Statistics, 22(3), 392399.
terms
for more information on the structural
formula.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68  #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)
})
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") )

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.