[R] There is an error when I performed chisquare and postanova test...:(
jrkrideau at inbox.com
Fri Sep 25 15:56:26 CEST 2015
As Michael suggests carefully read the help file (type ?chisq.test to bring up the page) and match all the elements of your command with the elements listed on the help page.
You do not need to use attach(chicken) given the code you are using and using attach(data) is generally considered bad practice. The two equations below are equivalent and the second is better practice in R.
anova(lm(chicken$ration~chicken$weight)) # your code
anova(lm(ration ~ weight, data = chickens)) # cleaner code.
Also have a look at ?with
I'd suggest having a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-ex and/or http://adv-r.had.co.nz/Reproducibility.html for some ideas on how to form questions and supply sample data to R-help.
You are posting from nabble which does not supply any context for the help list. If you are going to post here regularly I think everyone would be grateful if you post directly to R-help from a mail program. Very few people here use nabble and it is generally considered something of a curse.
Good luck on the quizz
Kingston ON Canada
> -----Original Message-----
> From: 2hanl2da at naver.com
> Sent: Fri, 25 Sep 2015 04:44:59 -0700 (PDT)
> To: r-help at r-project.org
> Subject: [R] There is an error when I performed chisquare and postanova
> I am studying for a quiz and while I was solving two problems, an error
> a) So the problem is we want to test if the block program makes a
> in retention at α = 1%
> (which is the significance level)
> This is the code I used to perform chisquare test.
> My solution:
> blockprogram <- matrix(c(18,15,5,8,4,10,5,7,18,10), nrow=2, byrow=T)
> colnames(blockprogram) <- c("1 yr","2 yr","3 yr","4 yr","5+ yrs")
> rownames(blockprogram) <- c("Non-Block","Block")
> chisq.test(blockprogram, conf.level=0.99) ==> This is the part where I
> chisq.test(blockprogram, conf.level=0.99)$observed
> chisq.test(blockprogram, conf.level=0.99)$expected
> So my question is is it the *conf.level=0.99* where it is wrongly used?
> b)I was able to run the one way anova but wasn't able to run on the
> test. I seriously do not know what went wrong... So, this is the original
> The data set chicken.csv contains weights of chickens which are given 1
> of 3
> different food rations. Perform an ANOVA procedure to determine if the
> weights of the chickens are significantly affected by the food rations
> are provided. In case a significant effect exists, perform a Tukey HSD
> post-hoc procedure to identify under which ration the chickens will be
> heaviest. Use a 5% level of significance.
> SO here's the code I used to perform:
> chicken <- read.csv("C:/Users/Win/Desktop/chicken.csv")
> anova.ration <- aov(chicken$ration~chicken$weight)
> *posthoc.ration <- TukeyHSD(anova.ration, 'weight', conf.level=0.95) =>
> is the part where I wasn't able to run :(*
> tapply(ration,weight, mean, na.rm=T)
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
Receive Notifications of Incoming Messages
Easily monitor multiple email accounts & access them with a click.
Visit http://www.inbox.com/notifier and check it out!
More information about the R-help