[R] Regarding KS Test for Goodness-of-Fit

Schalk Heunis schalk.heunis at gmail.com
Sun Sep 20 10:39:51 CEST 2009


Manuj
Your approach in (2) would work, looking at the source (just type
ks.test) your function will be called with a sorted vector of data
values, i.e. HED(sort(x), ...) where x is a a numeric vector of data
values and ... is the parameters as passed to ks.test

This means your function needs to be able to handle a vector of
inputs.  Look at sapply if this is an issue.

HTH
Schalk Heunis

On Sun, Sep 20, 2009 at 4:21 AM, Manuj Sharma <smanuj1970 at yahoo.in> wrote:
>
> I have fitted Hyperexponential distribution (HED) and Hypoexponential distribution (HoED) to two different data sets (of size 1000 numeric values each) using a software package called EMpht.
> I want to use R to perform goodness-of-fit test for the fitted distribution with respect to the empirical CDFs of the data sets using KS test (Kolmogorov-Smirnov test).
> ks.test() function in R takes the first argument as the data set,
> and the second argument as the name of the distribution, followed by the distribution parameter values. In case of the CDFs that are already supported by R, this is simple (for example: ks.test(data_set, "pnorm", mean, sd)).
>
> 1. Can somebody please suggest whether R has in-built support for Hyperexponential and Hypoexponential CDFs
> (they do not appear in the list of distribution given in "An Introduction to R"))?
>
> 2. If I write an R function to compute HED (or HoED) CDF value, can I use that function name as second argument in ks.test()? For example, if I implement an R function named HED_CDF with parameters <parameters...>, will it be correct to use ks.test() as follows:
>     ks.test(data_set, "HED_CDF", <parameters...>)
> Will it give correct result?
>
> - Manuj Sharma
>
>
>
>      From cricket scores to your friends. Try the Yahoo! India Homepage! http://in.yahoo.com/trynew
>        [[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.
>




More information about the R-help mailing list