# Parameter estimation for a distribution with known shape parameters
X <- rNormal_trunc_ab(n= 500, mu= 2, sigma = 5, a = 1, b = 2)
est.par <- eNormal_trunc_ab(X); est.par
plot(est.par)
# Fitted density curve and histogram
den.x <- seq(min(X),max(X),length=100)
den.y <- dNormal_trunc_ab(den.x,params = est.par)
hist(X, breaks=10, probability=TRUE, ylim = c(0,1.2*max(den.y)))
lines(den.x, den.y, col="blue")
lines(density(X), lty = 2)
# Extracting boundary and shape parameters
est.par[attributes(est.par)$par.type=="boundary"]
est.par[attributes(est.par)$par.type=="shape"]
# log-likelihood function
lNormal_trunc_ab(X,param = est.par)
Run the code above in your browser using DataLab