Description Usage Arguments Value Examples
Simulation of k correlated Random variables (RVs) with target marginal distributions and correlation structure.
1 | SimCorrRVs(n = 1000, paramsRVs)
|
n |
A scalar indicating the number of RVs to be generated. |
paramsRVs |
A list generated by function "EstCorrRVs". |
A matrix (n x k) with the generated RVs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ## Simulation of 3 correlated RVs with Gamma, Beta and Log-Normal distribution, respectively.
## We assume also a target correlation matrix.
## Not run:
set.seed(13)
# Define the target distribution functions (ICDFs) of X1, X2 and X3 RV.
FX1='qgamma'; FX2='qbeta'; FX3='qlnorm'
Distr=c(FX1,FX2,FX3) # store in a vector.
# Define the parameters of the target distribution functions
# and store them in a list.
pFX1=list(shape=1.5,scale=2); pFX2=list(shape1=1.5,shape2=3)
pFX3=list(meanlog=1,sdlog=0.5)
DistrParams=list()
DistrParams[[1]]=pFX1;DistrParams[[2]]=pFX2;DistrParams[[3]]=pFX3
# Define the target correlation matrix.
CorrelMat=matrix(c(1,0.7,0.5,
0.7,1,0.8,
0.5,0.8,1),ncol=3,nrow=3,byrow=T);
# Estimate the parameters of the auxiliary Gaussian model.
paramsRVs=EstCorrRVs(R=CorrelMat,dist=Distr,params=DistrParams,
NatafIntMethod='GH',NoEval=9,polydeg=8)
# Generate 10000 synthetic realisations of the 3 correlated RVs.
SynthRVs=SimCorrRVs(n=10000,paramsRVs=paramsRVs)
# Comparison of target and simulation correlation matrix.
pairs(SynthRVs)
CorrelMatSim=cor(SynthRVs)
difference=(CorrelMat-CorrelMatSim)^2; print(difference)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.