Re: [R] Why F value and Pr are not show in summary() of an aov() result?

2009-11-22 Thread Sundar Dorai-Raj
It's hard to read your code, so I won't comment on your specific
example. So when all else fails read the documentation for
?summary.aov:

They have columns ‘"Df"’, ‘"Sum Sq"’, ‘"Mean
 Sq"’, as well as ‘"F value"’ and ‘"Pr(>F)"’ if there are non-zero
 residual degrees of freedom.

So if you do df.residual(afit), is it >0?

--sundar

On Sun, Nov 22, 2009 at 7:19 AM, Peng Yu  wrote:
> I have the following code. I'm wondering why summary() doesn't show F
> value and Pr?
>
> Rscript multi_factor.R
>> a=3
>> b=4
>> c=5
>> d=6
>> e=7
>>
>> A=1:a
>> B=1:b
>> C=1:c
>> D=1:d
>> E=1:e
>>
>> X=matrix(nr=a*b*c*d*e,nc=5)
>> colnames(X)=LETTERS[1:5]
>>
>> for(i_a in 1:a-1) {
> +   for(i_b in 1:b-1) {
> +     for(i_c in 1:c-1) {
> +       for(i_d in 1:d-1) {
> +         for(i_e in 1:e-1) {
> +           X[(((i_a * b + i_b) * c + i_c) * d + i_d) * e + i_e + 1, ]
> = c(i_a+1, i_b+1, i_c+1, i_d+1, i_e+1)
> +         }
> +       }
> +     }
> +   }
> + }
>>
>> Y=matrix(nr=a*b*c*d*e,nc=1)
>> for(i in 1:(a*b*c*d*e)) {
> +   fa=X[i,'A']
> +   fb=X[i,'B']
> +   fc=X[i,'C']
> +   fd=X[i,'D']
> +   fe=X[i,'E']
> +
> +   Y[i,1]= fa +fb +fc +fe +fa*fb +fa*fc +fb*fc +fa*fe +fc*fe
> +fa*fb*fc +fa*fc*fe + rnorm(1)
> + }
>>
>> aframe = data.frame(
> +     A=as.factor(X[,'A'])
> +     , B=as.factor(X[,'B'])
> +     , C=as.factor(X[,'C'])
> +     , D=as.factor(X[,'D'])
> +     , E=as.factor(X[,'E'])
> +     ,Y)
>>
>> afit=aov(Y ~ A * B * C * D * E, aframe)
>>
>> summary(afit)
>             Df  Sum Sq Mean Sq
> A             2 1512240  756120
> B             3  453324  151108
> C             4 2549895  637474
> D             5       2  0.3693
> E             6 1451057  241843
> A:B           6   33875    5646
> A:C           8  189839   23730
> B:C          12   56024    4669
> A:D          10       7       1
> B:D          15      25       2
> C:D          20      18       1
> A:E          12  107574    8964
> B:E          18      21       1
> C:E          24  180413    7517
> D:E          30      16       1
> A:B:C        24    4167     174
> A:B:D        30      37       1
> A:C:D        40      42       1
> B:C:D        60      63       1
> A:B:E        36      30       1
> A:C:E        48   13298     277
> B:C:E        72      62       1
> A:D:E        60      79       1
> B:D:E        90      87       1
> C:D:E       120     122       1
> A:B:C:D     120     140       1
> A:B:C:E     144     131       1
> A:B:D:E     180     145       1
> A:C:D:E     240     225       1
> B:C:D:E     360     398       1
> A:B:C:D:E   720     713       1
>
> __
> 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.
>

__
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.


[R] Why F value and Pr are not show in summary() of an aov() result?

2009-11-22 Thread Peng Yu
I have the following code. I'm wondering why summary() doesn't show F
value and Pr?

Rscript multi_factor.R
> a=3
> b=4
> c=5
> d=6
> e=7
>
> A=1:a
> B=1:b
> C=1:c
> D=1:d
> E=1:e
>
> X=matrix(nr=a*b*c*d*e,nc=5)
> colnames(X)=LETTERS[1:5]
>
> for(i_a in 1:a-1) {
+   for(i_b in 1:b-1) {
+ for(i_c in 1:c-1) {
+   for(i_d in 1:d-1) {
+ for(i_e in 1:e-1) {
+   X[(((i_a * b + i_b) * c + i_c) * d + i_d) * e + i_e + 1, ]
= c(i_a+1, i_b+1, i_c+1, i_d+1, i_e+1)
+ }
+   }
+ }
+   }
+ }
>
> Y=matrix(nr=a*b*c*d*e,nc=1)
> for(i in 1:(a*b*c*d*e)) {
+   fa=X[i,'A']
+   fb=X[i,'B']
+   fc=X[i,'C']
+   fd=X[i,'D']
+   fe=X[i,'E']
+
+   Y[i,1]= fa +fb +fc +fe +fa*fb +fa*fc +fb*fc +fa*fe +fc*fe
+fa*fb*fc +fa*fc*fe + rnorm(1)
+ }
>
> aframe = data.frame(
+ A=as.factor(X[,'A'])
+ , B=as.factor(X[,'B'])
+ , C=as.factor(X[,'C'])
+ , D=as.factor(X[,'D'])
+ , E=as.factor(X[,'E'])
+ ,Y)
>
> afit=aov(Y ~ A * B * C * D * E, aframe)
>
> summary(afit)
 Df  Sum Sq Mean Sq
A 2 1512240  756120
B 3  453324  151108
C 4 2549895  637474
D 5   2  0.3693
E 6 1451057  241843
A:B   6   338755646
A:C   8  189839   23730
B:C  12   560244669
A:D  10   7   1
B:D  15  25   2
C:D  20  18   1
A:E  12  1075748964
B:E  18  21   1
C:E  24  1804137517
D:E  30  16   1
A:B:C244167 174
A:B:D30  37   1
A:C:D40  42   1
B:C:D60  63   1
A:B:E36  30   1
A:C:E48   13298 277
B:C:E72  62   1
A:D:E60  79   1
B:D:E90  87   1
C:D:E   120 122   1
A:B:C:D 120 140   1
A:B:C:E 144 131   1
A:B:D:E 180 145   1
A:C:D:E 240 225   1
B:C:D:E 360 398   1
A:B:C:D:E   720 713   1

__
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.