if (FALSE) {
set.seed(1.2345)
# the actual parameters
lower <- c(-1,-1)
upper <- c(1, 2)
mu <- c(0, 0)
sigma <- matrix(c(1, 0.7,
0.7, 2), 2, 2)
# generate random samples
X <- rtmvnorm(n=500, mu, sigma, lower, upper)
method <- "BFGS"
# estimate mean vector and covariance matrix sigma from random samples X
# with default start values
mle.fit1 <- mle.tmvnorm(X, lower=lower, upper=upper)
# diagnostic output of the estimated parameters
summary(mle.fit1)
logLik(mle.fit1)
vcov(mle.fit1)
# profiling the log likelihood and confidence intervals
mle.profile1 <- profile(mle.fit1, X, method="BFGS", trace=TRUE)
confint(mle.profile1)
par(mfrow=c(3,2))
plot(mle.profile1)
# choosing a different start value
mle.fit2 <- mle.tmvnorm(X, lower=lower, upper=upper,
start=list(mu=c(0.1, 0.1),
sigma=matrix(c(1, 0.4, 0.4, 1.8),2,2)))
summary(mle.fit2)
}
Run the code above in your browser using DataLab