n = 1000; shape = exp(0); Scale = exp(1)
y = sqrt(rgamma(n, shape=shape, scale=Scale/shape))
fit = vglm(y ~ 1, nakagami, trace=TRUE, crit="c")
y = rnaka(n, shape=shape, scale=Scale)
fit = vglm(y ~ 1, nakagami(iscale=3), trace=TRUE)
head(fitted(fit))
mean(y)
coef(fit, matrix=TRUE)
(Cfit = Coef(fit))
hist(sy <- sort(y), prob=TRUE, main="", xlab="y", ylim=c(0,0.6))
lines(sy, dnaka(sy, shape=Cfit[1], scale=Cfit[2]), col="red")
Run the code above in your browser using DataLab