Staleno:

As always, you need to read the Help file carefully. From ?aov:

"The main difference from lm is in the way print, summary and so on handle
the fit: this is expressed in the traditional language of the analysis of
variance rather than that of linear models. "

summary.aov() computes sequential ss. lm() uses the t-statistics for the
estimated coefficients. They are not the same if non-orthogonal contrasts
are used. Of course, the coefficients and fits **are** identical.

If you don't know what this means, consult a statistician or linear models
references.

-- Bert

On Mon, Jun 25, 2012 at 2:26 AM, Staleno <s...@bergen-plastics.no> wrote:

> Hello.
>
> I'm a new user of R, and I have a question regarding the use of aov and
> lm-functions. I'm doing a fractional factorial experiment at our production
> site, and I need to familiarize myself with the analysis before I conduct
> the experiment. I've been working my way through the examples provided at
> http://www.itl.nist.gov/div898/handbook/pri/section4/pri472.htm
> http://www.itl.nist.gov/div898/handbook/pri/section4/pri472.htm , but I
> can't get the results provided in the trial model calculations. Why is
> this.
> Here is how I have tried to do it:
>
> > data.catapult=read.table("Fractional.txt",header=T) #Read the data in the
> > table provided in the example.
>
> > data.catapult
>   Distance    h  s b l  e
> 1     28.00 3.25  0 1 0 80
> 2     99.00 4.00 10 2 2 62
> 3    126.50 4.75 20 2 4 80
> 4    126.50 4.75  0 2 4 45
> 5     45.00 3.25 20 2 4 45
> 6     35.00 4.75  0 1 0 45
> 7     45.00 4.00 10 1 2 62
> 8     28.25 4.75 20 1 0 80
> 9     85.00 4.75  0 1 4 80
> 10     8.00 3.25 20 1 0 45
> 11    36.50 4.75 20 1 4 45
> 12    33.00 3.25  0 1 4 45
> 13    84.50 4.00 10 2 2 62
> 14    28.50 4.75 20 2 0 45
> 15    33.50 3.25  0 2 0 45
> 16    36.00 3.25 20 2 0 80
> 17    84.00 4.75  0 2 0 80
> 18    45.00 3.25 20 1 4 80
> 19    37.50 4.00 10 1 2 62
> 20   106.00 3.25  0 2 4 80
>
> > aov.catapult =
> >
> aov(Distance~h+s+b+l+e+h*s+h*b+h*l+h*e+s*b+s*l+s*e+b*l+b*e+l*e,data=data.catapult)
> > summary(aov.catapult)
>            Df Sum Sq Mean Sq F value  Pr(>F)
> h            1   2909    2909  15.854 0.01638 *
> s            1   1964    1964  10.701 0.03076 *
> b            1   7537    7537  41.072 0.00305 **
> l            1   6490    6490  35.369 0.00401 **
> e            1   2297    2297  12.518 0.02406 *
> h:s          1    122     122   0.667 0.45998
> h:b          1    345     345   1.878 0.24247
> h:l          1    354     354   1.929 0.23724
> h:e          1      0       0   0.001 0.97578
> s:b          1    161     161   0.877 0.40199
> s:l          1     20      20   0.107 0.75966
> s:e          1    114     114   0.622 0.47427
> b:l          1    926     926   5.049 0.08795 .
> b:e          1    124     124   0.677 0.45689
> l:e          1    158     158   0.860 0.40623
> Residuals    4    734     184
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> This seems just about right to me. However, when I attempt to make the
> linear model, based on main factors and two-factor interactions, I get a
> completely different result:
>
> > lm.catapult =
> >
> lm(Distance~h+s+b+l+e+h*s+h*b+h*l+h*e+s*b+s*l+s*e+b*l+b*e+l*e,data=data.catapult)
> > summary(lm.catapult)
>
> Call:
> lm(formula = Distance ~ h + s + b + l + e + h * s + h * b + h *
>    l + h * e + s * b + s * l + s * e + b * l + b * e + l * e,
>    data = data.catapult)
>
> Residuals:
>      1       2       3       4       5       6       7       8       9
> 10
> -0.8100 22.3875 -3.6763 -3.8925 -3.8925 -0.8576  7.0852 -0.8100 -0.8100
> -0.8576
>     11      12      13      14      15      16      17      18      19
> 20
> -0.8576 -0.8576  7.8875 -3.8925 -3.8925 -3.6763 -3.6763 -0.8100 -0.4148
> -3.6763
>
> Coefficients:
>              Estimate Std. Error t value Pr(>|t|)
> (Intercept)  25.031042 100.791955   0.248   0.8161
> h            -3.687500  22.466457  -0.164   0.8776
> s             0.475446   2.446791   0.194   0.8554
> b           -39.417973  44.906164  -0.878   0.4296
> l           -18.938988  12.233954  -1.548   0.1965
> e            -0.158449   1.230683  -0.129   0.9038
> h:s          -0.368750   0.451546  -0.817   0.4600
> h:b          12.375000   9.030925   1.370   0.2425
> h:l           3.135417   2.257731   1.389   0.2372
> h:e           0.008333   0.258026   0.032   0.9758
> s:b          -0.634375   0.677319  -0.937   0.4020
> s:l          -0.055469   0.169330  -0.328   0.7597
> s:e           0.015268   0.019352   0.789   0.4743
> b:l           7.609375   3.386597   2.247   0.0879 .
> b:e           0.318397   0.387008   0.823   0.4569
> l:e           0.089732   0.096760   0.927   0.4062
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 13.55 on 4 degrees of freedom
> Multiple R-squared: 0.9697,     Adjusted R-squared: 0.8563
> F-statistic: 8.545 on 15 and 4 DF,  p-value: 0.02559
>
> This result is nothing like the results provided in the example. Why is
> this? Any help is very much appreciated.
>
> Regards, Ståle.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Fractional-Factorial-Wrong-values-using-lm-function-tp4634400.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to