Hi,
I'm trying to analyse some data I have imported into R from a .csv file but
when I carry out the aov command the results show only one degree of freedom
when there should be 14. Does anyone know why? I'd really appreciate some
help, the data is pasted below.
/The imported table looks ike this this:/
Order Transect Sample Abundance
1 Coleoptera 1 1 13
2 Coleoptera 1 2 12
3 Coleoptera 1 3 11
4 Coleoptera 1 4 13
5 Coleoptera 1 5 6
6 Coleoptera 2 1 18
7 Coleoptera 2 2 18
8 Coleoptera 2 3 16
9 Coleoptera 2 4 21
10 Coleoptera 2 5 11
11 Coleoptera 3 1 19
12 Coleoptera 3 2 16
13 Coleoptera 3 3 9
14 Coleoptera 3 4 32
15 Coleoptera 3 5 29
/The command I am using is this:/
anova2<-aov(Abundance~Transect,data=beetle)
/The results come out like this:/
Df Sum Sq Mean Sq F value Pr(>F)
Transect 1 250.00 250.000 7.2394 0.01852 *
Residuals 13 448.93 34.533
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
Cheers,
Sam
--
View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3887528.html
Sent from the R help mailing list archive at Nabble.com.
ANOVA from imported data has only 1 degree of freedom
7 messages · David Winsemius, shardman, Ben Bolker
On Oct 9, 2011, at 11:10 AM, shardman wrote:
Hi, I'm trying to analyse some data I have imported into R from a .csv file but when I carry out the aov command the results show only one degree of freedom when there should be 14. Does anyone know why? I'd really appreciate some help, the data is pasted below.
To me this appears likely to be homework. If so then please read your college's rules regarding academic honesty. In any case, please read the Posting Guide.
/The imported table looks ike this this:/
Order Transect Sample Abundance
1 Coleoptera 1 1 13
2 Coleoptera 1 2 12
3 Coleoptera 1 3 11
4 Coleoptera 1 4 13
5 Coleoptera 1 5 6
6 Coleoptera 2 1 18
7 Coleoptera 2 2 18
8 Coleoptera 2 3 16
9 Coleoptera 2 4 21
10 Coleoptera 2 5 11
11 Coleoptera 3 1 19
12 Coleoptera 3 2 16
13 Coleoptera 3 3 9
14 Coleoptera 3 4 32
15 Coleoptera 3 5 29
/The command I am using is this:/
anova2<-aov(Abundance~Transect,data=beetle)
/The results come out like this:/
Df Sum Sq Mean Sq F value Pr(>F)
Transect 1 250.00 250.000 7.2394 0.01852 *
Residuals 13 448.93 34.533
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
Cheers,
Sam
--
View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3887528.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at 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.
David Winsemius, MD West Hartford, CT
Hi David, Thanks for your message. I can assure you this is not homework. I'm working on an ecology project and am trying to analyse the results from the fieldwork. I don't want other people to do the work for me I was just hoping someone might be able to spot where I have made a mistake, I'm still teaching myself to use R after having used SPSS for a long time. I did read the posting guidelines but couldn't see any reason not to ask for help, I'm sorry if I've got it wrong, Yours, Sam -- View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3887979.html Sent from the R help mailing list archive at Nabble.com.
On Oct 9, 2011, at 2:08 PM, shardman wrote:
Hi David, Thanks for your message. I can assure you this is not homework. I'm working on an ecology project and am trying to analyse the results from the fieldwork. I don't want other people to do the work for me I was just hoping someone might be able to spot where I have made a mistake, I'm still teaching myself to use R after having used SPSS for a long time. I did read the posting guidelines but couldn't see any reason not to ask for help, I'm sorry if I've got it wrong,
Please read the Posting Guide again. Nabble is not the standard venue where people read this list and you seem to have missed the part where the PG asked you to include relevant context in replies. It also also asks you to describe your scientific domain (which you have now done) and academic position (at least in part so the list can remain non- homework oriented). My memory from your initial posting was that you had numeric identifiers for you groups and did not wrap the group variable name in factor(), so it was treated as a continuous variable. Doesn't SPSS have some mechanism to flag a variable as discrete? Perhaps(from memory) something along these lines: aov(outcome ~ factor(group), data=dat) (Further comments from memory of earlier posting.) You also were asking why there were not 14 df in the output but there were since 1+13 = 14. Surely you were not expecting 14 df to be associated with the grouping variable when there were only 3 groups?
Yours, Sam -- View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3887979.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at 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.
David Winsemius, MD West Hartford, CT
Hi David, Apologies again and thankyou for your help, I've edited my original post to clarify what I was asking. What I meant was that the factor had only 1 degrees of freedom when it should have had 2 (14 in total), so you're right there were 14 but not in the right place. In SPSS you select one column as a factor and another as a dependent variable so this wouldn't happen, it's easy to use but not that versatile and very expensive. I've been told good things about R so I'm trying to teach myself. I followed your suggestion and I now have the results I need, I'll take more care with posting in future, Yours, Sam -- View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3888322.html Sent from the R help mailing list archive at Nabble.com.
shardman <samuelhardman <at> hotmail.com> writes:
Hi,
I'm trying to analyse some data I have imported into R from a .csv file but
when I carry out the aov command the results show only one degree of freedom
when there should be 14. Does anyone know why? I'd really appreciate some
help, the data is pasted below.
/The imported table looks ike this this:/
Order Transect Sample Abundance
1 Coleoptera 1 1 13
[snip]
15 Coleoptera 3 5 29 /The command I am using is this:/ anova2<-aov(Abundance~Transect,data=beetle)
I was going to tell you to read up on the distinction between factors and numeric variables in statistical models, but I can't immediately find a reference on line (this is bound to be in Peter Dalgaard's book or any other basic-stats-with-R text). str() will tell you whether the columns are numeric or factors. Try beetle <- transform(beetle,Transect=factor(Transect)) [or ?read.csv and use colClasses explicitly to specify the classes of the columns] before running your anova.
Thanks bbolker, that's really helpful. I'll look out for the book too, it could be helpful! Yours, Sam -- View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3891246.html Sent from the R help mailing list archive at Nabble.com.