Dina
Dina

Reputation: 11

One sample Kolmogorov-Smirnov to test gof of theoretical distribtion (makedist error) matlab

I have few continuous variables that look like this:

durs1=[3,40933 0,033630 0,25103 0,6361 0,71971 1,18311 1,91946 0,12842 0,97639 1,1383 0,46871 3,05241 2,34907 1,03788 0,76434 1,08798 1,462 0,4241 2,32128 0,29017..]

Each has more than 1000 values (all positive). I used

[a, b]=gamfit(durs1)

a =

2.3812    0.4200


b =

2.2316    0.3907
2.5408    0.4514

to find parameters of gamma distribution. Now I want to make a goodness of fit test in order to see how well the model fits my data. Matlab provides the one sample Kolmogorov-Smirnov test to solve the problem (http://www.mathworks.com/help/stats/kstest.html#btnyrvz-1) But when I run my code (based on their examples):

test_cdf=makedist('Gamma','a',2.38,'b',0.42) 
[h, p]=kstest(durs1,'CDF',test_cdf)  

I have this error: "Undefined function 'makedist' for input arguments of type 'char'."

Can somebody help me to fix my code?

Upvotes: 1

Views: 3153

Answers (1)

ThijsW
ThijsW

Reputation: 2599

It seems like the function makedist of the statistics toolbox is available only from Matlab version r2013a. Looking in the documentation of earlier versions, even as late as r2012b, there is no mention of makedist. So I think updating to the latest version of matlab should solve your problem.

Upvotes: 1

Related Questions