Last chance! 50% off unlimited learning
Sale ends in
Density and random generation for the trivariate normal distribution distribution.
dtrinorm(x1, x2, x3, mean1 = 0, mean2 = 0, mean3 = 0,
var1 = 1, var2 = 1, var3 = 1,
cov12 = 0, cov23 = 0, cov13 = 0, log = FALSE)
rtrinorm(n, mean1 = 0, mean2 = 0, mean3 = 0,
var1 = 1, var2 = 1, var3 = 1,
cov12 = 0, cov23 = 0, cov13 = 0)
vector of quantiles.
vectors of means.
vectors of variances.
vectors of covariances.
number of observations.
Same as rnorm
.
Logical.
If log = TRUE
then the logarithm of the density is returned.
dtrinorm
gives the density,
rtrinorm
generates random deviates (
dtrinorm()
's arguments might change in the future!
It's safest to use the full argument names
to future-proof possible changes!
The default arguments correspond to the standard trivariate normal
distribution with correlation parameters equal to 0,
which corresponds to three independent standard normal distributions.
Let sd1
(say) be sqrt(var1)
and
written var
arguments are left alone then
the cov
can be inputted with
# NOT RUN {
nn <- 1000
tdata <- data.frame(x2 = sort(runif(nn)))
tdata <- transform(tdata, mean1 = 1 + 2 * x2,
mean2 = 3 + 1 * x2, mean3 = 4,
var1 = exp( 1), var2 = exp( 1), var3 = exp( 1),
rho12 = rhobit( 1, inverse = TRUE),
rho23 = rhobit( 1, inverse = TRUE),
rho13 = rhobit(-1, inverse = TRUE))
ymat <- with(tdata, rtrinorm(nn, mean1, mean2, mean3,
var1, var2, var3,
sqrt(var1)*sqrt(var1)*rho12,
sqrt(var2)*sqrt(var3)*rho23,
sqrt(var1)*sqrt(var3)*rho13))
pairs(ymat, col = "blue")
# }
Run the code above in your browser using DataLab