pndat = data.frame(m = 1.0, SD = exp(1.0))
pndat = transform(pndat, y = rposnorm(n <- 1000, m=m, sd=SD))
with(pndat, hist(y, prob=TRUE, border="blue",
main=paste("posnorm(m=",m[1],", sd=",round(SD[1],2),")")))
fit = vglm(y ~ 1, fam=posnormal1, pndat, trace=TRUE)
coef(fit, mat=TRUE)
(Cfit = Coef(fit))
mygrid = with(pndat, seq(min(y), max(y), len=200)) # Add the fit to the histogram
lines(mygrid, dposnorm(mygrid, Cfit[1], Cfit[2]), col="red")
Run the code above in your browser using DataLab