已知sim3相似变换矩阵,如何求解出R, s, t ,从sim3相似变换矩阵中恢复和获得尺度、旋转、平移

如果已知如下这种sim3相似变换矩阵,如何求解出R, s, t ?
[ 0.237345 0.0486276 − 0.366644 − 0.135602 0.0486276 0.0460356 − 0.0878448 − 0.0324891 − 0.366644 − 0.0878448 0.696721 0.244963 0 0 0 1 ] \begin{bmatrix} 0.237345 &0.0486276 & -0.366644 &-0.135602\\ 0.0486276 & 0.0460356 &-0.0878448 &-0.0324891\\ -0.366644& -0.0878448 & 0.696721 & 0.244963\\ 0 &0 & 0 & 1 \end{bmatrix} 0.2373450.04862760.36664400.04862760.04603560.087844800.3666440.08784480.69672100.1356020.03248910.2449631

首先我们知道sim3变换的矩阵具有形式如下:
s i m 3 = [ s R 3 × 3 t 3 × 1 0 1 ] 4 × 4 (0) sim3= \begin{bmatrix} sR_{3 \times 3} & t_{3 \times 1} \\ 0 & 1 \end{bmatrix}_{4 \times 4} \tag0 sim3=[sR3×30t3×11]4×4(0)

相似变换矩阵只是在旋转矩阵前面乘了一个常数 s s s

要从一个 4 × 4 4 \times 4 4×4的相似变换矩阵中分离 t t t很容易,直接取出矩阵对应位置的值即可。

但是要分离 s , R s,R s,R需要做一些非常简单的矩阵运算:

首先令,
A = s R 3 × 3 (1) A = sR_{3 \times 3} \tag 1 A=sR3×3(1)然后求 A A A的行列式的值
a = d e t ( A ) (2) a = det(A) \tag 2 a=det(A)(2)

根据矩阵的性质知道
a = s × s × s × d e t ( R ) (3) a = s \times s \times s \times det(R) \tag3 a=s×s×s×det(R)(3)

因为旋转矩阵有一个性质,它的行列式为1,所以

s = a 1 3 (4) s = a^{\frac{1}{3}} \tag4 s=a31(4)

那么将矩阵 A A A除以 s s s就能得到没有尺度的旋转矩阵

R = 1 s A (5) R = \frac{1}{s} A \tag5 R=s1A(5)

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
计算VaR和ES,需要先估计GARCH-Copula模型,然后使用该模型进行模拟,得到未来的收益率分布,最后根据不同置信度计算VaR和ES。以下是R代码示例: 假设我们有两个行业指数收益率数据,分别为ret1和ret2,我们使用t分布作为边缘分布,使用t-Copula作为联合分布,进行GARCH-Copula模型估计: ``` library(rugarch) library(fGarch) # 定义GARCH模型 spec1 <- ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(0, 0), include.mean = TRUE), distribution.model = "std") spec2 <- ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(0, 0), include.mean = TRUE), distribution.model = "std") # 估计GARCH模型 fit1 <- ugarchfit(spec1, data = ret1) fit2 <- ugarchfit(spec2, data = ret2) # 计算残差 resid1 <- residuals(fit1, standardize = TRUE) resid2 <- residuals(fit2, standardize = TRUE) # 定义Copula模型 library(copula) tcop <- tCopula(param = c(0.5), dim = 2, dispstr = "un", df = 3) # 拟合Copula模型 fit.cop <- fitCopula(tcop, cbind(pnorm(resid1), pnorm(resid2))) # 计算Copula参数 cop.param <- fit.cop@fit$par ``` 然后,我们可以用该模型进行模拟,得到未来的收益率分布: ``` # 定义模拟次数 n.sim <- 10000 # 生成随机样本 sim.cop <- rCopula(n.sim, tcop, dim = 2) # 将Copula样本转换为边缘分布的样本 sim1 <- qnorm(sim.cop[, 1]) sim2 <- qnorm(sim.cop[, 2]) # 使用GARCH模型模拟未来收益率 sim.ret1 <- ugarchsim(fit1, n.sim, startMethod = "sample") sim.ret2 <- ugarchsim(fit2, n.sim, startMethod = "sample") # 计算未来的收益率 sim.ret1 <- sim.ret1@path[-1, ] * sqrt(fit1@fit$variance[-1, ]) sim.ret2 <- sim.ret2@path[-1, ] * sqrt(fit2@fit$variance[-1, ]) # 将边缘分布样本和未来收益率结合起来 sim.ret <- cbind(sim.ret1, sim.ret2) sim.ret <- apply(sim.ret, 2, function(x) qnorm(pt(x, df = 3))) # 计算未来的总收益率 sim.total.ret <- sim.cop * sim.ret ``` 接下来,我们可以利用生成的随机样本计算VaR和ES: ``` # 计算VaR和ES alpha <- 0.05 VaR <- quantile(sim.total.ret, alpha) ES <- mean(sim.total.ret[sim.total.ret < VaR]) # 输结果 print(paste0("VaR: ", round(VaR, 4))) print(paste0("ES: ", round(ES, 4))) ``` 最后,我们可以进行风险分析,比如计算两个行业指数的相关系数和协方差矩阵: ``` # 计算相关系数 cor(sim.ret1, sim.ret2) # 计算协方差矩阵 cov(sim.ret) ``` 以上就是使用GARCH-Copula模型计算VaR和ES,并进行风险分析的R代码示例。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值