關於plotting confidence intervals有很多答案。
我正在閱讀Lourme A. et al (2016)的論文,我想從圖紙中得出90%置信邊界和10%例外點,如圖2所示。
library("MASS")
library(copula)
set.seed(612)
n <- 1000 # length of sample
d <- 2 # dimension
# random vector with uniform margins on (0,1)
u1 <- runif(n, min = 0, max = 1)
u2 <- runif(n, min = 0, max = 1)
u = matrix(c(u1, u2), ncol=d)
Rg <- cor(u) # d-by-d correlation matrix
Rg1 <- ginv(Rg) # inv. matrix
# round(Rg %*% Rg1, 8) # check
# the multivariate c.d.f of u is a Gaussian copula
# with parameter Rg[1,2]=0.02876654
normal.cop = normalCopula(Rg[1,2], dim=d)
fit.cop = fitCopula(normal.cop, u, method="itau") #fitting
# Rg.hat = [email protected][1]
# [1] 0.03097071
sim = rCopula(n, normal.cop) # in (0,1)
# Taking the quantile function of N1(0, 1)
y1 <- qnorm(sim[,1], mean = 0, sd = 1)
y2 <- qnorm(sim[,2], mean = 0, sd = 1)
par(mfrow=c(2,2))
plot(y1, y2, col="red"); abline(v=mean(y1), h=mean(y2))
plot(sim[,1], sim[,2], col="blue")
hist(y1); hist(y2)
參考。 Lourme,A.,F. Maurer(2016)在風險管理框架中測試Gaussian和Student's t copulas。經濟建模。
問題。任何人都可以幫我解釋一下變量v=(v_1,...,v_d)
和G(v_1),..., G(v_d)
的等式嗎?
我認爲v
是非隨機矩陣,尺寸應該是d=2
(尺寸)的$ k^2 $(網格點)。例如,
axis_x <- seq(0, 1, 0.1) # 11 grid points
axis_y <- seq(0, 1, 0.1) # 11 grid points
v <- expand.grid(axis_x, axis_y)
plot(v, type = "p")
[此](http://stackoverflow.com/questions/23437000/how-to-plot-a-contour-line-showing-where-95-of-values-fall -within式-R和中)? – alistaire
@alistaire,感謝您的鏈接,建議的代碼提供了一個解決方案,但它不適合我,因爲我想繪製一個「平滑」輪廓。 – Nick
你如何從數據點定義這個「alpha」置信邊界? – Spacedman