I have a value a=300 observation (x) = sample(1:50) How to find a p-value from this. I need to show that "a" is different fom mean(x). Thanks -- ------------- Mary Kindall Yorktown Heights, NY USA [[alternative HTML version deleted]]
Hi Mary, I think the good old t-test is what you want: x <- sample(1:50) t.test(x, mu = 300) gives: One Sample t-test data: x t = -133.2, df = 49, p-value < 0.00000000000000022 alternative hypothesis: true mean is not equal to 300 95 percent confidence interval: 21.36 29.64 sample estimates: mean of x 25.5 Best, Henrik Am 22.07.2012 21:37, schrieb Mary Kindall:> I have a value > a=300 > > observation (x) = sample(1:50) > > How to find a p-value from this. I need to show that "a" is different fom > mean(x). > Thanks >-- Dipl. Psych. Henrik Singmann PhD Student Albert-Ludwigs-Universit?t Freiburg http://www.psychologie.uni-freiburg.de/Members/singmann
HI, Probably ?pnorm x1<-mean(x) x1 [1] 25.5> pnorm(25.5,mean=300)[1] 0 A.K. ----- Original Message ----- From: Mary Kindall <mary.kindall at gmail.com> To: r-help at r-project.org Cc: Sent: Sunday, July 22, 2012 3:37 PM Subject: [R] pvalue calculate I have a value a=300 observation (x) = sample(1:50) How to find a p-value from this. I need to show that "a" is different fom mean(x). Thanks -- ------------- Mary Kindall Yorktown Heights, NY USA ??? [[alternative HTML version deleted]] ______________________________________________ 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.
On 12-07-22 3:37 PM, Mary Kindall wrote:> I have a value > a=300 > > observation (x) = sample(1:50) > > How to find a p-value from this. I need to show that "a" is different fom > mean(x). > Thanks >This question doesn't really make sense. sample(1:50) gives you the same sample as 1:50 does, just in a different order. So the mean is guaranteed to be 25.5, which is obviously different from 300. If you really did have a random sample from some unknown distribution and you wanted to test whether the mean of that distribution is different from 300, then Henrik's suggestion is reasonable for most distributions. Duncan Murdoch
On 2012-07-22 13:09, Henrik Singmann wrote:> Hi Mary, > > I think the good old t-test is what you want:Maybe, but calculating p-values with absolutely no consideration of assumptions is pure folly. It may well be that Mary has some assumptions in mind, but the way the question was posed does not instil confidence in that assumption. Peter Ehlers> > x <- sample(1:50) > > t.test(x, mu = 300) > > gives: > One Sample t-test > > data: x > t = -133.2, df = 49, p-value < 0.00000000000000022 > alternative hypothesis: true mean is not equal to 300 > 95 percent confidence interval: > 21.36 29.64 > sample estimates: > mean of x > 25.5 > > Best, > Henrik > > > Am 22.07.2012 21:37, schrieb Mary Kindall: >> I have a value >> a=300 >> >> observation (x) = sample(1:50) >> >> How to find a p-value from this. I need to show that "a" is different fom >> mean(x). >> Thanks >> >