[R] help_aov

2006-10-30 Thread Thanjavur Bragadeesh
Hi,

I am trying to run an analysis of variance using R.
in my data table x is a continuous variable lengthof 200 and p is a 
categorical variable also of length 200 and p is anyone of three categories 
1,2 or ,3.
if I run
summary(aov(x~p,data=test))
I get
Response: x
 Df  Sum Sq Mean Sq F valuePr(F)
p   1  3174.7  3174.7  42.749 5.175e-10 ***
Residuals 198 14704.274.3
---
and if I run
summary(aov(x~as.factor(p), data=test)) # I get

Response: x
Df  Sum Sq  Mean Sq  F value   Pr(F)
as.factor(p)  2  3175.7  1587.8   21.275  4.31e-09 ***
Residuals   197  14703.274.6


Can anyone kindly explain the difference. How will it affect -correct way to 
run - if it is a two-way anova where I have a second categorical variable 
sex - male or female.

Many Thanks


Yours sincerely,

Bragadeesh

__
R-help@stat.math.ethz.ch 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.


Re: [R] help_aov

2006-10-30 Thread Peter Dalgaard
Thanjavur Bragadeesh [EMAIL PROTECTED] writes:

 Hi,
 
 I am trying to run an analysis of variance using R.
 in my data table x is a continuous variable lengthof 200 and p is a 
 categorical variable also of length 200 and p is anyone of three categories 
 1,2 or ,3.
 if I run
 summary(aov(x~p,data=test))
 I get
 Response: x
  Df  Sum Sq Mean Sq F valuePr(F)
 p   1  3174.7  3174.7  42.749 5.175e-10 ***
 Residuals 198 14704.274.3


If you get 1 DF for a variable with three different values, then it is
not a categorical variable from R's point of view, but a quantitative
one.  So you need x~factor(p) here like you have below. Or convert p
to a factor before the analysis.

 and if I run
 summary(aov(x~as.factor(p), data=test)) # I get
 
 Response: x
 Df  Sum Sq  Mean Sq  F value   Pr(F)
 as.factor(p)  2  3175.7  1587.8   21.275  4.31e-09 ***
 Residuals   197  14703.274.6
 
 
 Can anyone kindly explain the difference. How will it affect -correct way to 
 run - if it is a two-way anova where I have a second categorical variable 
 sex - male or female.
 
 Many Thanks
 
 
 Yours sincerely,
 
 Bragadeesh
 
 __
 R-help@stat.math.ethz.ch 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.
 

-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch 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.