分布を特定のデータに当てはめています。次に、分布のパラメーターを推定しました。また、R で ecdf() コマンドを使用して経験的累積分布関数をプロットしました。推定分布の累積分布関数を経験的累積分布関数と共にプロットする必要があります。どうすればそれができますか?ecdf() コマンドはまだ役に立ちますか?
3773 次
1 に答える
1
はい、ecdf
お手伝いできます。プロット方法があります。以下に、正規分布の可能なコードを示します。
x <- rnorm(100)
plot(ecdf(x))
lines(seq(-3, 3, by=.1), pnorm(seq(-3, 3, by=.1)), col=2)
編集:代わりに対数ロジスティック分布関数を使用して同じことを行うことができます。たとえば、パッケージに実装されていますactuar
。
# load package
require(actuar)
# check out the parametrization!
?dllogis
# estimate shape and scale from your data
shape <- 20
scale <- 1
# Don't do this. Use your own data instead.
x <- rllogis(100, shape=shape, scale=scale)
# Plotting the empirical distribution function
plot(ecdf(x))
# x-values for plotting distribution function
xvals <- seq(min(x), max(x), length=100)
# plot estimated distribution function with your estimated shape and scale
lines(xvals, pllogis(xvals, shape=shape, scale=scale), col=2)
于 2013-10-15T09:56:39.010 に答える