> mydata
[1] 37.50 46.79 48.30 46.04 43.40 39.25 38.49 49.51 40.38 36.98 40.00 [12] 38.49 37.74 47.92 44.53 44.91 44.91 40.00 41.51 47.92 36.98 43.40 [23] 42.26 41.89 38.87 43.02 39.25 40.38 42.64 36.98 44.15 44.91 43.40 [34] 49.81 38.87 40.00 52.45 53.13 47.92 52.45 44.91 29.54 27.13 35.60 [45] 45.34 43.37 54.15 42.77 42.88 44.26 27.14 39.31 24.80 16.62 30.30 [56] 36.39 28.60 28.53 35.84 31.10 34.55 52.65 48.81 43.42 52.49 38.00 [67] 38.65 34.54 37.70 38.11 43.05 29.95 32.48 24.63 35.33 41.34
#estimate shape and scale to perform KS-test for weibull distribution
> fitdistr(mydata,"weibull") shape scale 6.4632971 43.2474500 ( 0.5800149) ( 0.8073102)
#KS-test for weibull distribution
> ks.test(mydata,"pweibull", scale = 43.2474500, shape = 6.4632971)
> mydata
[1] 37.50 46.79 48.30 46.04 43.40 39.25 38.49 49.51 40.38 36.98 40.00
[12] 38.49 37.74 47.92 44.53 44.91 44.91 40.00 41.51 47.92 36.98 43.40
[23] 42.26 41.89 38.87 43.02 39.25 40.38 42.64 36.98 44.15 44.91 43.40
[34] 49.81 38.87 40.00 52.45 53.13 47.92 52.45 44.91 29.54 27.13 35.60
[45] 45.34 43.37 54.15 42.77 42.88 44.26 27.14 39.31 24.80 16.62 30.30
[56] 36.39 28.60 28.53 35.84 31.10 34.55 52.65 48.81 43.42 52.49 38.00
[67] 38.65 34.54 37.70 38.11 43.05 29.95 32.48 24.63 35.33 41.34
# estimate shape and scale to perform KS-test for weibull distribution
> fitdistr(mydata, "weibull")
shape scale
6.4632971 43.2474500
( 0.5800149) ( 0.8073102)
# KS-test for weibull distribution
> ks.test(mydata, "pweibull", scale=43.2474500, shape=6.4632971)
One-sample Kolmogorov-Smirnov test
data: mydata D = 0.0686, p-value = 0.8669 alternative hypothesis: two-sided
#KS-test for normal distribution
> ks.test(mydata,"pnorm",mean=mean(mydata),sd=sd(mydata))
data: mydata
D = 0.0686, p-value = 0.8669
alternative hypothesis: two-sided
# KS-test for normal distribution
> ks.test(mydata, "pnorm", mean=mean(mydata), sd=sd(mydata))
One-sample Kolmogorov-Smirnov test
data: mydata
D = 0.0912, p-value = 0.5522
alternative hypothesis: two-sided
data: mydata D = 0.0912, p-value = 0.5522 alternative hypothesis: two-sided
The p-values are 0.8669 for the weibullWeibull distribution, and 0.5522 for the normal distribution. Thus I can assume that my data follows a weibullWeibull as well as a normal distribution. But which distribution function describes my data better?
I hope it becomes more clear what I am looking for.
ReferingReferring to elevendollar I found the following code, but don't know how to interpret the results:
fits <- list( no = fitdistr(mydata, "normal"), we = fitdistr(mydata, "weibull")) sapply(fits, function(i) i$loglik) no we -259.6540 -257.9268
fits <- list(no = fitdistr(mydata, "normal"),
we = fitdistr(mydata, "weibull"))
sapply(fits, function(i) i$loglik)
no we
-259.6540 -257.9268