set.seed(123); nn <- 350
var1 <- exp(1.5); var2 <- exp(0.75); var3 <- exp(1.0)
### Artificial data, with two covariates.
tdata <- data.frame(x2 = runif(nn), x3 = runif(nn))
tdata <- transform(tdata,
y1 = rnorm(nn, 1 + 2 * x2, sd = sqrt(var1)),
y2 = rnorm(nn, 3 + 1 * x2, sd = sqrt(var2)),
y3 = rnorm(nn, 3 - 1 * x3, sd = sqrt(var2 * var3)))
### Fit the model using VGAMextra::trinormalCovff().
fit.trinormCovff <- vglm(cbind(y1, y2, y3) ~ x2 + x3,
trinormalCovff,
data = tdata, trace = TRUE)
summary(fit.trinormCovff)
vcov(fit.trinormCovff)
### Fitting the model using VGAM::trinormal()
fit.trinormVGAM <- vglm(cbind(y1, y2, y3) ~ x2 + x3,
trinormal,
data = tdata, trace = TRUE)
summary(fit.trinormVGAM)
vcov(fit.trinormVGAM)
#### Compare the estimated coefficients. Note that
#### trinormal() estimates the sd's and correlation coeffs.
coef(fit.trinormCovff, matrix = TRUE)
coef(fit.trinormVGAM, matrix = TRUE)
Run the code above in your browser using DataLab