How do u calculated p values for a z test.. so far i ve done this A = read.table("cw3_data.txt") xbar = mean(A) s = 1 n = 20 mu = 0 z.test = (xbar-mu)/(s/sqrt(n)) p.value = pnorm(abs(z.test)) error = qnorm(0.99)*s/sqrt(n) left = xbar - error right = xbar + error and have got values off of it...but the values for p dont match up with other sites that i have used to check it agaisnt..such as wolfram alpha value i got was 0.7335039 when wolfram got 0.533.. any ideas where i ve gone wrong? cheers -- View this message in context: http://r.789695.n4.nabble.com/P-values-tp2131646p2131646.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org mailing list PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Why s = 1 ## s = sd(A) #? -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von level Gesendet: Mittwoch, 5. Mai 2010 22:41 An: r-help at r-project.org Betreff: [R] P values How do u calculated p values for a z test.. so far i ve done this A = read.table("cw3_data.txt") xbar = mean(A) s = 1 n = 20 mu = 0 z.test = (xbar-mu)/(s/sqrt(n)) p.value = pnorm(abs(z.test)) error = qnorm(0.99)*s/sqrt(n) left = xbar - error right = xbar + error and have got values off of it...but the values for p dont match up with other sites that i have used to check it agaisnt..such as wolfram alpha value i got was 0.7335039 when wolfram got 0.533.. any ideas where i ve gone wrong? cheers -- View this message in context: http://r.789695.n4.nabble.com/P-values-tp2131646p2131646.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.
We cannot be certain without knowing what the data in cw3_data.txt is, but here are some likely issues. Notice that:> (1-0.7335039)*2[1] 0.5329922 Which implies that the wolfram value comes from taking the smaller tail area and multiplying by 2, which is a common way to compute p-values for 2-sided tests. You took the absolute value implying 2-sided, but then you use the wrong tail and do not multiply by 2 (or compare to alpha/2 which is my preference, but I'm in a small minority there). There is a z.test function in the TeachingDemos package that you could have used as another check of your calculations, or to do this with a single command. Note also that read.table returns a data frame, it appears in your case that it had a single column and everything worked out in your calculations, but if you tried this again with a different file with multiple columns then the results could be confusing, it is best to make sure you understand how your data is stored and work with the correct types of data directly. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of level > Sent: Wednesday, May 05, 2010 2:41 PM > To: r-help at r-project.org > Subject: [R] P values > > > How do u calculated p values for a z test.. > > so far i ve done this > > A = read.table("cw3_data.txt") > > xbar = mean(A) > s = 1 > n = 20 > mu = 0 > > z.test = (xbar-mu)/(s/sqrt(n)) > > p.value = pnorm(abs(z.test)) > > error = qnorm(0.99)*s/sqrt(n) > left = xbar - error > right = xbar + error > > and have got values off of it...but the values for p dont match up with > other sites that i have used to check it agaisnt..such as wolfram alpha > value i got was 0.7335039 when wolfram got 0.533.. any ideas where i > ve > gone wrong? cheers > -- > View this message in context: http://r.789695.n4.nabble.com/P-values- > tp2131646p2131646.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.
Which fortune is this? :) Dennis On Fri, May 7, 2010 at 10:08 AM, Charles Annis, P.E. < charles.annis@statisticalengineering.com> wrote:> Please let me quote an eminently sensible person, who observed that ... > > "p-values are dangerous, especially large, small, and in-between ones." > - Frank E Harrell Jr., Prof. of Biostatistics and Department Chair, > Vanderbilt University > > > > Charles Annis, P.E. > > Charles.Annis@StatisticalEngineering.com > 561-352-9699 > http://www.StatisticalEngineering.com > > > -----Original Message----- > From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-project.org] > On > Behalf Of Robert A LaBudde > Sent: Friday, May 07, 2010 12:29 PM > To: Duncan Murdoch > Cc: r-help@r-project.org; level > Subject: Re: [R] P values > > At 07:10 AM 5/7/2010, Duncan Murdoch wrote: > >Robert A LaBudde wrote: > >>At 01:40 PM 5/6/2010, Joris Meys wrote: > >> > >>>On Thu, May 6, 2010 at 6:09 PM, Greg Snow <Greg.Snow@imail.org> wrote: > >>> > >>> > >>>>Because if you use the sample standard deviation then it is a t test > not > a > >>>>z test. > >>>> > >>>> > >>>I'm doubting that seriously... > >>> > >>>You calculate normalized Z-values by substracting the sample mean and > >>>dividing by the sample sd. So Thomas is correct. It becomes a Z-test > since > >>>you compare these normalized Z-values with the Z distribution, instead > of > >>>the (more appropriate) T-distribution. The T-distribution is essentially > a > >>>Z-distribution that is corrected for the finite sample size. In > Asymptopia, > >>>the Z and T distribution are identical. > >>> > >> > >>And it is only in Utopia that any P-value less than 0.01 actually > >>corresponds to reality. > >> > >> > >I'm not sure what you mean by this. P-values are simply statistics > >calculated from the data; why wouldn't they be real if they are small? > > Do you truly believe an actual real-life distribution accurately is > fit by a normal distribution at quantiles of 0.001, 0.0001 or beyond? > > "The map is not the territory", and just because you can calculate > something from a model doesn't mean it's true. > > The real world is composed of mixture distributions, not pure ones. > > The P-value may be real, but its reality is subordinate to the > distributional assumption involved, which always fails at some level. > I'm simply asserting that level is in the tails at probabilities of > 0.01 or less. > > Statisticians, even eminent ones such as yourself and lesser lights > such as myself, frequently fail to keep this in mind. We accept such > assumptions as "normality", "equal variances", etc., on an > "eyeballometric" basis, without any quantitative understanding of > what this means about limitations on inference, including P-values. > > Inference in statistics is much cruder and more judgmental than we > like to portray. We should at least be honest among ourselves about > the degree to which our hand-waving assumptions work. > > I remember at the O. J. Simpson trial, the DNA expert asserted that a > match would occur only once in 7 billion people. I wondered at the > time how you could evaluate such an assertion, given there were less > than 7 billion people on earth at the time. > > When I was at a conference on optical disk memories when they were > being developed, I heard a talk about validating disk specifications > against production. One statement was that the company would also > validate the "undetectable error rate" specification of 1 in 10^16 > bits. I amusingly asked how they planned to validate the > "undetectable" error rate. The response was handwaving and "Just as > we do everything else". The audience laughed, and the speaker didn't > seem to know what the joke was. > > In both these cases the values were calculable, but that didn't mean > that they applied to reality. > > ===============================================================> Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: ral@lcfltd.com > Least Cost Formulations, Ltd. URL: http://lcfltd.com/ > 824 Timberlake Drive Tel: 757-467-0954 > Virginia Beach, VA 23464-3239 Fax: 757-467-2947 > > "Vere scire est per causas scire" > > ______________________________________________ > R-help@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. > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Robert A LaBudde wrote:> At 01:40 PM 5/6/2010, Joris Meys wrote: > >> On Thu, May 6, 2010 at 6:09 PM, Greg Snow <Greg.Snow@imail.org> wrote: >> >> >>> Because if you use the sample standard deviation then it is a t test nota>>> z test. >>> >>> >> I'm doubting that seriously... >> >> You calculate normalized Z-values by substracting the sample mean and >> dividing by the sample sd. So Thomas is correct. It becomes a Z-testsince>> you compare these normalized Z-values with the Z distribution, instead of >> the (more appropriate) T-distribution. The T-distribution is essentiallya>> Z-distribution that is corrected for the finite sample size. InAsymptopia,>> the Z and T distribution are identical. >> > > And it is only in Utopia that any P-value less than 0.01 actually > corresponds to reality. > >## I'm not sure what you mean by this. P-values are simply statistics ## calculated from the data; why wouldn't they be real if they are small? ## Duncan Murdoch Just wondering. The smallest the p-value, the closer to 'reality' (the more accurate) the model is supposed to (not) be (?). How realistic is it to be that (un-) real? bak p.s. I am no statistician [[alternative HTML version deleted]]