[R] There is an error when I performed chisquare and postanova test...:(

John Kane 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


John Kane
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
> test...:(
> 
> I am studying for a quiz and while I was solving two problems, an error
> occured.
> a) So the problem is we want to test if the block program makes a
> difference
> 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
> can't
> run..
> 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
> tukey's
> test. I seriously do not know what went wrong... So, this is the original
> problem:
> 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
> they
> 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")
> attach(chicken)
> anova(lm(chicken$ration~chicken$weight))
> anova.ration <- aov(chicken$ration~chicken$weight)
> *posthoc.ration <- TukeyHSD(anova.ration, 'weight', conf.level=0.95) =>
> This
> is the part where I wasn't able to run :(*
> tapply(ration,weight, mean, na.rm=T)
> plot(posthoc.weight)
> 
> Thanks!
> 
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/There-is-an-error-when-I-performed-chisquare-and-postanova-test-tp4712770.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

____________________________________________________________
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 mailing list