View source: R/trinormalCovff.R
trinormalCovff | R Documentation |
Estimates the means and the upper-half of the (symmetric) covariance matrix of a trivariate normal distribution by maximum likelihood.
trinormalCovff(zero = c("var", "cov"),
lmean = "identitylink",
lvar = "loglink",
lcov = "identitylink")
zero |
The linear predictors modelled as intercept–only.
See |
lmean, lvar, lcov |
Link functions applied to the means, variances (diagonal elements of the
covariance matrix), and covariances (off-diagonal elements).
See |
This family function is similar to
trinormal
. The only difference is
that the variances and covariances, instead of the
standard deviations and correlation coefficients,
are directly modelled and estimated.
Similarly, trinormalCovff
also fits linear models to the means of a trivariate normal distribution.
The fitted means are returned as the fitted values in the form of a
three–column matrix. By default, the variances and covariances
are modelled as intercept–only, where a
loglink
link is applied to the variances
and an identitylink
over
the covariances.
An object of class "vglmff"
(see vglmff-class
) to be
used by VGLM/VGAM modelling functions, e.g.,
vglm
or vgam
.
Victor Miranda and Thomas Yee.
trinormal
,
zero
,
Links
,
vglm
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.