前言:今早解决了一个小问题。之前有说过R藤中抽样可以用RVineSim,但是因为前面要pobs样本数据,所以抽样出来的值不是真正的样本值,而是样本值对应的cdf,所以如果想得到分位点,还得用quantile函数变换一下。越写越感觉写的东西没有什么意义。。。且代码写的很乱。。copula值得更好的应用领域。。。
今天才发现,原来vinecopula包只能设定Rvine或者Cvine模型,至于Dvine需要用到新的包:
library(CDVineCopulaConditional)
CDVineCondFit(数据,d-1,type = "DVine")
包里给的例子:
# Read data data(dataset) data <- dataset$data[1:100,1:5]
# Define the variables Y and X. X are the conditioning variables, # which have to be positioned in the last columns of the data.frame colnames(data) <- c("Y1","Y2","X3","X4","X5")
## Not run: # Select and fit a C- vine copula model, requiring that the RVM <- CDVineCondFit(data,Nx=3,treecrit="BIC",type="CVine",selectioncrit="AIC") summary(RVM) RVM$Matrix
第二个参数我也不太清楚实什么意思。。。官方给的解释是:条件变量的个数。
总之如果改变这个参数,那么模型的估计结果也会发生改变。。。