全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3707 1
2011-07-04
One of useful applications of Choleshk decompostion in a simulation study is to generate random variables with a given covariance structure. In following example, Cholesky decomposition algorithm is writen in IML. The whole logic can be easily implemented a data step. This means that one can easily to generate multivariate random variables with a covariance structure in a date step.


The Cholesky decomposition algorithm can be found at this link,

http://en.wikipedia.org/wiki/Cholesky_decomposition


proc iml;
A = { 0.9858668         0.9832139         0.8740793         0.9125018         0.8980966,
0.9832139         2.0058248         2.0107842         2.0543280         2.0244553,
0.8740793         2.0107842        99.1966824        99.1846182        99.0462248,
0.9125018         2.0543280        99.1846182       100.1625760       100.0319877,
0.8980966         2.0244553        99.0462248       100.0319877       100.8799631
};
U = root(A);
start choldc( A) ;
n=nrow(a);
L=j(n,n,0);
****i=1,j=1****;
L[1,1]=sqrt(A[1,1);
L[2:N,1]=A[2:N,1]/L[1,1];
do i=2 to n;
   do j=i to n;
     sum=A[i,j];
  do k=i-1 to 1 by -1;
    sum = sum - L[i,k]*L[j,k];
  end;
  if i=j then L[i,i]=sqrt(sum);
  else L[j,i]=sum/L[i,i];
   end;
  end;
  return(L`) ;
  finish;
L=choldc( A) ;
print  u L;
  
quit;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-8-11 18:03:29
不是甚懂 求注释
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群