[R-sig-teaching] Analyze Nested and Split-Plot Designs with R

Steven Stoline sstoline at gmail.com
Thu Jan 8 21:04:55 CET 2015


Dear Rich:

First thank you very much. it helped a lot.

The F value and its p-values corresponding to the factor "Supplier"are
different from the ones in the textbook, Montgomery 8th ed. But conclusion
stay same (Pvalue > 0.05)



In the last model (the third one) used for Table 14.6 , I am not sure what
is wrong.


> MontEx14.1.aov3 <- aov(Purity ~ Supplier + Error(Supplier:Batch),
data=MontEx14.1)

Warning message:

In aov(Purity ~ Supplier + Error(Supplier:Batch), data = MontEx14.1) :
  Error() model is singular




many thanks
Steven

On Thu, Jan 8, 2015 at 1:58 PM, Richard M. Heiberger <rmh at temple.edu> wrote:

> Steven,
>
> I assume you mean Montgomery 8th edition (he changed chapter numbers
> recently).
>
> Please state what you expect as output.
>
> For your first attempt, you have the case wrong (purity instead of Purity).
>
> Are you reading Supplier and Batch as factors.  It can't be determined
> from the
> printed table in your email.  Use dump (or dput) next time.   dput is
> designed for R.
>
> With the above corrections, your first model formula gives Table 14.4
> and your second
> formula gives Table 14.5.
>
> To get Table 14.6 you need to use the Error() function in the model
> formula.
> Here are statements for all three tables.
>
> Rich
>
> ## dump("MontEx14.1","")
> MontEx14.1 <-
> structure(list(Supplier = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
> 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("1",
> "2", "3"), class = "factor"), Batch = structure(c(1L, 1L, 1L,
> 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 2L, 3L,
> 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L,
> 4L), .Label = c("1", "2", "3", "4"), class = "factor"), Purity = c(1L,
> -1L, 0L, -2L, -3L, -4L, -2L, 0L, 1L, 1L, 4L, 0L, 1L, -2L, -3L,
> 0L, 4L, 2L, -1L, 0L, -2L, 0L, 3L, 2L, 2L, 4L, 0L, -2L, 0L, 2L,
> 1L, -1L, 2L, 3L, 2L, 1L)), .Names = c("Supplier", "Batch", "Purity"
> ), row.names = c(NA, -36L), class = "data.frame")
>
>
>
> MontEx14.1$Supplier <- factor(MontEx14.1$Supplier)
> MontEx14.1$Batch <- factor(MontEx14.1$Batch)
>
> MontEx14.1.aov1 <- aov(Purity ~ Supplier/Batch, data=MontEx14.1)
> summary(MontEx14.1.aov1)
>
> MontEx14.1.aov2 <- aov(Purity ~ Supplier*Batch, data=MontEx14.1)
> summary(MontEx14.1.aov2)
>
> MontEx14.1.aov3 <- aov(Purity ~ Supplier + Error(Supplier:Batch),
> data=MontEx14.1)
> summary(MontEx14.1.aov3)
>
>
> On Thu, Jan 8, 2015 at 1:06 PM, Steven Stoline <sstoline at gmail.com> wrote:
> > Dear All:
> >
> > example 14.1, Montgomery, chapter 14. *Supplier* is a *fixed factor*,
> > *Batches* is a *random factor* nested within the fixed factor Supplier.
> >
> > How to analyze these data in R in two ways:
> >
> > 1- Nested Design
> >
> > fit <- aov(purity~Supplier/Batch)
> >
> >
> > it did not give me the expected output.
> >
> >
> > 2- as a factorial (suppliers Fixed, Batches Random)
> >
> > fit.out <- aov(Purity~Supplier*Batch, data=have)
> >
> > it did not give me the expected output.
> >
> >
> > Here is the data set:
> > ===============
> >
> >> data
> >   Supplier Batch  Purity
> > 1     1  1
> > 1     1 -1
> > 1     1  0
> > 1     2 -2
> > 1     2 -3
> > 1     2 -4
> > 1     3 -2
> > 1     3  0
> > 1     3  1
> > 1     4  1
> > 1     4  4
> > 1     4  0
> > 2     1  1
> > 2     1 -2
> > 2     1 -3
> > 2     2  0
> > 2     2  4
> > 2     2  2
> > 2     3 -1
> > 2     3  0
> > 2     3 -2
> > 2     4  0
> > 2     4  3
> > 2     4  2
> > 3     1  2
> > 3     1  4
> > 3     1  0
> > 3     2 -2
> > 3     2  0
> > 3     2  2
> > 3     3  1
> > 3     3 -1
> > 3     3  2
> > 3     4  3
> > 3     4  2
> > 3     4  1
> >
> >
> > many thanks
> > Steven
> >
> > --
> > Steven M. Stoline
> > 1123 Forest Avenue
> > Portland, ME 04112
> > sstoline at gmail.com
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-teaching at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
>



-- 
Steven M. Stoline
1123 Forest Avenue
Portland, ME 04112
sstoline at gmail.com

	[[alternative HTML version deleted]]



More information about the R-sig-teaching mailing list