[R] Chi-Square Goodness-of-Fit test

Ethan Johnsons ethan.johnsons at gmail.com
Thu Dec 7 06:29:21 CET 2006


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
> __________________________________
>
>




More information about the R-help mailing list