Simulating dependent normally distributed variables using copulas

4 ビュー (過去 30 日間)
Alexandra
Alexandra 2014 年 12 月 10 日
回答済み: Tom Lane 2014 年 12 月 17 日
I created a model that simulates variables with kernel distributions connected by copula functions. (X and Y are series of ln returns)
It looks like this: kX = ksdensity(X,X,'function','cdf'); kY = ksdensity(Y,Y,'function','cdf'); [Rho,nu] = copulafit('t',[kX kY],'Method','ApproximateML'); r = copularnd('t',Rho,nu,100000); XX = r(:,1); YY = r(:,1); SX = ksdensity(X,XX,'function','icdf'); SY = ksdensity(Y,YY,'function','icdf'); SimX = a*exp(SX); SimY = b*exp(SY);
Now I wish to evaluate the results when modeling the variables as normally distributed. I can’t see what function can directly substitute ksdensity in the model. I was trying to do this with:
kX = normcdf(X); kY = normcdf(Y); [Rho,nu] = copulafit('t',[kX kY],'Method','ApproximateML'); r = copularnd('t',Rho,nu,100000); XX = r(:,1); YY = r(:,1); SX = norminv(X,XX); SY = norminv(Y,YY); SimX = a*exp(SX); SimY = b*exp(SY);
But is not working because norminv does not support the second argument with the copula function. I am seeing this right? What can I do?
Thank you very much,

回答 (1 件)

Tom Lane
Tom Lane 2014 年 12 月 17 日
Consider formatting your question so the code is not wrapped into the text.
The syntax ksdensity(x,xx) computes a kernel density based on x, evaluated at xx. If you intend to use the standard normal distribution, I believe you want just norminv(xx) .

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by