Do you know/have a function that takes a vector x and provides a returned p-value that uses the Chi-Square Goodness-of-Fit test to test the goodness of fit of a standard normal distribution. Awaiting your positive reply. Thx ej
See pearson.test in the nortest package. Also, read the notes section in ?pearson.test. You may not really want to do this test. HTH, Simon. Ethan Johnsons wrote:> Do you know/have a function that takes a vector x and provides a > returned p-value that uses the Chi-Square Goodness-of-Fit test to test > the goodness of fit of a standard normal distribution. > > Awaiting your positive reply. > > Thx > > ej > > ______________________________________________ > R-help at stat.math.ethz.ch 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. > >-- Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University Canberra ACT 0200 Australia T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au F: +61 2 6125 0757 CRICOS Provider # 00120C The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey.
If we use this data as an example, does ks.test still valid? E.Coli Group Observed Expected A 57 77.9 B 330 547.1 C 2132 2126.7 D 4584 4283.3 E 4604 4478.5 F 2119 2431.1 G 659 684.1 H 251 107.2 thx ej On 12/4/06, Don McKenzie <dmck at u.washington.edu> wrote:> > in R v 2.4 > > > x <- rnorm(50) > > y <- rnorm(50) > > ks.test(x,y,"rnorm") > > Two-sample Kolmogorov-Smirnov test > > data: x and y > D = 0.08, p-value = 0.9977 > alternative hypothesis: two.sided > > ********** > > > x <- rnorm(50) > > y <- runif(50) > > ks.test(x,y,"rnorm") > > Two-sample Kolmogorov-Smirnov test > > data: x and y > D = 0.46, p-value = 3.801e-05 > alternative hypothesis: two.sided > ****************** > > > > On Dec 4, 2006, at 7:02 PM, Simon Blomberg wrote: > > See pearson.test in the nortest package. Also, read the notes section in > ?pearson.test. You may not really want to do this test. > > HTH, > > Simon. > > Ethan Johnsons wrote: > Do you know/have a function that takes a vector x and provides a > returned p-value that uses the Chi-Square Goodness-of-Fit test to test > the goodness of fit of a standard normal distribution. > > Awaiting your positive reply. > > Thx > > ej > > ______________________________________________ > R-help at stat.math.ethz.ch 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. > > > > > > -- > Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. > Centre for Resource and Environmental Studies > The Australian National University > Canberra ACT 0200 > Australia > T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au > F: +61 2 6125 0757 > CRICOS Provider # 00120C > > The combination of some data and an aching desire for > an answer does not ensure that a reasonable answer > can be extracted from a given body of data. > - John Tukey. > > ______________________________________________ > R-help at stat.math.ethz.ch 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. > > Don McKenzie, Research Ecologist > Pacific WIldland Fire Sciences Lab > US Forest Service > > Affiliate Assistant Professor > College of Forest Resources > CSES Climate Impacts Group > University of Washington > > 206.732.7824 > dmck at u.washington.edu > donaldmckenzie at fs.fed.us > > > >
By looking at R thread, it seems that the approach is: (1) cut the data into bins (you can use hist() to do this); (2) calculate the expected numbers in each bin using the differences of the CDF (pnorm, pexp, etc.); (3) calculate sum((exp-obs)^2/exp); (4) find the tail probability of the chi-square distribution (pchisq). I am a newbie in R. Your help will be greatly appreciated. Thx ej On 12/5/06, Don McKenzie <dmck at u.washington.edu> wrote:> Ethan Johnsons wrote: > > If we use this data as an example, does ks.test still valid? > > > > E.Coli Group Observed Expected > > A 57 77.9 > > B 330 547.1 > > C 2132 2126.7 > > D 4584 4283.3 > > E 4604 4478.5 > > F 2119 2431.1 > > G 659 684.1 > > H 251 107.2 > You can use the test with any numeric data I believe. Whether it is > valid is more a question > for a statistician than for R. :-) > > Don > > -- > ___________________________________ > > Don McKenzie, Research Ecologist > Pacific Wildland Fire Sciences Lab > USDA Forest Service > 400 N 34th St. #201 > Seattle, WA 98103, USA > (206) 732-7824 > donaldmckenzie at fs.fed.us > > Affiliate Assistant Professor > College of Forest Resources > CSES Climate Impacts Group > University of Washington > dmck at u.washington.edu > __________________________________ > >