# [R] 4^2 factorial help

Paul Smith phhs80 at gmail.com
Fri Aug 18 13:23:29 CEST 2006

```On 8/18/06, Correia, L, Mr <lcorreia at sun.ac.za> <lcorreia at sun.ac.za> wrote:
> To whom it may concern:
>
> I am trying a factorial design a system of mine that has two factors.
> Each factor was set at four different levels, with one replication for
> each of the combinations. My data is as follows:
>
>
>            A           B                     Response
>
> 1        600        2.5                   0.0257
>
> 2        600        2.5                   0.0254
>
> 3        600        5                      0.0217
>
> 4        600        5                      0.0204
>
> 5        600        10                    0.0191
>
> 6        600        10                    0.0210
>
> 7        600        20                    0.0133
>
> 8        600        20                    0.0139
>
> 9        800        2.5                   0.0312
>
> 10       800       2.5                   0.0317
>
> 11       800       5                      0.0307
>
> 12       800      5                      0.0309
>
> 13       800       10                    0.0330
>
> 14       800       10                    0.0318
>
> 15       800       20                    0.0225
>
> 16       800       20                    0.0234
>
> 17      1000      2.5                   0.0350
>
> 18      1000      2.5                   0.0352
>
> 19      1000      5                      0.0373
>
> 20      1000      5                      0.0361
>
> 21      1000     10                    0.0432
>
> 22      1000     10                    0.0402
>
> 23      1000     20                    0.0297
>
> 24      1000     20                    0.0306
>
> 25      1200      2.5                   0.0324
>
> 26      1200      2.5                   0.0326
>
> 27      1200      5                      0.0353
>
> 28      1200      5                      0.0353
>
> 29      1200     10                    0.0453
>
> 30      1200     10                    0.0436
>
> 31      1200     20                    0.0348
>
> 32      1200     20                    0.0357
>
>
>
> I am able to enter my data into R and obtain an ANOVA table (which I
> have been able to verify as correct using an excel spreadsheet), using
> the following syntax:
>
>
>
> >Factorial<-data.frame(A=c(rep(c("600", "600", "600", "600", "800",
> "800", "800", "800", "1000", "1000", "1000", "1000", "1200", "1200",
> "1200", "1200"), each=2)), B=c(rep(c("2.5", "5", "10", "20", "2.5", "5",
> "10", "20", "2.5", "5", "10", "20", "2.5", "5", "10", "20"), each=2)),
> Response = c(0.0257, 0.0254, 0.0217, 0.0204, 0.0191, 0.021, 0.0133,
> 0.0139, 0.0312, 0.0317, 0.0307, 0.0309, 0.033, 0.0318, 0.0225, 0.0234,
> 0.035, 0.0352, 0.0373, 0.0361, 0.0432, 0.0402, 0.0297, 0.0306, 0.0324,
> 0.0326, 0.0353, 0.0353, 0.0453, 0.0436, 0.0348, 0.0357))
>
>
>
> > anova(aov(Response~A*B, data=Factorial))
>
>
>
> However, this is as far as I am able to go. I would like to obtain the
> coefficients of my model, but am unable. I would also like to use other
> non-linear models as these factors are not linear. Also would like to
> add A^2 and B^2 into the ANOVA and modeling.

Try:

model <- lm(Response~A*B, data=Factorial)
anova(model)

Paul

```