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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

massmatics
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!
Reply | Threaded
Open this post in threaded view
|

Re: There is an error when I performed chisquare and postanova test...:(

Michael Dewey-3
Dear massmatics

The list has a no homework policy but in this case I feel I can depart
from that. Have you tried reading the documentation for chisq.test?

On 25/09/2015 12:44, massmatics wrote:

> 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.
>
> ______________________________________________
> [hidden email] 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.
>

--
Michael
http://www.dewey.myzen.co.uk/home.html

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: There is an error when I performed chisquare and postanova test...:(

massmatics
Yes, so far, we only learned how to use chisq.test when performed at 0.05 significance level
But not when it is at 0.01
Reply | Threaded
Open this post in threaded view
|

Re: There is an error when I performed chisquare and postanova test...:(

Michael Dewey-3
Let me repeat my advice
Read the documentation for chisq.test and see if it has the parameters
you think it has.

On 25/09/2015 14:12, massmatics wrote:

> Yes, so far, we only learned how to use chisq.test when performed at 0.05
> significance level
> But not when it is at 0.01
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/There-is-an-error-when-I-performed-chisquare-and-postanova-test-tp4712770p4712772.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>

--
Michael
http://www.dewey.myzen.co.uk/home.html

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: There is an error when I performed chisquare and postanova test...:(

John Kane
In reply to this post by massmatics
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: [hidden email]
> Sent: Fri, 25 Sep 2015 04:44:59 -0700 (PDT)
> To: [hidden email]
> 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.
>
> ______________________________________________
> [hidden email] 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!

______________________________________________
[hidden email] 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.