A simulation of t-student copulas using Monte Carlo method
5 views (last 30 days)
Show older comments
I am trying to do a simulation of t-student copulas using Monte Carlo method. However, I am not sure whether my way of doing it is right. Could you guys check whether I am right or wrong please?
Here is my code:
% do a Kernel smoothing function estimate for my five variables
U12=ksdensity(X1,X1,'function','cdf')
U22=ksdensity(X2,X2,'function','cdf')
U32=ksdensity(X3,X3,'function','cdf')
U42=ksdensity(X4,X4,'function','cdf')
U52=ksdensity(X5,X5,'function','cdf')
% calculate the estimate of the correlation matrix and number of degrees
[rho_N_t,nuhat,nuci]=copulafit('t',[ U12(:),U22(:),U32(:),U42(:),U52(:)])
% Kendall's rank correlation
Kendall_t = copulastat('t',rho_N_t)
% Find the Cholesky decomposition
L = chol(Kendall_t,'lower')
U = zeros(10000,5);
% repeat 10000 times
for n=1:10000
% Simulate 5 independent random variates from N(0,1).
z = normrnd(0,1,5,1)
y = L*z
% Simulate a random variate s from Chi-square distribution
s = chi2rnd(nuhat)
x = sqrt(v)/sqrt(s)*y
u = tcdf(x,v)
u_c = u'
U(n,:) = u_c
end
% return to the original scale
yy1= ksdensity(X1, U(:,1),'function','icdf')
yy2= ksdensity(X2, U(:,2),'function','icdf')
yy3= ksdensity(X3, U(:,3),'function','icdf')
yy4= ksdensity(X4, U(:,4),'function','icdf')
yy5= ksdensity(X5, U(:,5),'function','icdf')
0 Comments
Answers (0)
See Also
Categories
Find more on Monte-Carlo in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!