Simulating dependent normally distributed variables using copulas
조회 수: 2 (최근 30일)
이전 댓글 표시
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,
댓글 수: 0
답변 (1개)
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) .
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!