I wish to run the Kolmogorov-Smirnov test on my data to determine how well it conforms to a specific continuous distribution function I have in mind.

If my understanding is correct, the Kolmogorov-Smirnov test can be performed in R with something along the lines of:

ks.test(my_data, "pweibull", shape=2, scale=1)

where in the case above pweibull is indicating a test against the Weibull function.

The issue I am having is that the function I want to test against (the BiPareto function defined here for what it's worth) is not a standard part of R best I can tell. Is it possible to define one's own function with parameters in R that can be passed to ks.test()?

ie. so I can have a call like:

ks.test(my_data, "bipareto", alpha=a_param, beta=b_param, c=c_param, k=k_param)

The help on the ks.test function is explicit - you can supply a cdf as a function:

Alternatively, y can be a character string naming a continuous (cumulative) distribution function, or such a function.

The last bit is where it tells you that.

So you can make a function called bipareto (say) that computes the cdf, and use that in the call. But you don't have to put it in quotes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.