dtmvnorm.marginal2(tmvtnorm)
dtmvnorm.marginal2()所属R语言包:tmvtnorm
Bivariate marginal density functions from a Truncated Multivariate Normal distribution
从截断的多元正态分布的二元边际密度函数
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function computes the bivariate marginal density function f(x_q, x_r) from a k-dimensional Truncated Multivariate Normal density function (k>=2). The bivariate marginal density is obtained by integrating out (k-2) dimensions as proposed by Tallis (1961). This function is basically an extraction of the Leppard and Tallis (1989) Fortran code for moments calculation, but extended to the double truncated case.
此函数计算的二元边际密度函数f(x_q, x_r)k维截断多元正态密度函数(k> = 2)。的二元边际密度是通过以下方式获得积分,第(k-2)者塔利斯(1961)所提出的尺寸。此功能基本上是一个提取的Leppard的塔利斯(1989)的时刻计算的Fortran代码,而是扩展到双截断的情况。
用法----------Usage----------
dtmvnorm.marginal2(xq, xr, q, r,
mean = rep(0, nrow(sigma)),
sigma = diag(length(mean)),
lower = rep(-Inf, length = length(mean)),
upper = rep(Inf, length = length(mean)),
log = FALSE)
参数----------Arguments----------
参数:xq
Value x_q
值x_q
参数:xr
Value x_r
值x_r
参数:q
Index position for x_q within mean vector to calculate the bivariate marginal density for.
索引位置x_q内均值向量计算的二元边际密度。
参数:r
Index position for x_r within mean vector to calculate the bivariate marginal density for.
索引位置x_r内均值向量计算的二元边际密度。
参数:mean
Mean vector, default is rep(0, length = nrow(sigma)).
均值向量,默认是:rep(0, length = nrow(sigma))。
参数:sigma
Covariance matrix, default is diag(length(mean)).
协方差矩阵,默认是diag(length(mean))。
参数:lower
Vector of lower truncation points, default is rep(-Inf, length = length(mean)).
矢量较低的截断点,默认是rep(-Inf, length = length(mean))。
参数:upper
Vector of upper truncation points, default is rep( Inf, length = length(mean)).
向量上的截断点,默认是rep( Inf, length = length(mean))。
参数:log
Logical; if TRUE, densities d are given as log(d).
逻辑,如果TRUE,密度d的log(D)。
Details
详细信息----------Details----------
The bivariate marginal density function f(x_q, x_r) for x \sim TN(μ, Σ, a, b) and q \ne r is defined as
二元边际密度函数f(x_q, x_r)x \sim TN(μ, Σ, a, b)和q \ne r被定义为
(作者)----------Author(s)----------
Stefan Wilhelm <Stefan.Wilhelm@financial.com>, Manjunath B G <bgmanjunath@gmail.com>
参考文献----------References----------
Journal of the Royal Statistical Society, Series B, 23, 223–229
Applied Statistics, 38, 543–553
Working Paper. Available at SSRN: http://ssrn.com/abstract=1472153
实例----------Examples----------
lower = c(-0.5, -1, -1)
upper = c( 2.2, 2, 2)
mean = c(0,0,0)
sigma = matrix(c(2.0, -0.6, 0.7,
-0.6, 1.0, -0.2,
0.7, -0.2, 1.0), 3, 3)
# generate random samples from untruncated and truncated distribution[产生从untruncated和截尾分布的随机抽样]
Y = rmvnorm(10000, mean=mean, sigma=sigma)
X = rtmvnorm(500, mean=mean, sigma=sigma, lower=lower, upper=upper,
algorithm="gibbs")
# compute bivariate marginal density of x1 and x2[计算x1和x2的二元边际密度]
xq <- seq(lower[1], upper[1], by=0.1)
xr <- seq(lower[2], upper[2], by=0.1)
grid <- matrix(NA, length(xq), length(xr))
for (i in 1:length(xq))
{
for (j in 1:length(xr))
{
grid[i,j] = dtmvnorm.marginal2(xq=xq[i], xr=xr[j],
q=1, r=2, sigma=sigma, lower=lower, upper=upper)
}
}
plot(Y[,1], Y[,2], xlim=c(-4, 4), ylim=c(-4, 4),
main=expression("bivariate marginal density ("*x[1]*","*x[2]*")"),
xlab=expression(x[1]), ylab=expression(x[2]), col="gray80")
points(X[,1], X[,2], col="black")
lines(x=c(lower[1], upper[1], upper[1], lower[1], lower[1]),
y=c(lower[2],lower[2],upper[2],upper[2],lower[2]),
lty=2, col="red")
contour(xq, xr, grid, add=TRUE, nlevels = 8, col="red", lwd=2)
# scatterplot matrices for untruncated and truncated points[untruncated和截断点的散点图矩阵]
require(lattice)
splom(Y)
splom(X)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|